Why does a saved photo disappear after a few moments when it is opened?

  • Thread starter Thread starter Saulius LT
  • Start date Start date
S

Saulius LT

Guest
1. I save a transparent picture in png format.


2. Open the photo (with Microsoft photos) by clicking on it.


3. The photo disappears after a moment.


4. This problem does not occur when the picture is opaque or open with another program.


5. How do I change the code to avoid this problem?

Public Class Form1
Dim img As Bitmap
Dim px(,) As Color
Dim im As Image = Image.FromFile("C:\Users\Saulius\Pictures\Saved Pictures\eifelis.png")
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
PictureBox1.Width = 1000
PictureBox1.Height = PictureBox1.Width / (im.Width / im.Height)
img = New Bitmap(im, PictureBox1.Width, PictureBox1.Height)
PictureBox1.Image = img
ReDim px(img.Width, img.Height)
End Sub
Sub tt()
For y As Integer = 0 To img.Height - 1
For x As Integer = 0 To img.Width - 1
px(x, y) = img.GetPixel(x, y)
Next
Next
Dim newy, newx As Integer
img = New Bitmap(PictureBox1.Width, PictureBox1.Height)
PictureBox1.Image = img
For y As Integer = 0 To img.Height - 1
newy = Math.Ceiling(Math.Sin(Math.PI / 180.0 * ((y + 1) * (90.0 / img.Height))) * (y + 1))
For x As Integer = 0 To img.Width - 1
newx = Math.Ceiling(Math.Sin(Math.PI / 180.0 * ((x + 1) * (90.0 / img.Width))) * (x + 1))
img.SetPixel(x, y, Color.FromArgb(50, Convert.ToInt32(px(x, newy - 1).R), Convert.ToInt32(px(x, newy - 1).G), Convert.ToInt32(px(x, newy - 1).B)))
Next
Next
End Sub
Private Sub PictureBox1_Paint(sender As Object, e As PaintEventArgs) Handles PictureBox1.Paint

End Sub
Dim j As Integer
Private Sub Form1_MouseClick(sender As Object, e As MouseEventArgs) Handles MyBase.MouseClick
tt()
img.Save("C:\Users\Saulius\Desktop\photo.png", Imaging.ImageFormat.Png)
End Sub
End Class


Disappear:

1504916.png

This saved Picture:

1504917.png

Continue reading...
 
Back
Top