HighTechTalks DotNet Forums  

Re: How to save a multi TIFF?

Dotnet Framework (Drawing) microsoft.public.dotnet.framework.drawing


Discuss Re: How to save a multi TIFF? in the Dotnet Framework (Drawing) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Bob Powell [MVP]
 
Posts: n/a

Default Re: How to save a multi TIFF? - 12-14-2007 , 03:14 PM






The article on multi-frame TIFF files on my site is fairly comprehensive.

--
--
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.


"Heinz" <hzi (AT) itinionsoft (DOT) de> wrote

Quote:
Hi,

I want to save a multi TIFF. In my test I have found out that the method
Image.Save() cannot save a multi TIFF:

Image image = Image.FromFile( "Zahlen_1-20.tif" );
image.Save( "MultiTIFF.tif" );
image.Dispose();

So I create now a new Image, add each frame of the multi TIFF and save the
new image. This works fine, but the size of the new multi TIFF is now
about
450 KB instead of 65 KB.

Image image = Image.FromFile( "Zahlen_1-20.tif" );
int frameCount = image.GetFrameCount( FrameDimension.Page );
for ( int frameIndex = 0; frameIndex < frameCount; frameIndex++ )
{
byte[] frame = GetFrame( image, frameIndex );

// How must I add here the frame to a new multi TIFF Image, so the size
of the new image is about 65 KB ?
// The compression should be LZW.
}

public byte[] GetFrame( Image image, int frameIndex )
{
using ( MemoryStream stream = new MemoryStream() )
{
image.SelectActiveFrame( FrameDimension.Page, frameIndex );
image.Save( stream, ImageFormat.Tiff );
return stream.ToArray();
}
}


How can I save the multi TIFF so it has the same size as the original?


Thanks,
Heinz




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.