|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
OutOfMemory exception loading ZIP or JPEG compressed TIFs from fileleaks 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(Object 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 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. 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 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.
Why have a DBNull?
vb.net windows deployment Datagrid cell change event? Where to find event. Inheritance Question in VB.NET Please: Sign the Petition in order to Save VB6 code... CSV Separator Outlook.Application is not defined. PIA installed and setup correctly. RowFilter and DataColumn Named as Number Error in implementing interface Property I'd like to get an event each time the cursor stops moving. |
|||||||||||||||||||||||