Solved

Working with large images in VB.NET

Posted on 2004-08-20
8
1,261 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 14

Expert Comment

by:ptakja
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now