Solved

Working with large images in VB.NET

Posted on 2004-08-20
8
1,350 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

687 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