C# Class AForge.Imaging.Image

Core image relatad methods.
All methods of this class are static and represent general routines used by different image processing classes.
Datei anzeigen Open project: noxryan/Claro-Shader Class Usage Examples

Public Methods

Method Description
Clone ( Bitmap source ) : Bitmap

Clone image.

The original Bitmap.Clone() does not produce the desired result - it does not create an actual clone (it does not create a copy of the image). That is why this method was implemented to provide the functionality.

Clone ( Bitmap source, PixelFormat format ) : Bitmap

Clone image.

The original Bitmap.Clone() does not produce the desired result - it does not create a clone with specified pixel format. More of it, the original method does not create an actual clone - it does not create a copy of the image. That is why this method was implemented to provide the functionality.

Clone ( BitmapData sourceData ) : Bitmap

Clone image.

Convert16bppTo8bpp ( Bitmap bimap ) : Bitmap

Convert bitmap with 16 bits per plane to a bitmap with 8 bits per plane.

The routine does the next pixel format conversions: Format16bppGrayScale to Format8bppIndexed with grayscale palette; Format48bppRgb to Format24bppRgb; Format64bppArgb to Format32bppArgb; Format64bppPArgb to Format32bppPArgb.

Convert8bppTo16bpp ( Bitmap bimap ) : Bitmap

Convert bitmap with 8 bits per plane to a bitmap with 16 bits per plane.

The routine does the next pixel format conversions: Format8bppIndexed (grayscale palette assumed) to Format16bppGrayScale; Format24bppRgb to Format48bppRgb; Format32bppArgb to Format64bppArgb; Format32bppPArgb to Format64bppPArgb.

CreateGrayscaleImage ( int width, int height ) : Bitmap

Create and initialize new 8 bpp grayscale image.

The method creates new 8 bpp grayscale image and initializes its palette. Grayscale image is represented as Format8bppIndexed image with palette initialized to 256 gradients of gray color.

FromFile ( string fileName ) : Bitmap

Load bitmap from file.

The method is provided as an alternative of System.Drawing.Image.FromFile(string) method to solve the issues of locked file. The standard .NET's method locks the source file until image's object is disposed, so the file can not be deleted or overwritten. This method workarounds the issue and does not lock the source file.

Sample usage:

Bitmap image = AForge.Imaging.Image.FromFile( "test.jpg" );
IsGrayscale ( Bitmap image ) : bool

Check if specified 8 bpp image is grayscale.

The methods checks if the image is a grayscale image of 256 gradients. The method first examines if the image's pixel format is Format8bppIndexed and then it examines its palette to check if the image is grayscale or not.

SetGrayscalePalette ( Bitmap image ) : void

Set pallete of the 8 bpp indexed image to grayscale.

The method initializes palette of Format8bppIndexed image with 256 gradients of gray color.

Private Methods

Method Description
FormatImage ( Bitmap &image ) : void

Method Details

Clone() public static method

Clone image.
The original Bitmap.Clone() does not produce the desired result - it does not create an actual clone (it does not create a copy of the image). That is why this method was implemented to provide the functionality.
public static Clone ( Bitmap source ) : Bitmap
source System.Drawing.Bitmap Source image.
return System.Drawing.Bitmap

Clone() public static method

Clone image.
The original Bitmap.Clone() does not produce the desired result - it does not create a clone with specified pixel format. More of it, the original method does not create an actual clone - it does not create a copy of the image. That is why this method was implemented to provide the functionality.
public static Clone ( Bitmap source, PixelFormat format ) : Bitmap
source System.Drawing.Bitmap Source image.
format PixelFormat Pixel format of result image.
return System.Drawing.Bitmap

Clone() public static method

Clone image.
public static Clone ( BitmapData sourceData ) : Bitmap
sourceData System.Drawing.Imaging.BitmapData Source image data.
return System.Drawing.Bitmap

Convert16bppTo8bpp() public static method

Convert bitmap with 16 bits per plane to a bitmap with 8 bits per plane.

The routine does the next pixel format conversions: Format16bppGrayScale to Format8bppIndexed with grayscale palette; Format48bppRgb to Format24bppRgb; Format64bppArgb to Format32bppArgb; Format64bppPArgb to Format32bppPArgb.

Invalid pixel format of the source image.
public static Convert16bppTo8bpp ( Bitmap bimap ) : Bitmap
bimap System.Drawing.Bitmap Source image to convert.
return System.Drawing.Bitmap

Convert8bppTo16bpp() public static method

Convert bitmap with 8 bits per plane to a bitmap with 16 bits per plane.

The routine does the next pixel format conversions: Format8bppIndexed (grayscale palette assumed) to Format16bppGrayScale; Format24bppRgb to Format48bppRgb; Format32bppArgb to Format64bppArgb; Format32bppPArgb to Format64bppPArgb.

Invalid pixel format of the source image.
public static Convert8bppTo16bpp ( Bitmap bimap ) : Bitmap
bimap System.Drawing.Bitmap Source image to convert.
return System.Drawing.Bitmap

CreateGrayscaleImage() public static method

Create and initialize new 8 bpp grayscale image.
The method creates new 8 bpp grayscale image and initializes its palette. Grayscale image is represented as Format8bppIndexed image with palette initialized to 256 gradients of gray color.
public static CreateGrayscaleImage ( int width, int height ) : Bitmap
width int Image width.
height int Image height.
return System.Drawing.Bitmap

FromFile() public static method

Load bitmap from file.

The method is provided as an alternative of System.Drawing.Image.FromFile(string) method to solve the issues of locked file. The standard .NET's method locks the source file until image's object is disposed, so the file can not be deleted or overwritten. This method workarounds the issue and does not lock the source file.

Sample usage:

Bitmap image = AForge.Imaging.Image.FromFile( "test.jpg" );
public static FromFile ( string fileName ) : Bitmap
fileName string File name to load bitmap from.
return System.Drawing.Bitmap

IsGrayscale() public static method

Check if specified 8 bpp image is grayscale.
The methods checks if the image is a grayscale image of 256 gradients. The method first examines if the image's pixel format is Format8bppIndexed and then it examines its palette to check if the image is grayscale or not.
public static IsGrayscale ( Bitmap image ) : bool
image System.Drawing.Bitmap Image to check.
return bool

SetGrayscalePalette() public static method

Set pallete of the 8 bpp indexed image to grayscale.
The method initializes palette of Format8bppIndexed image with 256 gradients of gray color.
Provided image is not 8 bpp indexed image.
public static SetGrayscalePalette ( Bitmap image ) : void
image System.Drawing.Bitmap Image to initialize.
return void