Strange GDI+ error
-
I have a gif file, 256 colors, created with Paint Shop Pro. I do // Load the bitmap Bitmap myBitmap = new Bitmap ("toto.gif"); // Cut it Bitmap frame = myBitmap.Clone(Rectangle); // Save individual frames frame.Save("Frame1.gif", Imaging.PixelFormat.Gif); It works OK. Latter, I want to load the saved frame // Load the frame again Bitmap frame = new Bitmap("frame1.gif"); This works also. But, if I try to save it again frame.Save("Frame2.gif"); I got an external exception in InteropServices, telling me there was a problem with GDI+.dll. Anybody had the same problem?
-
I have a gif file, 256 colors, created with Paint Shop Pro. I do // Load the bitmap Bitmap myBitmap = new Bitmap ("toto.gif"); // Cut it Bitmap frame = myBitmap.Clone(Rectangle); // Save individual frames frame.Save("Frame1.gif", Imaging.PixelFormat.Gif); It works OK. Latter, I want to load the saved frame // Load the frame again Bitmap frame = new Bitmap("frame1.gif"); This works also. But, if I try to save it again frame.Save("Frame2.gif"); I got an external exception in InteropServices, telling me there was a problem with GDI+.dll. Anybody had the same problem?
I'm not sure exactly what you're trying to do (which may help to understand the problem and help you solve it), but take a look at the
Image.SaveAdd
method (whichBitmap
would inherit, of course) to see how to save individual frames of an animated GIF, which I'm guessing is what you're trying to accomplish.Microsoft MVP, Visual C# My Articles
-
I have a gif file, 256 colors, created with Paint Shop Pro. I do // Load the bitmap Bitmap myBitmap = new Bitmap ("toto.gif"); // Cut it Bitmap frame = myBitmap.Clone(Rectangle); // Save individual frames frame.Save("Frame1.gif", Imaging.PixelFormat.Gif); It works OK. Latter, I want to load the saved frame // Load the frame again Bitmap frame = new Bitmap("frame1.gif"); This works also. But, if I try to save it again frame.Save("Frame2.gif"); I got an external exception in InteropServices, telling me there was a problem with GDI+.dll. Anybody had the same problem?
Search on Google groups, I had the same problem a few years back. Sorry I cant recall the resolution though :( top secret
-
I'm not sure exactly what you're trying to do (which may help to understand the problem and help you solve it), but take a look at the
Image.SaveAdd
method (whichBitmap
would inherit, of course) to see how to save individual frames of an animated GIF, which I'm guessing is what you're trying to accomplish.Microsoft MVP, Visual C# My Articles
I have a storyboard, a single image that contains several frames. My program cut this storyboard in individual frames, of variable size. I now want to save these individual frames in separate files. This part works. The gif are indeed saved. Later I need to make copies of some of these files, after I've done some processing on memory on them. So I start by loading the individual frames doing Bitmap bitmap = new Bitmap("Frame1.gif"); // Then some processing // Then I save it again bitmap.Save("Frame1.gif", PixelFormat.gif); And there it crashes. I have tried to do the save immediatly after the load, in case my processing was messing something, but it still doesn't work. Conclusion: I cannot save a bitmap immediately after I load it? :confused:
-
I have a storyboard, a single image that contains several frames. My program cut this storyboard in individual frames, of variable size. I now want to save these individual frames in separate files. This part works. The gif are indeed saved. Later I need to make copies of some of these files, after I've done some processing on memory on them. So I start by loading the individual frames doing Bitmap bitmap = new Bitmap("Frame1.gif"); // Then some processing // Then I save it again bitmap.Save("Frame1.gif", PixelFormat.gif); And there it crashes. I have tried to do the save immediatly after the load, in case my processing was messing something, but it still doesn't work. Conclusion: I cannot save a bitmap immediately after I load it? :confused:
That is weird, and I frankly don't know the answer to that. But there is a better, more efficient way of copying files anyway:
File.Copy
.Microsoft MVP, Visual C# My Articles