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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. GDI+ A generic error occurred

GDI+ A generic error occurred

Scheduled Pinned Locked Moved C#
helpwinformsgraphics
9 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.
  • B Offline
    B Offline
    ben2
    wrote on last edited by
    #1

    Hi, In my windows application if I'm getting ExternalException when I use the following to methods if the text parameter is too large. g.MeasureString(text, font, size, format); g.DrawString(text, font, color, rectangle, format); I have tried to make the size and rectangle parameters to be large so that it fits the text, but I still get the same exception with Message : "A Genric error occurred" Please let me know how I can fix this. Thanks Ben

    C L 2 Replies Last reply
    0
    • B ben2

      Hi, In my windows application if I'm getting ExternalException when I use the following to methods if the text parameter is too large. g.MeasureString(text, font, size, format); g.DrawString(text, font, color, rectangle, format); I have tried to make the size and rectangle parameters to be large so that it fits the text, but I still get the same exception with Message : "A Genric error occurred" Please let me know how I can fix this. Thanks Ben

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      How big is your string ?

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

      B 1 Reply Last reply
      0
      • C Christian Graus

        How big is your string ?

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

        B Offline
        B Offline
        ben2
        wrote on last edited by
        #3

        Length of the string 103325

        C 1 Reply Last reply
        0
        • B ben2

          Hi, In my windows application if I'm getting ExternalException when I use the following to methods if the text parameter is too large. g.MeasureString(text, font, size, format); g.DrawString(text, font, color, rectangle, format); I have tried to make the size and rectangle parameters to be large so that it fits the text, but I still get the same exception with Message : "A Genric error occurred" Please let me know how I can fix this. Thanks Ben

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Instead of trying to draw one large string why don't you break it up and draw them individually?

          █▒▒▒▒▒██▒█▒██ █▒█████▒▒▒▒▒█ █▒██████▒█▒██ █▒█████▒▒▒▒▒█ █▒▒▒▒▒██▒█▒██

          B 1 Reply Last reply
          0
          • L Lost User

            Instead of trying to draw one large string why don't you break it up and draw them individually?

            █▒▒▒▒▒██▒█▒██ █▒█████▒▒▒▒▒█ █▒██████▒█▒██ █▒█████▒▒▒▒▒█ █▒▒▒▒▒██▒█▒██

            B Offline
            B Offline
            ben2
            wrote on last edited by
            #5

            I can, but I'm more interested in find out if there is a cutoff on the length of the string that gdi+ can handle thru these 2 methods.

            L 1 Reply Last reply
            0
            • B ben2

              Length of the string 103325

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              Well, that's just silly :-) That error generally means you've used too much of a resource, or you've tried to use a resource that's not available to you. With that many chars, I am not surprised.

              Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

              B 1 Reply Last reply
              0
              • C Christian Graus

                Well, that's just silly :-) That error generally means you've used too much of a resource, or you've tried to use a resource that's not available to you. With that many chars, I am not surprised.

                Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

                B Offline
                B Offline
                ben2
                wrote on last edited by
                #7

                Is there any work around?

                1 Reply Last reply
                0
                • B ben2

                  I can, but I'm more interested in find out if there is a cutoff on the length of the string that gdi+ can handle thru these 2 methods.

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

                  GDI+ works with strings that are either "Pascal strings" (length + data) or "C strings" (null terminated), so it has a explicit notion of string length (which gets set to -1 for C strings). And I would not be surprised there are some 16-bit limitations to integer quantities (hence max 65535 or even 32767 since -1 suggests signed integers are used for lengths). one thing I found after a quick Google was: "Due to a limitation of the GDI+ decoder, an System.ArgumentException is thrown if you construct a bitmap from a .png image file with a single dimension greater than 65,535 pixels." If you really want to know, continue searching, or perform some experiments. I would suggest trying string lengths of 32700, 32800, 65500 and 65600. :)

                  Luc Pattyn

                  B 1 Reply Last reply
                  0
                  • L Luc Pattyn

                    GDI+ works with strings that are either "Pascal strings" (length + data) or "C strings" (null terminated), so it has a explicit notion of string length (which gets set to -1 for C strings). And I would not be surprised there are some 16-bit limitations to integer quantities (hence max 65535 or even 32767 since -1 suggests signed integers are used for lengths). one thing I found after a quick Google was: "Due to a limitation of the GDI+ decoder, an System.ArgumentException is thrown if you construct a bitmap from a .png image file with a single dimension greater than 65,535 pixels." If you really want to know, continue searching, or perform some experiments. I would suggest trying string lengths of 32700, 32800, 65500 and 65600. :)

                    Luc Pattyn

                    B Offline
                    B Offline
                    ben2
                    wrote on last edited by
                    #9

                    Thanks for the info

                    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