Solved

Working with large images in VB.NET

Posted on 2004-08-20
8
1,302 Views
Last Modified: 2010-05-18
Hi im working on an application that is supposed to handle large images, now i seem to have some trouble with the bitmap object, seems it can only handle images that are like 10000px,10000px i dont know the exact number but this can be alittle too small sometimes...

but when i open smaller images ( < 10000x10000 but still really large) i get a "Out of memory" exception even tho the taskmanager reports just 170Mb memory used out of one GB of ram....

is it possible to break that limit and load say 3 times that amount of memory in bitmap objects so i can work with the three images at the same time...

well, its actually 4 since i create another graphics object and clone parts of the three input images to the output graphics object...

has anyone experience with working with large image files?

the reason that i need such large images is because they are supposed to be printed later on very large paper with very good quality... like 1Meter height and variable width...

0
Comment
Question by:JohnnyGr
  • 3
  • 3
8 Comments
 
LVL 4

Expert Comment

by:Daniellus83
ID: 11857941
JohnnyGr: Understand that an image (lets say 10x10 pixel) but then twice so big (that makes 20x20) needs about 4 times more memory of uncompressed image data.

What program do you use?
0
 
LVL 2

Author Comment

by:JohnnyGr
ID: 11858254
im using my own program im trying to make...

but still... the application just uses 170 meggs of memory... and i have about 700mb free, plus swap so there should be more than enough memory to work with.. but i still get "Out Of Memory" exceptions....
0
 
LVL 4

Expert Comment

by:Daniellus83
ID: 11859094
Okay... I understand that you use only 170 Mb. But I could be that for you NEXT operation you exceed the maximum mem, the program could predict you would exceed this amount and give you the error (so you would not see any change of mem usage in taskmanager)

My next guess (since nobody else helps you):

Mostly you get strange things like this if you not do clean/close used objects/var. Try to clear the graphics objects if you can... after/before you use it. Also when you close an application. Something like this: graphics_object.clear and resize its pixels down to a minimum.
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
LVL 14

Expert Comment

by:ptakja
ID: 11866662
I have some experience with images in the hundreds of megabyte range using VB.Net.  One thing you will absolutely want to make sure you do is make sure you call the DISPOSE method on ALL graphics objects you create with the New keyword.  This includes Graphics, Brush, Pen objects.   DON'T rely on the objects to be released when they go out of scope.   If that doesn't have too much of an effect, try putting a call to GC.Collect to force the Garbage collector to run which will release any resources that are tagged for disposal.  Dealing with images this large requires very strict programming discipline to make sure you clean up after yourself as soon as you are done with the objects.   Basically, if you create an object with New and you are done with it, if it has a Dispose method...call it!  (Use intellisense (or the object browser) to see if it does).

Jeff

0
 
LVL 2

Author Comment

by:JohnnyGr
ID: 11867644
Well i seem to have things going my way now...
I did as Daniellus83 and ptakja suggested and made sure i cleaned up everything ive been using... setting objects to disposed didnt work always tho.... but setting them to Nothing did. wich is kindof the same...

But it still seems that the bitmap object only can handle a image thats something like
10000px X 10000px and im trying to work with some really high resolution images for some advertisment, that are supposed to be printed on really big paper...

I dont really know much about the images more than i was asked if i could fix this...

Is there some way i can boost the number of pixels a bitmap object can hold?
0
 
LVL 4

Accepted Solution

by:
Daniellus83 earned 250 total points
ID: 11868680
Dear JohnnyGr; You might waana read this 'interesting' topic:

http://www.experts-exchange.com/Programming/Q_20860371.html

It seems to be like yours.

  "...GDI run out of its allocated kernel memory (the still uncertain X percent of
                       my 512 megabytes of ram) and crash with the said internal windows message..."
0
 
LVL 2

Author Comment

by:JohnnyGr
ID: 12101765
Whops, looks like i forgot all about this, well this problem ended up with the project being abandoned because theres no way you can create larger images than 10000x10000 something, no matter how hard you try, and that caused the out of memory error, wich it throws for all kinds of reasons...... and the images i was supposed to open was alot larger than that...
and with higher resolution...


0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question