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

C# Raster - Convert Image to Bitmap in C#.NET


Online C# Guide for Converting Image to Bitmap in .NET Application




Overview



RasterEdge XImage.Raster provide convert RasterImage object to Bitmap. Because pixel format can not be supported fully by Bitmap, if the source image is 1bpp, the output bitmap will convert to index8bpp.


Related .net document control helps:
asp.net pdf editor: EdgePDF: ASP.NET PDF Editor Web Control: Online view, annotate, redact, edit, process, convert PDF documents
document redact asp.net: Redact document ASP.NET: add, delete, apply redaction on PDF files in web browser using C#.net
asp.net convert pdf: ASP.NET Convert PDF Control: Convert, export PDF to Word, HTML, Tiff files in C# ASP.NET
asp.net dnn pdf editor: ASP.NET DNN PDF Editor Control: view, edit PDF files in Dotnetnuke application
asp.net pdf document viewer: ASP.NET PDF Document Viewer in C#: view, annotate, redact Adobe PDF files online in ASP.NET
asp.net mvc document viewer: ASP.NET MVC Document Viewer: view, annotate, redact files on ASP.NET MVC web projects
asp.net azure document viewer: ASP.NET Azure Document Viewer: view, annotate files online using ASP.NET Cloud Service




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;


  RasterEdge.Imaging.Basic.dll


  RasterEdge.XImage.Raster.Core.dll


  RasterEdge.XImage.Raster.dll


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.




Convert Image to Bitmap



By following steps below, your can convert RasterImage to bitmap.


Sample Code (convert single frame image to bitmap):




RasterImage img = new RasterImage("input.jpeg");
Bitmap outputBitmap = img.ToBitmap();




Sample Code (convert multi-frame image to bitmap):




RasterImage img = new RasterImage("input.tiff");
Bitmap[] outputBitmaps = new Bitmap[img.PageCount];
for (int n = 0; n < img.PageCount; n++)
{
   outputBitmaps[n] = img.ToBitmap(n);
}