C#/.NET: Separation of multipage tiff with compression "CCITT T.6" very slow

Posted by Alex B on Stack Overflow See other posts from Stack Overflow or by Alex B
Published on 2010-05-08T21:01:06Z Indexed on 2010/05/08 21:08 UTC
Read the original article Hit count: 318

Filed under:
|
|

I need to separate multiframe tiff files, and use the following method:

    public static Image[] GetFrames(Image sourceImage)
    {
        Guid objGuid = sourceImage.FrameDimensionsList[0];
        FrameDimension objDimension = new FrameDimension(objGuid);
        int frameCount = sourceImage.GetFrameCount(objDimension);
        Image[] images = new Image[frameCount];
        for (int i = 0; i < frameCount; i++)
        {
            MemoryStream ms = new MemoryStream();
            sourceImage.SelectActiveFrame(objDimension, i);
            sourceImage.Save(ms, ImageFormat.Tiff);
            images[i] = Image.FromStream(ms);
        }
        return images;
    }

It works fine, butt if the source was encoded using the CCITT T.6 compression, separating a 20-frame-file takes up to 15 seconds on my 2,5ghz CPU.

Saving the images afterwards to a single file using standard compression (LZW), the separation time is under 1 second.

Is there a way to speed up the process?

© Stack Overflow or respective owner

Related posts about c#

Related posts about tiff