How do I resize to 100px by 100px and save the image in picturebox as a PNG? I can do the saving but the output file won't open. The code I only have is below.
The basics for a thumbnail are fairly straight forward:
For saving, you might want to add ".png" to the filename. Since your image is in a picbox, get it out for less typing:
Dim bmp As Bitmap = CType(picbox.Image, Bitmap) ' bmpt is the thumbnail Dim bmpt As New Bitmap(100, 100) Using g As Graphics = Graphics.FromImage(bmpt) ' draw the original image to the smaller thumb g.DrawImage(bmp, 0, 0, bmpt.Width + 1, bmpt.Height + 1) End Using bmpt.Save("example_file.PNG", System.Drawing.Imaging.ImageFormat.Png)
Bitmapyou create must be disposed of when you are done with it.
bmpt.Dispose()as the last line.
PictureBox) you wont be able to save to the same file name. Alter the name slightly such as "myFoo" saved as "myFoo_t".
Bitmapfrom the other.