473,486 Members | 2,340 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 10118

"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
1909
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
3074
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
3284
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
2049
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
2589
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
2423
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
2104
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
12848
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
8712
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
7099
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6964
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6842
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7319
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3069
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1378
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
262
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.