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: tiff viewer: ASP.NET Tiff Viewer: view, annotate multipage Tiff images in ASP.NET MVC, WebForms using C# Control mvc pdf editor: ASP.NET MVC PDF Viewer & Editor: view, annotate, redact, edit PDF document in C# ASP.NET MVC document viewer c#: ASP.NET Document Viewer using C#: Open, View, Annotate, Redact, Convert document files in ASP.NET using C#, HTML5, JQuer... dicom document viewer: ASP.NET Dicom Document Viewer Control: view, annotate dicom imaging files online in ASP.NET document viewer: EdgeDoc:ASP.NET Document Viewer C# Control: Open, view, annotate, redact, convert documents online in C#, VB.NET, AS... edit pdf text: ASP.NET PDF Text Edit Control: online edit PDF text content using C# ASP.NET text file viewer: ASP.NET Text file viewer in MVC, WebForms: Open, view, annotate, convert txt files in C# ASP.NET

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. how to create password protected pdf file in c#, pdf text extract, c# ocr pdf to text, how to add image in pdf using c#, how to read pdf file in using c#, convert tiff to pdf c# itextsharp.

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; c# merge pdf byte arrays, get coordinates of text in pdf c#, itext add image to existing pdf c#, how to add footer in pdf using itextsharp in c#, itextsharp replace text in pdf c#, convert pdf to jpg, add watermark to pdf.




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. asp net replace text from pdf javascript, display excel spreadsheet, tiff image viewer, asp net mvc show pdf in div, pdf viewer control c#, mvc pdf editor, pdf preview.


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