C# Класс AForge.Imaging.Image

Core image relatad methods.
All methods of this class are static and represent general routines used by different image processing classes.
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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.

Приватные методы

Метод Описание
FormatImage ( Bitmap &image ) : void

Описание методов

Clone() публичный статический метод

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.
Результат System.Drawing.Bitmap

Clone() публичный статический метод

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.
Результат System.Drawing.Bitmap

Clone() публичный статический метод

Clone image.
public static Clone ( BitmapData sourceData ) : Bitmap
sourceData System.Drawing.Imaging.BitmapData Source image data.
Результат System.Drawing.Bitmap

Convert16bppTo8bpp() публичный статический метод

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.
Результат System.Drawing.Bitmap

Convert8bppTo16bpp() публичный статический метод

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.
Результат System.Drawing.Bitmap

CreateGrayscaleImage() публичный статический метод

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.
Результат System.Drawing.Bitmap

FromFile() публичный статический метод

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.
Результат System.Drawing.Bitmap

IsGrayscale() публичный статический метод

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.
Результат bool

SetGrayscalePalette() публичный статический метод

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.
Результат void