473,396 Members | 1,970 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Exception while reading multiframe TIFF containing different imageformats

Hi,

I've some trouble reading the containing frames of a multiframe tiff.
First frame is a 1700X2400 px CCITT4, second in JPG 820x1200, third is
a CCITT again ... and so on.

My function extracts the CCITT-frames correct, but the second, fourth,
etc. frames causes a general GDI+ error.

Hope someone can help!

Sascha

Here is my code:

public Image GetFrame(int frameNumber)
{
System.Drawing.Image image=Image.FromFile(_ImageFileName,true);

MemoryStream ms=null;
Image retImage=null;
try
{
ms=new MemoryStream();
Guid objGuid=image.FrameDimensionsList[0];
FrameDimension objDimension=new FrameDimension(objGuid);

image.SelectActiveFrame(objDimension,frameNumber);
image.Save(ms,ImageFormat.Bmp);

retImage=Image.FromStream(ms);

return retImage;
}
catch (Exception ex)
{
if (ms!=null)
{
ms.Close();
}
if (retImage!=null)
{
retImage.Dispose();
}
throw;
}
}

Mar 7 '07 #1
5 4608
Hi,
I've some trouble reading the containing frames of a multiframe tiff.
First frame is a 1700X2400 px CCITT4, second in JPG 820x1200, third is
a CCITT again ... and so on.
While I can't help directly on the issue, I have had similar problems
with GDI+ and multipage tiffs. The main issue being that GDI+ loads the
full image in memory (all the pages) and this can lead to out of of
memory errors on big files (say a hundred of pages)

Personally in my own apps I switched to freeimage
http://freeimage.sourceforge.net/

and all those issues dissapeared.

Might be an idea.
Best regards,
Adrian.
Mar 7 '07 #2
Hi, thanks for your answer,
but I don't think its a memory problem, because only every second
image has this problem.

Sascha

On 7 Mrz., 23:51, "Adrian Gallero" <adrian@[nospam]tmssoftware.com>
wrote:
Hi,
I've some trouble reading the containing frames of a multiframe tiff.
First frame is a 1700X2400 px CCITT4, second in JPG 820x1200, third is
a CCITT again ... and so on.

While I can't help directly on the issue, I have had similar problems
with GDI+ and multipage tiffs. The main issue being that GDI+ loads the
full image in memory (all the pages) and this can lead to out of of
memory errors on big files (say a hundred of pages)

Personally in my own apps I switched to freeimagehttp://freeimage.sourceforge.net/

and all those issues dissapeared.

Might be an idea.
Best regards,
Adrian.

Mar 8 '07 #3
On Mar 7, 8:03 am, sascha.folvi...@gmx.de wrote:
Hi,

I've some trouble reading the containing frames of a multiframe tiff.
First frame is a 1700X2400 px CCITT4, second in JPG 820x1200, third is
a CCITT again ... and so on.

My function extracts the CCITT-frames correct, but the second, fourth,
etc. frames causes a general GDI+ error.

Hope someone can help!

Sascha

Here is my code:

public Image GetFrame(int frameNumber)
{
System.Drawing.Image image=Image.FromFile(_ImageFileName,true);

MemoryStream ms=null;
Image retImage=null;
try
{
ms=new MemoryStream();
Guid objGuid=image.FrameDimensionsList[0];
FrameDimension objDimension=new FrameDimension(objGuid);

image.SelectActiveFrame(objDimension,frameNumber);
image.Save(ms,ImageFormat.Bmp);

retImage=Image.FromStream(ms);

return retImage;
}
catch (Exception ex)
{
if (ms!=null)
{
ms.Close();
}
if (retImage!=null)
{
retImage.Dispose();
}
throw;
}
}
Sascha,

I created a multipage tiff with alternating jpeg pages and in a small
test program used your function to successfully return an Image
object.

Could the problem be the way you're (if you're doing it) creating the
tiffs?

The program I used to create tiffs can be found here:
http://www.bobpowell.net/generating_multipage_tiffs.htm

The program I modified to use your function can be found here:
http://www.bobpowell.net/addframes.htm
Is there a specific line in your function that's throwing the error?
-Jay

Mar 8 '07 #4
On 8 Mrz., 22:25, "Jay Riggs" <jay.s.ri...@gmail.comwrote:
On Mar 7, 8:03 am, sascha.folvi...@gmx.de wrote:
Hi,
I've some trouble reading the containing frames of a multiframe tiff.
First frame is a 1700X2400 px CCITT4, second in JPG 820x1200, third is
a CCITT again ... and so on.
My function extracts the CCITT-frames correct, but the second, fourth,
etc. frames causes a general GDI+ error.
Hope someone can help!
Sascha
Here is my code:
public Image GetFrame(int frameNumber)
{
System.Drawing.Image image=Image.FromFile(_ImageFileName,true);
MemoryStream ms=null;
Image retImage=null;
try
{
ms=new MemoryStream();
Guid objGuid=image.FrameDimensionsList[0];
FrameDimension objDimension=new FrameDimension(objGuid);
image.SelectActiveFrame(objDimension,frameNumber);
image.Save(ms,ImageFormat.Bmp);
retImage=Image.FromStream(ms);
return retImage;
}
catch (Exception ex)
{
if (ms!=null)
{
ms.Close();
}
if (retImage!=null)
{
retImage.Dispose();
}
throw;
}
}

Sascha,

I created a multipage tiff with alternating jpeg pages and in a small
test program used your function to successfully return an Image
object.

Could the problem be the way you're (if you're doing it) creating the
tiffs?

The program I used to create tiffs can be found here:http://www.bobpowell.net/generating_multipage_tiffs.htm

The program I modified to use your function can be found here:http://www.bobpowell.net/addframes.htm

Is there a specific line in your function that's throwing the error?

-Jay
Hi Jay,

the error occurs at
"image.SelectActiveFrame(objDimension,frameNumber) ; ".
The TIFF is not created by myself. I get it and have to work with it.
But now I found out, that the ordinary windows-fax-viewer has the same
problem. On my workstation such images are opened with Microsoft
Office Document Imaging Viewer by default ... so I didnt see the
problem that way.

Sascha

Mar 9 '07 #5
Hi ng,

I've got the answer from Micosoft: GDI+ does not support Jpeg
compression of TIFF files.

So, I have to search for another lib.

Sascha

Mar 19 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mario Fischer | last post by:
Hi! I wrote a small SQL-parser for SELECT-statements for the purpose of easier switching between databases. The parser also works with multiple-table-queries. Until here everything is fine, but...
8
by: Phil Slater | last post by:
I'm trying to process a collection of text files, reading word by word. The program run hangs whenever it encounters a word with an accented letter (like rôle or passé) - ie something that's not a...
0
by: Greg | last post by:
Hello, I'm trying to load a 16bit multiframe TIFF-file in a bitmap, but it doesn't work. Error message: 'System.Runtime.InteropServices.ExternalException' 'A generic error occurred in GDI+' ...
6
by: Anders Würtz | last post by:
i have an assignment to iterate through a collection containing different types of numeric values (float, double, int, byte, short etc.) and to add 1 to all of them. I tried with array and...
8
by: stephane8 | last post by:
I'm able to open and read my .csv file. But when the character "-" is in one of my fields (ex : 18802-002) I get a system.DBNull value ! Even if I edit the file with notepad and put "18802-002" I...
1
by: Lore Leunoeg | last post by:
Hello I want to load a local file into the XmlDocument cache. But when I'm not connected to the internet I get this exeption: "The underlying connection was closed: The remote name could not be...
2
by: joblot1976 | last post by:
How can I read a large xml file containing blob fields? I have an xml file that store information about products including 5 images for each product. I am getting Out of Memory Exception when I try...
15
by: Juha Nieminen | last post by:
I'm sure this is not a new idea, but I have never heard about it before. I'm wondering if this could work: Assume that you have a common base class and a bunch of classes derived from it, and...
1
by: Christopher | last post by:
The observer pattern itself is easy enough. I've implemented it using a Event that contains data for any Event type I forsee my application using. My problem is I don't want one and only one...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.