GDI+ Generic Error work around.

Use this board to post your code snippets - tips and tricks
1 post Page 1 of 1
Contributors
User avatar
Scottie1972
Codenstuff Elite
Codenstuff Elite
Posts: 953
Joined: Thu Jan 14, 2010 5:48 am

GDI+ Generic Error work around.
Scottie1972
if you ever are working with images ans keep receiving a error message like this
Image

and you just cant google a answer.
this is what you can do.

if you use a button to run the code
Code: Select all
Dim bmp as new BitMap("path_to_image")
bmp.Save("new_image_path_&_name.ext",System.Drawing.Imaging.ImageFormat.FILE_EXTENTION)
Add a Timer control to your project.
Set it for 3 to 5 seconds 3000/5000
Timer.Interval = 3000 to 5000
Timer.Enabled = True
Timer.Start()
Code: Select all
Dim bmp as new BitMap("path_to_image")
bmp.Save("new_image_path_&_name.ext",System.Drawing.Imaging.ImageFormat.FILE_EXTENTION)


ButtonYouJust_Clicked.Enabled = False

Timer.Interval = 3000 to 5000
Timer.Enabled = True
Timer.Start()

Now in the Timer_Tick Event simple re-enable the button and turn the timer off
Code: Select all
ButtonYouJust_Clicked.Enabled = True

Timer.Enabled = False
Timer.Stop()

All this does is disables the Button or whatever control until the GDI+ has finished what it is doing in the background.
normally a few seconds depending on the size of the image. but a minimum of 3 seconds is a good start.

And another piece or advise. on GDI+
If you are working on a Image and you keep getting the Access Denied error message.
This is because the Image is "Open or being used". You need to .Close() or .Dispose() of the image first
then you can continue work work on it.

Believe it or not, this error is really a .NET Framework issue and not the programmer.
Image
1 post Page 1 of 1
Return to “Quick Snips”