By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,725 Members | 1,094 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,725 IT Pros & Developers. It's quick & easy.

Drawing large bitmaps

P: n/a
I'm having trouble dealing with bitmaps larger than about 10,000 pixels in
either direction.

I've tried using DrawImage and DrawImageUnscaled, but both give me out of
memory errors.

In my case, I'm simply trying to draw a portion of the bitmap. The portion
is slightly under the 1600x1200 size of my screen.

When trying to do it, I get an Out of Memory exception.

Searching Google returned this issue as common with large, but what I
haven't been able to find is a workaround.

Anyone have any ideas? Am I going to have to write unamanaged code to do
this?

Pete
Nov 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

"Pete Davis" <pdavis68@[nospam]hotmail.com> wrote in message
news:06********************@giganews.com...
I'm having trouble dealing with bitmaps larger than about 10,000 pixels in
either direction.

I've tried using DrawImage and DrawImageUnscaled, but both give me out of
memory errors.

In my case, I'm simply trying to draw a portion of the bitmap. The portion
is slightly under the 1600x1200 size of my screen.

When trying to do it, I get an Out of Memory exception.

Searching Google returned this issue as common with large, but what I
haven't been able to find is a workaround.

Anyone have any ideas? Am I going to have to write unamanaged code to do
this?

Pete


Any idea how large your bitmap of 10000 * 10000 is in Mb?
The fact that you only draw a portion of it doesn't matter, the whole bitmap
file has to be mapped in your Virtual Address space.

Willy.
Nov 17 '05 #2

P: n/a
Well, the process is getting up to about 500MB at the time of the exception.
Well within the 2 1/2 gb of my system. 10,000x10,000x32 is only about 400MB.
With virtual memory, I could do about 8-10 times that.

I don't think the computer is literally running out of memory.

I've loaded larger in Adobe Photoshop and it doesn't crash.
Pete
"Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in message
news:OC**************@TK2MSFTNGP14.phx.gbl...

"Pete Davis" <pdavis68@[nospam]hotmail.com> wrote in message
news:06********************@giganews.com...
I'm having trouble dealing with bitmaps larger than about 10,000 pixels
in either direction.

I've tried using DrawImage and DrawImageUnscaled, but both give me out of
memory errors.

In my case, I'm simply trying to draw a portion of the bitmap. The
portion is slightly under the 1600x1200 size of my screen.

When trying to do it, I get an Out of Memory exception.

Searching Google returned this issue as common with large, but what I
haven't been able to find is a workaround.

Anyone have any ideas? Am I going to have to write unamanaged code to do
this?

Pete


Any idea how large your bitmap of 10000 * 10000 is in Mb?
The fact that you only draw a portion of it doesn't matter, the whole
bitmap file has to be mapped in your Virtual Address space.

Willy.

Nov 17 '05 #3

P: n/a
Not at all, each process in Windows (32 bit) has a maximum of 2GB available
as Virtual Address Space (VAS), this 2GB is used to load code pages as well
as Data pages, your Bitmap is loaded by GDI+ (used by System.Drawing) from a
Filestream into a native heap buffer and copied to the Image buffer, also in
the native heap, that means you need aprox. two times (the file is somewhat
smaller ) the size of the raw image, that is two contiguous blocks of 400Mb
of memory. The problem however is GDI+ (gdiplus.dll) which is loaded
somewhere at address 0x4ec50000[1] in VAS, while most other DLL's are loaded
at top of memory and your code modules at the bottom together with the GC
heap. While in general you may have a total of 1.9 GB VAS available, there
is no guarantee there is 800 Mb available in one large chunk, or two chunks
of > 400Mb, especial if there are other modules or data-structures loaded or
when there are many objects allocated from the GC heap.
Note also that you can't compare Photoshop (not using GDI+) and .NET which
is using GDI+.

Willy.

[1] this custs the initial heap into two portions one of ~1.2 Gb and another
of ~360Mb

"Pete Davis" <pdavis68@[nospam]hotmail.com> wrote in message
news:u6******************************@giganews.com ...
Well, the process is getting up to about 500MB at the time of the
exception. Well within the 2 1/2 gb of my system. 10,000x10,000x32 is only
about 400MB. With virtual memory, I could do about 8-10 times that.

I don't think the computer is literally running out of memory.

I've loaded larger in Adobe Photoshop and it doesn't crash.
Pete
"Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in message
news:OC**************@TK2MSFTNGP14.phx.gbl...

"Pete Davis" <pdavis68@[nospam]hotmail.com> wrote in message
news:06********************@giganews.com...
I'm having trouble dealing with bitmaps larger than about 10,000 pixels
in either direction.

I've tried using DrawImage and DrawImageUnscaled, but both give me out
of memory errors.

In my case, I'm simply trying to draw a portion of the bitmap. The
portion is slightly under the 1600x1200 size of my screen.

When trying to do it, I get an Out of Memory exception.

Searching Google returned this issue as common with large, but what I
haven't been able to find is a workaround.

Anyone have any ideas? Am I going to have to write unamanaged code to do
this?

Pete


Any idea how large your bitmap of 10000 * 10000 is in Mb?
The fact that you only draw a portion of it doesn't matter, the whole
bitmap file has to be mapped in your Virtual Address space.

Willy.


Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.