473,323 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Drawing large bitmaps

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
3 10077

"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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: David | last post by:
Hi all: I am processing a 3D bitmaps(essentially ~1024 2D bitmaps with a size of 1MB each). If I want read large amount of radom data from this series, how could I buffer the file to get...
4
by: Christina Androne | last post by:
Hi I want to allow the user to drow some locators on an image and connect the locators with lines. So I tried to put the following code in the onmousedown enevt of the picture: Graphics...
13
by: Metallicraft | last post by:
I have a vb6 application. On the main form is a picture box with one or two images and several pieces of text displayed in it. These are created on the fly using gdi32 routines that are all in a...
2
by: Mike | last post by:
Hello everybody. I am drawing a country map that consists of 149 municipality bitmaps, each around 25 Kb. I draw it onto the in-memory bitmap, then draw it on the picture box. I use C++, but...
3
by: Chris Saunders | last post by:
I am fairly new to .Net and C# but am familiar with the Win32 API. I wish to set the pixels of the client area of a window one at a time with a specific color. I have so far discovered that...
3
by: pradnyapatil29 | last post by:
I am trying to draw a chart similar to GANTT chart in asp.net. Right now, I am drawing the rectangles on bitmap...but I dont want to use bitmap . Coz loading bitmap takes time...Is there...
14
by: marko | last post by:
Hi everyone, I'm an artist and I'm looking for a way to draw a line that will zig-zag its way thru an image randomly, crisscrossing itself many times, based on random numbers. To give you an...
5
by: Macias | last post by:
Hi, Please help me, how I can make a line drawing on PictureBox similar to MS paint. I thinking about this: click and hold button, move mouse and relase button. I'm trying useing this...
2
by: Nathan Sokalski | last post by:
I am attempting to create icons for controls I have created using VB.NET by using the System.Drawing.ToolboxBitmap attribute. I have managed to do this in C# by specifying the path to the *.ico...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.