maverickabhi
maverickabhi

Reputation: 305

image conversion from bitonal tiff to color tiff

How can we convert the bitonal tiff image into color tiff image without losing the quality and of same size in c# .net. Here is the code I have written for converting an jpg image to a bitonal image.

string file = @"D:\Work\image001.jpg";
Bitmap bitmap = (Bitmap)Image.FromFile(file);
MemoryStream byteStream = new MemoryStream();
bitmap.Save(byteStream, ImageFormat.Tiff);
Image tiff = Image.FromStream(byteStream);
ImageCodecInfo encoderInfo = GetEncoderInfo("image/tiff");
EncoderParameters encoderParams = new EncoderParameters(1);
EncoderParameter parameter = new EncoderParameter(System.Drawing.Imaging.Encoder.Compression, (long)EncoderValue.CompressionCCITT4);
encoderParams.Param[0] = parameter;
tiff.Save(@"D:\Work\Tiff\1.tiff", encoderInfo, encoderParams);

Any help would be appreciated Thanks...

Upvotes: 0

Views: 839

Answers (1)

Stalag
Stalag

Reputation: 11

You need to convert it to an RGB bitmap first and then back to a TIFF.

Example here (not mine): http://www.codeproject.com/Articles/15186/Bitonal-TIFF-Image-Converter-for-NET

However, you do realize it will still technically be "bitonal" right? When your image was originally converted to bitonal an algorithm made every pixel either black or white. There's no way to determine what the original RGB value of each pixel was.

Upvotes: 1

Related Questions