Groups | Blog | Home
all groups > dotnet drawing api > august 2006 >

dotnet drawing api : Tif problem?


Chris Ashley
8/31/2006 1:08:40 AM
I need to do some manipulation of Tif images, however I'm encountering
problems with multi-page Tif files.

If there are three or less pages in the Tif, everything seems to work
fine. However once the Tif goes above this I get a
'System.OutOfMemoryException: Out of memory.' - this is strange because
I can load a 10mb three-page Tif fine, but a 1mb four-page Tif won't
load so it can't be memory.

Is there a problem with the .NET support for Tif images?
Bob Powell [MVP]
8/31/2006 8:58:52 PM
There are no particular probblems that I know of.

Perhaps the article on multi-frame TIFF images in the GDI+ FAQ will help you
out.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.



[quoted text, click to view]

aggc
11/2/2006 2:11:03 AM
I had some problems with multi-page tiff files..
..net uses GDI+ to manipulate Images and recently i discover (with help of
others) that GDI+ doesn't support TIFF files with jpeg compression. Maybe 4th
page it's an TIFF file with jpeg compression..
When you invoke System.Drawing... FromFile and GDI+ doesn't support your
format then raises an expection 'System.OutOfMemoryException: Out of memory'

When you use System.Drawing... fromstream raise another exception 'Misses ...'




[quoted text, click to view]
aggc
11/2/2006 2:14:02 AM
More explicit...

Dim objImage As System.Drawing.Image

' FileStream
Dim fs1 As New FileStream("c:\newtest.tif", FileMode.Open, FileAccess.Read)
System.Drawing.Image.FromStream(fs1, True, False)

'Exception -> misses ojpeg tags compression

'MemoryStream
Dim fs1 As New FileStream("c:\test.jpg", FileMode.Open)
Dim r1 As New IO.BinaryReader(fs1)
Dim buffer(fs1.Length) As Byte
r1.Read(buffer, 0, fs1.Length)
r1.Close()
fs1.Close()
Dim ms As New MemoryStream(buffer)
ms.Flush()
objImage = System.Drawing.Image.FromStream(ms)

'Exception -> misses ojpeg tags compression

'FromFile
objImage = System.Drawing.Image.FromFile("c:\newtest.tif")

'Exception -> out of memory

System.Drawing.Bitmap doesn't work either.


[quoted text, click to view]
AddThis Social Bookmark Button