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. GDI Exception

GDI Exception

Scheduled Pinned Locked Moved C#
graphicswinformshelp
6 Posts 3 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.
  • D Offline
    D Offline
    DeepOceans
    wrote on last edited by
    #1

    Hi I m facing exception while saving an image. The code is //this line throws Exception picturebox.Image.Save(memorystream, System.Drawing.Imaging.ImageFormat.Jpeg ); and exception is: "A generic error occurred in GDI+." So plz tell me the solution Regards

    Shanzay

    A L 2 Replies Last reply
    0
    • D DeepOceans

      Hi I m facing exception while saving an image. The code is //this line throws Exception picturebox.Image.Save(memorystream, System.Drawing.Imaging.ImageFormat.Jpeg ); and exception is: "A generic error occurred in GDI+." So plz tell me the solution Regards

      Shanzay

      A Offline
      A Offline
      Anthony Mushrow
      wrote on last edited by
      #2

      My guess is that there is something up with the memory stream. Try saving the image to a file (by passing a string) instead of a stream. If the error still occurs, then it must be a problem with the image.

      My current favourite word is: Waffle Cheese is still good though.

      1 Reply Last reply
      0
      • D DeepOceans

        Hi I m facing exception while saving an image. The code is //this line throws Exception picturebox.Image.Save(memorystream, System.Drawing.Imaging.ImageFormat.Jpeg ); and exception is: "A generic error occurred in GDI+." So plz tell me the solution Regards

        Shanzay

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        Hi, almost all errors occuring in GDI+ lead to the same message, so it can be many things. Most liekly in your case: you have forgotten to reposition the stream, if you write data to a stream, its position advances; now if you want to save the image, you need to set the position to zero again. Try memorystream.Position=0 before Image.Save :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google


        D 1 Reply Last reply
        0
        • L Luc Pattyn

          Hi, almost all errors occuring in GDI+ lead to the same message, so it can be many things. Most liekly in your case: you have forgotten to reposition the stream, if you write data to a stream, its position advances; now if you want to save the image, you need to set the position to zero again. Try memorystream.Position=0 before Image.Save :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google


          D Offline
          D Offline
          DeepOceans
          wrote on last edited by
          #4

          hi, Thanx for reply. I did this but still getting this error.Actually I m sending Live video from server to client and after recieving every frame this error is displaying so what should I do in this Scenario.

          Shanzay

          L 1 Reply Last reply
          0
          • D DeepOceans

            hi, Thanx for reply. I did this but still getting this error.Actually I m sending Live video from server to client and after recieving every frame this error is displaying so what should I do in this Scenario.

            Shanzay

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #5

            did you succeed in saving to a file as the other reply suggested?

            Luc Pattyn [Forum Guidelines] [My Articles]


            this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google


            D 1 Reply Last reply
            0
            • L Luc Pattyn

              did you succeed in saving to a file as the other reply suggested?

              Luc Pattyn [Forum Guidelines] [My Articles]


              this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google


              D Offline
              D Offline
              DeepOceans
              wrote on last edited by
              #6

              yah well I got success by adding two things 1. used thread.Sleep() before saving 2. used file.jpg instead memorystream. Thanx.

              Shanzay

              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