I've inherited some code that takes in a TIFF file and saves it, also in TIFF format, but with compression. The code uses classes from the System.Drawing.Imaging
namespace (as opposed to say System.Windows.Media
).
I understand obtaining a compressing encoder, setting up the encoder parameters, etc. But I'm puzzled by the fragment below. The original image is saved to a MemoryStream
in BMP format, then the output TIFF is generated from the BMP format image:
using (var memStream = new MemoryStream())
{
image.Save(memStream, ImageFormat.Bmp);
memStream.Seek(0L, SeekOrigin.Begin);
using (var bmpImage = Image.FromStream(memStream))
{
bmpImage.Save(outputFile, tiffEncoder, encoderParams);
}
}
What would be a reason for generating the intermediate BMP-format image and using that as the basis for the output TIFF?
Update: the images in question are line art -- i.e. black & white -- and the compression being used is "CC4" (CCITT Group 4).
I suppose it's possible that CC4 compression is more efficient if the input is in BMP form. But I would think that some efficiency would be lost by the intermediate conversion from TIFF to BMP...