Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Maximum Bitmap Size?

242 views
Skip to first unread message

James Westgate

unread,
Jun 10, 2005, 11:34:44 AM6/10/05
to
I have to ask why you need to create a bitmap that is going to take up at
least 4050 x 40750 x 4 bytes of memory?
There will be an upper limit to stop you from doing this, but Im not sure
what it is. in my experience bitmaps above 10000x10000 become pretty much
unusable from GDI+ anyway.

James

"mike" <mi...@discussions.microsoft.com> wrote in message
news:0006C8F4-4E2D-4FD8...@microsoft.com...
> Hi,
>
> I am trying to create a bitmap using the (int,int) constructor.
>
> I am getting an invalid parameter exception when I pass in the following
> values
>
> Bitmap bm = new Bitmap(4050,40750);
>
> Is there a maximum size limit I am hitting when I try this?
>
> Thanks
>
> Jay


SharpCoderMP

unread,
Jun 13, 2005, 4:41:39 PM6/13/05
to
:D
Bob Powell has somwhere on his site test for image limits...
http://www.bobpowell.net/faqmain.htm
as far as i can remeber he got something of about a mile wide.
but still, james right. what for do you need such a huge bitmap?

mike

unread,
Jun 13, 2005, 6:30:01 PM6/13/05
to
I personally dont have any desire to create an image that size.

However, we do provide our users the ability to save graphical output as an
image instead of sending it to a plotter, and in this case the image was 13.5
inches wide, and 136 inches long, and the user had selected 300 dpi.

These plot sizes are not uncommon for our application.

Mainly what I was hoping for was the limit constraints so I could include
those in my dialog box when validating the image settings, as opposed to just
popping up a message saying "Image too Big", without being able to give an
answer to the user as to what the largest size image is.

Anyway.. thanks for the input

Bob Powell [MVP]

unread,
Jun 14, 2005, 6:32:07 AM6/14/05
to
The article as on the limits of the drawing surface bounds as defined by the
maximum number that can be used. This is somewhere in the region of several
thousand miles on each side but this is theoretical and has no relation to
the capacity of the computer to manipulate the image.

Each image in the system has the amount of memory defined by this formula..

bit-depth*width*height/8

This means that an image 40800 pixels by 4050 will require over 660
megabytes of memory. To manipulate this image. Especially to print it you
need a minimum of twice this much live memory and probably more because the
printdrivers may also be doing some banding as well. This doesn't take into
account the amount of memory required by the system or any other images that
might be in it.

Theoretically .NET can manipulate these large images. In practice however,
the strain placed on the paging system for virtual memory is so great that
the system will grind to a halt and will seem to have frozen. The only way
to enable the use of large images is to have lots and lots of free memory.
Four gigabytes would be a useful minimum. More would be better.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"SharpCoderMP" <csha...@interia.pl.NFSPM> wrote in message
news:Ov$fIhFcF...@TK2MSFTNGP09.phx.gbl...

mike

unread,
Jun 14, 2005, 11:45:03 AM6/14/05
to
Thanks again for the response.

I guess my main goal is to determine what check is being done in the .Net
code on the parameters and throwing the exception. It would be much more
meaningful to the users if I could actually document the size limit
constraints and also perform some validation in the UI before trying to
create an image.

I realize the size of that file would be huge, but I really just want to
understand the hard limits of the Bitmap constructor (if there are any).

The problem I run into is it isn't uncommon for some of our outputs to be
42" x 72" (and greater). When drawing to a plotter this all works fine, but
we also give the user the ability to save as an image so they can include the
output in a report (either powerPoint, Word, etc.). Clearly it makes no sense
to save the image as 42" X 72" at 300dpi if it is just going to be included
on a PP slide, but that doesn't mean a user won't try to do it.

Anyway.. again, thanks for your input, and also your website.

0 new messages