When I do a
b.Save(outputFilename, ImageFormat.Bmp);
where b is a 16-bit bitmap it is saved with bitfields compression. How can I make C# save without using any compression?
This is what I did with the links that @Ben Voigt posted:
ImageCodecInfo myImageCodecInfo;
Encoder myEncoder ;
EncoderParameter myEncoderParameter;
EncoderParameters myEncoderParameters;
myEncoder = Encoder.Compression;
myImageCodecInfo = GetEncoderInfo("image/bmp");
myEncoderParameters = new EncoderParameters(1);
myEncoderParameter = new EncoderParameter(myEncoder,
(long)EncoderValue.CompressionNone);
myEncoderParameters.Param[0] = myEncoderParameter;
b.Save(outputFilename, myImageCodecInfo, myEncoderParameters );
When I pass an 8-bit bitmap no compression is used. But when I pass a 16-bit RGB bitmap it still uses bitfields compression.
Bitmap in windows means DIB.
“A device-independent bitmap (DIB) is a format used to define device-independent bitmaps in various color resolutions. The main purpose of DIBs is to allow bitmaps to be moved from one device to another (hence, the device-independent part of the name). A DIB is an external format, in contrast to a device-dependent bitmap, which appears in the system as a bitmap object (created by an application…). A DIB is normally transported in metafiles (usually using the StretchDIBits() function), BMP files, and the Clipboard (CF_DIB data format).”
And as we have discussed already in comments ,BITFIELDS compression is only used in 16 and 32 bit DIBs, and simply describes how the data is packed. In the case of a 16-bit DIB it can define the resolution of the green channel (i.e. 5:6:5 or 5:5:5), where as for 32-bit DIBs it defines whether the data is stored in RGB or BGR order (and, when using a BMIHv4/5 header, whether the alpha channel is used.)
There is only one reason to it. It is to keep the BMP to be device independent which is about the format being independent of the device it may be used in. So it means, its always kept in a DIB format according to Windows ! The format is kept intact by means of the compression.
This should ensure your quality.