Results 1 to 5 of 5

Thread: Generic Error in GDI when creating a PNG file

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    523

    Generic Error in GDI when creating a PNG file

    I will attach a documented demo app to illustrate the problem I am having.
    Each of these cases work
    • I can successfully create a PNG file based on a specified control on the form. I can them load the PNG into a picture box.
    • Repeatedly create the PNG, with the same file name but not displaying it
    • Displaying Pic2, but then creating Pic1

    What does not work
    • Displaying the image of Pic1, then trying to overwrite PNG1 with the same file name. It does not matter if the Picture in the picture box has been replaced or not.


    It gives the error "System.Runtime.InteropServices.ExternalException: 'A generic error occurred in GDI+.'"

    If I stop and rerun it, no problem until I load an image that I try to overwrite. It seems like the file is being locked as soon as I read it, which prevents me from writing over it. In any case you can see for your self with the code.

    Any suggestions?
    Attached Files Attached Files

  2. #2
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: Generic Error in GDI when creating a PNG file

    Didn't look at the code yet, but perhaps this thread is applicable to the issue you're having.
    "Anyone can do any amount of work, provided it isn't the work he is supposed to be doing at that moment" Robert Benchley, 1930

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    523

    Re: Generic Error in GDI when creating a PNG file

    That does look like it might address the issue. It will be a while until I can check it out, but I do appreciate the pointer to that post.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Generic Error in GDI when creating a PNG file

    Nobody wants to have to download a ZIP file, extract it, open a solution and then trawl through it hoping to find the relevant part. That should be a last resort. Post the relevant code and ONLY the relevant code directly so that we can just read it and then copy and paste it if required.

    Also, the size of your attachment strongly suggests that it contains binary files, which is against site rules. If you are going to attach a zipped solution, ALWAYS delete any bin and obj folders first.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    523

    Re: Generic Error in GDI when creating a PNG file

    Point taken. I will be mindful of that in the future.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width