Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Strange GDI+ error

Strange GDI+ error

Scheduled Pinned Locked Moved C#
graphicshelpwinformsquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #1

    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?

    H L 2 Replies Last reply
    0
    • A Anonymous

      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?

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      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 (which Bitmap 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

      S 1 Reply Last reply
      0
      • A Anonymous

        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?

        L Offline
        L Offline
        leppie
        wrote on last edited by
        #3

        Search on Google groups, I had the same problem a few years back. Sorry I cant recall the resolution though :( top secret

        1 Reply Last reply
        0
        • H Heath Stewart

          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 (which Bitmap 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

          S Offline
          S Offline
          Stephane David
          wrote on last edited by
          #4

          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:

          H 1 Reply Last reply
          0
          • S Stephane David

            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:

            H Offline
            H Offline
            Heath Stewart
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups