How to C#: Imaging
Using Imaging SDK for C#.NET
Winforms Controls
Image Load
Image Access and Modify
Image Bit Depth
Image Bit Depth
Home ›› XImage.Raster ›› C# Raster: Modify Image Bit Depth

How to C#: Modify Image Bit Depth

Overview for How to Modify Image Bit Depth

Related .net document control helps: excel document viewer: ASP.NET Excel Document Viewer in C# Control: view office excel files online in ASP.NET web applications azure document viewer: ASP.NET Azure Document Viewer: view, annotate files online using ASP.NET Cloud Service pdf file permission: ASP.NET PDF File Permission Control: apply, remove PDF file permission settings in C# dnn pdf editor: ASP.NET DNN PDF Editor Control: view, edit PDF files in Dotnetnuke application mvc document viewer: ASP.NET MVC Document Viewer: view, annotate, redact files on ASP.NET MVC web projects sharepoint document viewer: ASP.NET SharePoint Document Viewer: view, annotate, redact documents in SharePoint
view document View multiple document formats in ASP.NET, MVC, Ajax, Azure using C# control

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.

In order to acheive the work, please refer to the following steps.

Install XImage.Raster in C# Project

Add necessary references to your C#.NET project. Right-click the project and select "Add Reference..." to locate and add the following DLLs as project references;




Use corresponding namespaces;

  using RasterEdge.XImage.Raster;

Note: When you get the error "Could not load file or assembly 'RasterEdge.Imaging.Basic' or any other assembly or one of its dependencies. An attempt to load a program with an incorrect format", please check your configure as follows:


       If you are using x64 libraries/dlls, Right click the project -> Properties -> Build -> Platform target: x64.


       If using x86, the platform target should be x86.


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).

Modify Image Bit Depth

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);