GDI+ A generic error occurred
-
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
-
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
How big is your string ?
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
How big is your string ?
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
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
-
Instead of trying to draw one large string why don't you break it up and draw them individually?
█▒▒▒▒▒██▒█▒██ █▒█████▒▒▒▒▒█ █▒██████▒█▒██ █▒█████▒▒▒▒▒█ █▒▒▒▒▒██▒█▒██
-
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
-
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
-
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.
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
-
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