I have a program which edits image colour values.
Program works perfectly except that I can only save image to a new filename - I cannot overwrite the original file
Can anyone help?
Program works perfectly except that I can only save image to a new filename - I cannot overwrite the original file
Can anyone help?
Code:
ImageBitmap = New Bitmap(filename)
For x = 0 To ImageBitmap.Width - 1
For y = 0 To ImageBitmap.Height - 1
Rbyte = ImageBitmap.GetPixel(x, y).R
Gbyte = ImageBitmap.GetPixel(x, y).G
Bbyte = ImageBitmap.GetPixel(x, y).B
'#### some byte manipulation
ImageBitmap.SetPixel(x, y, Color.FromArgb(Rbyte, Gbyte, Bbyte))
Next
Next
ImageBitmap.Save(filename, Imaging.ImageFormat.Png) '### This throws an exception
#### if I change the filename and save as below - everything OK
filename2 = Mid(filename, 1, Len(filename) - 4) & "2.png"
ImageBitmap.Save(filename2, Imaging.ImageFormat.Png) '### This works perfectly
Comment