Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Drawing / April 2008

Tip: Looking for answers? Try searching our database.

Maximum Bitmap size

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
usenet@tynemarch.co.uk - 09 Apr 2008 15:34 GMT
When I use the following code in a web page it works fine until my
Bitmap size gets to a certain size, e.g. 5214 x 3223. Then I get a red
cross, but no run time error occurs. What is the maxmum size of the
bitmap and how do I trap for the error?

Code is here. The actual details of what is draw is not relevant.

       Dim objBitmap As Bitmap = New Bitmap(5214, 3223)
       Dim objGraphics As Graphics = Graphics.FromImage(objBitmap)

    ' DRAWING CODE HERE

       Response.ContentType = "image/gif"

       objGraphics.DrawImage(objBitmap, 0, 0, objBitmap.Width,
objBitmap.Height)
       objBitmap.Save(Response.OutputStream, ImageFormat.Gif)

       objGraphics.Dispose()
       objBitmap.Dispose()
Bob Powell [MVP] - 10 Apr 2008 00:01 GMT
The maximum size of a bitmap is governed by the memory available to the
application. Even in the best possible case of an application with very
little used resources, the address space is limited so as you fill it up (2
gigs max for a 32 bit process I think) the maximum you can allocate is
reduced.

The bitmap you quote is about 67.2 megs uncompressed.

Signature

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

Ramuseco Limited .NET consulting
http://www.ramuseco.com

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.

> When I use the following code in a web page it works fine until my
> Bitmap size gets to a certain size, e.g. 5214 x 3223. Then I get a red
[quoted text clipped - 16 lines]
>        objGraphics.Dispose()
>        objBitmap.Dispose()
Norman Diamond - 10 Apr 2008 01:14 GMT
One limit is that the DotNet framework refuses to create an object of size
greater than 2GB, even in 64-bit versions of Windows.  However, you haven't
reached that limit.

There can also be trouble with fragmentation of the virtual address space.
One of the biggest offenders here is the DLL that shows common dialog boxes
to let the user specify a file to be opened or saved.  That DLL was given a
base address that is unlikely to conflict with other DLLs, so the DLL
doesn't need to be rebased when loaded, and that saves some number of
microseconds when loading the DLL.  However, it's right smack in the middle
of the process's virtual address space.  So after that DLL is loaded you
can't even create an object of size 1GB.  This should be a lot less of a
problem in 64-bit versions of Windows.

> When I use the following code in a web page it works fine until my
> Bitmap size gets to a certain size, e.g. 5214 x 3223. Then I get a red
[quoted text clipped - 16 lines]
>        objGraphics.Dispose()
>        objBitmap.Dispose()

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.