Guide for C#
Core Document Formats
Additional Features

C# Imaging - View & Convert Bitmap in C#.NET

Visual C# Code for Bitmap Image Conversion, Viewing and Processing

Visual C#
Home > .NET Imaging SDK > C# > Bitmap
If this is your first time to use our DocImageSDK, we strongly suggest you reading How to Start first!

C# Bitmap Image Viewer & Processor Control
RasterEdge C#.NET Bitmap Image Processing Control provides an efficient .NET solution for programmers to view, manipulate and convert bitmap image file using Visual C# programming code. Using this C#.NET bitmap image processing control SDK, developers can easily open bitmap image file from local disks or HTTP server, convert bitmap to other image file formats and save edited bitmap image from C#.NET class application to their computers.
Written in 100% managed C# code and built in .NET Framework 2.0, this C#.NET bitmap imaging library control provides standard options for developers to load, open, create, convert, and save bitmap file format with Visual C#.NET code. Therefore, from this online tutorial page for this C#.NET bitmap viewer and converter SDK, you will find information on following aspects.
  • Load and open bitmap image file using Visual C# .NET
  • Create and save bitmap image file using Visual C# code
  • Convert bitmap image file to, from other document image formats in C#.NET
Bitmap, a standard image file format on Microsoft Windows operating systems and also known as BMP, is often used for storing 2D digital image of arbitrary width, height, and resolution. Different from other raster image file formats, this bitmap file contains rich image information and the image pixels are rarely compressed in this image format. Thus, the bitmap image file always requires a much more storage space.
Besides bitmap (BMP) image format, RasterEdge .NET imaging SDK also supports processing, viewing and converting other document types and image files, including PDF, Word, DICOM and TIFF. What should be noted here is that all those C#.NET document viewer & processor controls are standalone .NET solutions, which can be used to read document image file without using other external document or image editors.
Bitmap Image Viewing & Conversion in C#.NET
This bitmap image viewer and conversion add-on is an easy to use SDK, which can be easily integrated into other C#.NET class applications for better bitmap image editing and processing management. Thus, in this section, we will guide you to install this C#.NET bitmap viewing and processing control into your C#.NET project step by step.
  1. Create a C#.NET class project in Microsoft Visual Studio (2005/2008/2010);
  2. Find and embed following bitmap editor control dlls to your C# project references;
    • RasterEdge.Imaging.Basic.dll
    • RasterEdge.Imaging.Processing.dll
  3. Activate .NET Bitmap Imaging SDK license and copy created "RasterEdgeLicense.txt" to the your C# project bin folder, together with above integrated bitmap editing dlls;
  4. Now you can edit and view bitmap image file in your C#.NET class application.
C#.NET Methods to Process and Convert Bitmap Image
// Method to load and open Bitmap image
public int LoadImageFromGraphicScreen();
public int LoadImageFromGraphicScreen(bool fWorkingArea);
public static REImage OpenImageFile(string filePath);
public static REImage OpenImageFile(string filePath, BaseDecoder dec);

// Method to create and save Bitmap image
public REImage();
public REImage(int w, int h);
public REImage(int w, int h, ImageMode mode);
public REImage(int w, int h, ImageMode mode, byte[] data);
public REImage(int w, int h, ImageMode mode, byte[] data, RColor[] colorPalette);

public static void SaveImageFile(REImage image, string filePath);
public static void SaveImageFile(REImage image, string filePath, BaseEncoder enc);

// Method to convert Bitmap image
public static REImage GetImageFromStream(Stream stream, BaseDecoder dec);
public static byte[] GetByteArrayFromImage(REImage image, BaseEncoder enc);
public static MemoryStream GetStreamFromImage(REImage image, BaseEncoder enc);
public static void ConvertImageFormat(string from, string to);
C# Demo Code to Process and Convert Bitmap Image
In this section, we offer several C# code snippets which can help developers view, process and convert bitmap image in .NET developing platform. If you are a VB.NET programming developer and want to view & convert bitmap image file in VB.NET class application, please go to this VB.NET bitmap image processing tutorial page where you can find a detailed VB.NET programming example.

Load and Open Bitmap Image Using C#.NET Code

Following C# sample code is used to help you view and display source bitmap image file by loading it from hard disks or web server.
using RasterEdge.Imaging.Basic;
using RasterEdge.Imaging.Basic.Core;
using RasterEdge.Imaging.Basic.Codec;

namespace RE__Test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
string fileName = "c:/Sample.bmp";

REImage reImage = REFile.OpenImageFile(fileName);
}
}
}

Create and Save Bitmap Image Using C#.NET Code

If you want to create a standard bmp image file with desired width, height & color mode and save it to your computer in C#.NET class application, please copy the sample C# code below.
using RasterEdge.Imaging.Basic;
using RasterEdge.Imaging.Basic.Core;
using RasterEdge.Imaging.Basic.Codec;

namespace RE__Test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
int width = 100;

int height = 60;

// Create a image with specified width, height and color mode; all pixels are set to white

REImage reImage = new REImage(width, height, ImageMode.RGB888);

REFile.SaveImageFile(reImage, "c:/reimage.bmp", new BMPEncoder());
}
}
}

Perform Bitmap Image Conversion Using C#.NET Code

The C# demo code below can help developers convert bitmap image file to other file formats or convert other file types to bmp image file in .NET class application.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Text;
using System.Windows.Forms;
using RasterEdge.Imaging.Basic.Convert;

namespace RE__Test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
ImageConverter.ConvertImageFormat("c:/Sample.png", "c:/reimage.bmp");

/*
// Convert Stream to Bitmap image
REImage reImage = REFile.GetImageFromStream(stream, new BMPDecoder());
REFile.SaveImageFile(reImage, "c:/reimage.bmp", new BMPEncoder());

// Convert Bitmap image to Stream
string fileName = "c:/Sample.bmp";
REImage reImage = REFile.OpenImageFile(fileName);
MemoryStream ms = REFile.GetStreamFromImage(reImage, new BMPDecoder());
return ms;

// Convert Bitmap image to Byte Array
string fileName = "c:/Sample.bmp";
REImage reImage = REFile.OpenImageFile(fileName);
byte[] bytes = REFile.GetByteArrayFromImage(reImage, new BMPDecoder());
return bytes;
*/
}
}
}
More Tutorials!
You may find more online guides for using RasteEdge .NET Imaging SDK.


Recommend this to Google+