XImage.Raster
Features
Tech Specs
How-to C#
Pricing

C# Imaging Library
How to C#: Modify Image Bit Depth


Overview for How to Modify Image Bit Depth







Steps to Modify image Bit Depth



  • Load an image with RasterImage object.
  • Create an image processor with ImageProcess object.
  • Call the method QuantizeColor of ImageProcess object to complete the task flopping image.
  • Save the modified image to an image file on the disk.


Modify Image Bit Depth



By using the XImage.Raster SDK, you can modify the image's bit in per pixel by assigning to the processor. The method QuantizeColor can be used to decrease the bit depth of an image with the specified dither method(DitherMethod enumeration) and color space(ColorSpace enumeration).

Sample Code (modify image bit depth):

RasterImage img = new RasterImage(@"F:\input.tif");
ImageProcess process = new ImageProcess(img);
//Decrease the bit depth, decrease the 24 bits per pixel image input.jpg to 8 bits per pixel. 
process.QuantizeColor(8, DitherMethod.FloydSteinbergDitherMethod, ColorSpace.GRAY);
//If the image has multiple frames,>
//only decrease the second pages bit depth
process.QuantizeColor(8, DitherMethod.FloydSteinbergDitherMethod, ColorSpace.GRAY, 1);
img.Save(@"C:\output.tif">)