By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,387 Members | 1,729 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,387 IT Pros & Developers. It's quick & easy.

OutOfMemory exception loading ZIP or JPEG compressed TIFs from file

P: n/a
I am using a method that was described as the best for avoiding memory
leaks when using MS Picture boxes. The main idea was to use a variable
to load the image from file and then assign the picture box image to
that variable like so:

Dim img as BitMap ' (have tried BitMap and Image)
img = Image.FromFile(OFD.FileName)
PictureBox1.Image = img

This has worked great with my photo album creator as my memory leaks
disappeared like magic.

I have, however, found another issue that I need to work out or find a
workaround for.

If a TIF image has been saved with ZIP or JPEG compression (we are
using Adobe Photoshop) then I get the following Exception when the
variable is loaded From File.

System.OutOfMemoryException: Out of memory.
at System.Drawing.Image.FromFile(String filename, Boolean
useEmbeddedColorManagement)
at System.Drawing.Image.FromFile(String filename)
at ReadSpecimen.frmReadSpecimen.cmdBrowse_Click(Objec t sender,
EventArgs e)

Does anyone have any ideas how to make this work with these compressed
formats?

If not does anyone have an idea on how I can detect the compression
properties of a TIF so I can warn the user and avoid the error?

Thanks for any help,

Sincerely,

Timothy Frawley

Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi

System.Drawing is built on GDI+. Therefore, it is the underlying GDI+ which
is loading the TIFF. Note that GDI+ frequently returns "out of memory"
errors as a generic indication of error. This might include an unsupported
format, or maybe it really is a memory pressure issue, or it could be
something else entirely.
Here is document about tiff.
We support the baseline TIFF (Part 1 in the document), and much of the
extensions (part 2). But we don't support JPG-compression in TIFF so far.
<http://www.ibr.oeaw.ac.at/beamline/tiff_doc_6_0.pdf>

For your scenario, I think we can use try..catch block to handle the
exception to avoid getting the exception when we are openning some
unsupported image format.
If you still have any concern, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #2

P: n/a
Thank you Peter,

As usual your posts are informative and very helpful.

I have already placed a try... catch block around the loading of the
image with an informative message box to the extent that the error may
have been caused by an unsupported image format with appropriate
instructions to the user on how to resolve the issue. This will have
to do.

Thank you again, I appreciate your help very much!

Sincerely,

Tim Frawley

Nov 21 '05 #3

P: n/a
Hi

I am glad my suggestion helps you.
Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.