|
-
Feb 4th, 2009, 05:09 PM
#1
Thread Starter
Frenzied Member
[2005] Bitmap constructor bombs
I have a third party GIS tool that I'm using to view maps with. Occasionally we have to take a snapshot of a portion of the map and dump it to a bitmap.
The third party tool has a function that will give me the upper left and lower right coordinates of the area selected on the map. These coordinates come out as system.drawing.point objects.
The two point objects are then used to generate a new system.drawing.size object that will give the height and width of the area selected. The height and width values are passed to the constructor for the system.drawing.bitmap.
All this works fine most of the time. Sometimes, however, when the user selects a particularly large area, the bitmap constructor bombs with a 'parameter is not valid' error. There isn't any documentation on this error, but I'm assuming it means the height and width are too big.
So what I'm wondering is... is there some way to check my height and width values prior to creating the bitmap and make sure they are in acceptable bounds?
 I always add to the reputation of those whose posts are helpful, and even occasionally to those whose posts aren't helpful but who obviously put forth a valiant effort. That is, when the system will allow it.
My war with a browser-redirect trojan
-
Feb 4th, 2009, 05:42 PM
#2
Re: [2005] Bitmap constructor bombs
how big are we talking here? I am pretty sure the limit is not finite, but limited by the amount of ram on the given machine that can be allocated to the application.
-
Feb 4th, 2009, 10:41 PM
#3
Re: [2005] Bitmap constructor bombs
Have you checked the StackTrace of the exception? The error message is not necessarily referring to a parameter of the Bitmap constructor. The call stack may give you a better idea of exactly what's going wrong.
It's probably also worth your while to test out the functionality and try to nail down EXACTLY what values will work and which cause the issue.
-
Feb 4th, 2009, 10:44 PM
#4
Re: [2005] Bitmap constructor bombs
I can confirm I get the same error message trying to make a new bitmap object with integer.maxvalue for the height and width params. So it likely is a (poorly worded) generic error that is bubbling up when there is not enough resources to reserve the bitmap space you are trying to allocate.
-
Feb 5th, 2009, 11:55 AM
#5
Thread Starter
Frenzied Member
Re: [2005] Bitmap constructor bombs
I believe it is a memory-related problem since I can't, as JMC suggests, nail it down exactly. Just when I think I've found the exact number that causes the problem I run it again and that number works, so I find a new number that causes the problem. It's in a range somewhere around 10,000 X 10,000 - which is utterly huge. The call stack doesn't reveal anything beyond the call to the bitmap constructor - unfortunately.
I got a suggestion on another site from a guy who's more familiar with this third party tool I'm using so I'm gonna pursue that and then let ya'll know.
Thanks for the help!
 I always add to the reputation of those whose posts are helpful, and even occasionally to those whose posts aren't helpful but who obviously put forth a valiant effort. That is, when the system will allow it.
My war with a browser-redirect trojan
-
Feb 5th, 2009, 05:22 PM
#6
Thread Starter
Frenzied Member
Re: [2005] Bitmap constructor bombs
Turns out the third party tool I was using had a class for exporting via jpeg, which was the final output of my bitmap. So rather than creating a bitmap and saving it as a jpeg, the third party tool renders it as a jpeg directly, which give me much better lattitude.
Thanks again for the help guys!
 I always add to the reputation of those whose posts are helpful, and even occasionally to those whose posts aren't helpful but who obviously put forth a valiant effort. That is, when the system will allow it.
My war with a browser-redirect trojan
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|