ERY.AgateLib.PixelBuffer Class Reference

Class which encapsulates raw pixel data. This can be used to construct or modify surface data programmatically. More...

List of all members.

Public Member Functions

 PixelBuffer (PixelFormat format, Size size)
 Constructs a PixelBuffer object.
 PixelBuffer (PixelFormat format, Size size, byte[] data)
 Constructs a PixelBuffer object. Data passed is not copied; it is referenced.
 PixelBuffer (PixelFormat format, Size size, byte[] data, PixelFormat dataFormat)
 Constructs a PixelBuffer object. This overload performs automatic conversion of the data passed to match the format specified for the pixel buffer. The data is always copied in memory, even if it is of the same type as the format parameter.
 PixelBuffer (PixelFormat format, Size size, byte[] data, bool copyData)
 Constructs a PixelBuffer object. This overload allows you to specify whether or not the data parameter should be copied.
 PixelBuffer (PixelFormat format, Size size, IntPtr data, PixelFormat sourceFormat, int srcRowStride)
 Constructs a PixelBuffer object. Copies data from an unmanaged memory location in the specified format.
bool IsBlank ()
 Checks to see if this PixelBuffer contains only transparent pixels. Pixels with an alpha value of less than Display.AlphaThreshold are considered transparent.
bool IsBlank (double alphaTolerance)
 Checks to see if this PixelBuffer contains only transparent pixels. This overload allows the alpha tolerance to be specified explicitly.
bool IsRowBlank (int row)
 Checks to see if the selected row of this PixelBuffer contains only transparent pixels. Pixels with an alpha value of less than Display.AlphaThreshold are considered transparent.
bool IsRowBlank (int row, double alphaTolerance)
 Checks to see if the selected row of this PixelBuffer contains only transparent pixels. This overload allows the alpha tolerance to be specified explicitly.
bool IsColumnBlank (int col)
 Checks to see if the selected row of this PixelBuffer contains only transparent pixels. Pixels with an alpha value of less than Display.AlphaThreshold are considered transparent.
bool IsColumnBlank (int col, double alphaTolerance)
 Checks to see if the selected row of this PixelBuffer contains only transparent pixels. This overload allows the alpha tolerance to be specified explicitly.
void CopyFrom (PixelBuffer buffer, Rectangle srcRect, Point destPt, bool clip)
 Copies pixel data from the specified PixelBuffer.
int GetPixelIndex (int x, int y)
 Gets the index of the first byte in the pixel in the Data array at the specified point.
bool IsPointValid (int x, int y)
 Returns true if the specified point is within the pixel buffer.
bool IsPointValid (Point pt)
 Returns true if the specified point is within the pixel buffer.
Color GetPixel (int x, int y)
 Copies pixel data from the specified location to a Color structure.
void SetPixel (int x, int y, Color clr)
 Sets the color at a particular pixel.
void SetData (byte[] data, PixelFormat srcFormat)
 Copies the data from the array passed in into the internal pixel buffer array. Automatic conversion is performed if the format the data is in (indicated by format parameter) differs from the format the pixel buffer is in.
void SetData (IntPtr data, PixelFormat srcFormat, int srcRowStride)
 Copies the data from the unmanaged memory pointer passed in into the internal pixel buffer array. Automatic conversion is performed if the format the data is in (indicated by format parameter) differs from the format the pixel buffer is in.
PixelBuffer ConvertTo (PixelFormat pixelFormat)
 Creates a new PixelBuffer and copies the data in this PixelBuffer, performing automatic conversion.
PixelBuffer ConvertTo (PixelFormat pixelFormat, Size mTextureSize)
 Creates a new PixelBuffer of the specified size, with the data in this PixelBuffer copied to the upper left corner.
PixelBuffer ConvertTo (PixelFormat pixelFormat, Size mTextureSize, Point point)
 Creates a new PixelBuffer of the specified size, with the data in this PixelBuffer copied so that the upper left corner is specified by point.
void SaveTo (string filename, ImageFileFormat format)
 Saves the data in the PixelBuffer for to an image file.

Static Public Member Functions

static void ConvertPixel (byte[] dest, int destIndex, PixelFormat destFormat, byte[] src, int srcIndex, PixelFormat srcFormat)
 Converts a single pixel in the specified format at the specified location from the source array and writes it to the specified location in the destination array.
static int GetPixelStride (PixelFormat format)
 Returns the number of bytes in memory used by a single pixel in the specified format.
static bool FormatHasAlpha (PixelFormat format)
 Returns true if the specified PixelFormat contains an alpha channel.

Properties

PixelFormat PixelFormat [get]
 Gets the format of the pixel data.
byte[] Data [get, set]
 Gets or sets the raw pixel data, in the format indicated by PixelFormat. An exception is thrown when setting Data if the length of the array passed is not Width * Height * PixelStride. The data is not copied, it is only referenced.
int PixelStride [get]
 Gets how many bytes each pixel takes up in memory.
int Height [get]
 Returns the height in pixels of the buffer.
int Width [get]
 Returns the width in pixels of the buffer.
Size Size [get]
 Returns the size (width, height) in pixels of the buffer.
int RowStride [get]
 Returns how many bytes a single row takes up. This value can be used to increase an index to go from one line of pixels to the next.


Detailed Description

Class which encapsulates raw pixel data. This can be used to construct or modify surface data programmatically.


Constructor & Destructor Documentation

ERY.AgateLib.PixelBuffer.PixelBuffer ( PixelFormat  format,
Size  size 
)

Constructs a PixelBuffer object.

Parameters:
size The size of the image data in pixels.
format The raw data format of the pixels to be contained in the pixel buffer. PixelFormat.Any is not a valid parameter.

ERY.AgateLib.PixelBuffer.PixelBuffer ( PixelFormat  format,
Size  size,
byte[]  data 
)

Constructs a PixelBuffer object. Data passed is not copied; it is referenced.

Parameters:
size The size of the image data in pixels.
format The raw data format of the pixels to be contained in the pixel buffer. PixelFormat.Any is not a valid parameter.
data Raw pixel data. It must be the correct size for the format passed. This data will not be copied; it will be referenced.

ERY.AgateLib.PixelBuffer.PixelBuffer ( PixelFormat  format,
Size  size,
byte[]  data,
PixelFormat  dataFormat 
)

Constructs a PixelBuffer object. This overload performs automatic conversion of the data passed to match the format specified for the pixel buffer. The data is always copied in memory, even if it is of the same type as the format parameter.

Parameters:
size The size of the image data in pixels.
format The raw data format of the pixels to be contained in the pixel buffer. PixelFormat.Any is not a valid parameter.
data Raw pixel data. It must be the correct size for the format passed.
dataFormat Format of the raw pixel data. This data will be copied into the PixelBuffer.

ERY.AgateLib.PixelBuffer.PixelBuffer ( PixelFormat  format,
Size  size,
byte[]  data,
bool  copyData 
)

Constructs a PixelBuffer object. This overload allows you to specify whether or not the data parameter should be copied.

Parameters:
size The size of the image data in pixels.
format The raw data format of the pixels to be contained in the pixel buffer. PixelFormat.Any is not a valid parameter.
data Raw pixel data. It must be the correct size for the format passed.
copyData True if the data should be copied into the pixel buffer.

ERY.AgateLib.PixelBuffer.PixelBuffer ( PixelFormat  format,
Size  size,
IntPtr  data,
PixelFormat  sourceFormat,
int  srcRowStride 
)

Constructs a PixelBuffer object. Copies data from an unmanaged memory location in the specified format.

Parameters:
format The format the pixel buffer should be stored in.
size The size (width and height) in pixels the pixel buffer should contain.
data Pointer to an unmanaged memory location which contains the pixel data. This data must be the same size in pixels as the size parameter.
sourceFormat The pixelformat of the source data.
srcRowStride The number of bytes from the beginning of one row to the next.


Member Function Documentation

bool ERY.AgateLib.PixelBuffer.IsBlank (  ) 

Checks to see if this PixelBuffer contains only transparent pixels. Pixels with an alpha value of less than Display.AlphaThreshold are considered transparent.

Returns:

bool ERY.AgateLib.PixelBuffer.IsBlank ( double  alphaTolerance  ) 

Checks to see if this PixelBuffer contains only transparent pixels. This overload allows the alpha tolerance to be specified explicitly.

Parameters:
alphaTolerance 
Returns:

bool ERY.AgateLib.PixelBuffer.IsRowBlank ( int  row  ) 

Checks to see if the selected row of this PixelBuffer contains only transparent pixels. Pixels with an alpha value of less than Display.AlphaThreshold are considered transparent.

Parameters:
row 
Returns:

bool ERY.AgateLib.PixelBuffer.IsRowBlank ( int  row,
double  alphaTolerance 
)

Checks to see if the selected row of this PixelBuffer contains only transparent pixels. This overload allows the alpha tolerance to be specified explicitly.

Parameters:
row 
alphaTolerance 
Returns:

bool ERY.AgateLib.PixelBuffer.IsColumnBlank ( int  col  ) 

Checks to see if the selected row of this PixelBuffer contains only transparent pixels. Pixels with an alpha value of less than Display.AlphaThreshold are considered transparent.

Parameters:
col 
Returns:

bool ERY.AgateLib.PixelBuffer.IsColumnBlank ( int  col,
double  alphaTolerance 
)

Checks to see if the selected row of this PixelBuffer contains only transparent pixels. This overload allows the alpha tolerance to be specified explicitly.

Parameters:
col 
alphaTolerance 
Returns:

void ERY.AgateLib.PixelBuffer.CopyFrom ( PixelBuffer  buffer,
Rectangle  srcRect,
Point  destPt,
bool  clip 
)

Copies pixel data from the specified PixelBuffer.

Parameters:
buffer The pixel buffer to copy from.
srcRect 
destPt 
clip If true, the copied region will automatically be clipped. If false, this method will throw an exception if the area being copied to is out of range.

int ERY.AgateLib.PixelBuffer.GetPixelIndex ( int  x,
int  y 
)

Gets the index of the first byte in the pixel in the Data array at the specified point.

Parameters:
x 
y 
Returns:

bool ERY.AgateLib.PixelBuffer.IsPointValid ( int  x,
int  y 
)

Returns true if the specified point is within the pixel buffer.

Parameters:
x 
y 
Returns:

bool ERY.AgateLib.PixelBuffer.IsPointValid ( Point  pt  ) 

Returns true if the specified point is within the pixel buffer.

Parameters:
pt 
Returns:

Color ERY.AgateLib.PixelBuffer.GetPixel ( int  x,
int  y 
)

Copies pixel data from the specified location to a Color structure.

Parameters:
x 
y 
Returns:

void ERY.AgateLib.PixelBuffer.SetPixel ( int  x,
int  y,
Color  clr 
)

Sets the color at a particular pixel.

Parameters:
x 
y 
clr 

void ERY.AgateLib.PixelBuffer.SetData ( byte[]  data,
PixelFormat  srcFormat 
)

Copies the data from the array passed in into the internal pixel buffer array. Automatic conversion is performed if the format the data is in (indicated by format parameter) differs from the format the pixel buffer is in.

Parameters:
data 
srcFormat 

void ERY.AgateLib.PixelBuffer.SetData ( IntPtr  data,
PixelFormat  srcFormat,
int  srcRowStride 
)

Copies the data from the unmanaged memory pointer passed in into the internal pixel buffer array. Automatic conversion is performed if the format the data is in (indicated by format parameter) differs from the format the pixel buffer is in.

Parameters:
data 
srcFormat 
srcRowStride 

PixelBuffer ERY.AgateLib.PixelBuffer.ConvertTo ( PixelFormat  pixelFormat  ) 

Creates a new PixelBuffer and copies the data in this PixelBuffer, performing automatic conversion.

Parameters:
pixelFormat PixelFormat that the newly created PixelBuffer should have.
Returns:

PixelBuffer ERY.AgateLib.PixelBuffer.ConvertTo ( PixelFormat  pixelFormat,
Size  mTextureSize 
)

Creates a new PixelBuffer of the specified size, with the data in this PixelBuffer copied to the upper left corner.

Parameters:
pixelFormat PixelFormat that the newly created PixelBuffer should have.
mTextureSize 
Returns:

PixelBuffer ERY.AgateLib.PixelBuffer.ConvertTo ( PixelFormat  pixelFormat,
Size  mTextureSize,
Point  point 
)

Creates a new PixelBuffer of the specified size, with the data in this PixelBuffer copied so that the upper left corner is specified by point.

Parameters:
pixelFormat PixelFormat that the newly created PixelBuffer should have.
mTextureSize 
point 
Returns:

void ERY.AgateLib.PixelBuffer.SaveTo ( string  filename,
ImageFileFormat  format 
)

Saves the data in the PixelBuffer for to an image file.

Parameters:
filename 
format 

static void ERY.AgateLib.PixelBuffer.ConvertPixel ( byte[]  dest,
int  destIndex,
PixelFormat  destFormat,
byte[]  src,
int  srcIndex,
PixelFormat  srcFormat 
) [static]

Converts a single pixel in the specified format at the specified location from the source array and writes it to the specified location in the destination array.

Parameters:
dest Destination array to write to.
destIndex Index in destination array to begin writing.
destFormat Pixel format to use when writing to destination array.
src Source array to read pixel data from
srcIndex Index in source array where pixel data should be read from.
srcFormat The format of the pixel data in the source array.

static int ERY.AgateLib.PixelBuffer.GetPixelStride ( PixelFormat  format  )  [static]

Returns the number of bytes in memory used by a single pixel in the specified format.

Parameters:
format Which format to look up.
Returns:
The number of bytes used by the format. This is always either 2 for 15 or 16 bit formats, 3 for 24 bit formats, and 4 for 32 bit formats.

static bool ERY.AgateLib.PixelBuffer.FormatHasAlpha ( PixelFormat  format  )  [static]

Returns true if the specified PixelFormat contains an alpha channel.

Parameters:
format 
Returns:


Property Documentation

PixelFormat ERY.AgateLib.PixelBuffer.PixelFormat [get]

Gets the format of the pixel data.

byte [] ERY.AgateLib.PixelBuffer.Data [get, set]

Gets or sets the raw pixel data, in the format indicated by PixelFormat. An exception is thrown when setting Data if the length of the array passed is not Width * Height * PixelStride. The data is not copied, it is only referenced.

int ERY.AgateLib.PixelBuffer.PixelStride [get]

Gets how many bytes each pixel takes up in memory.

int ERY.AgateLib.PixelBuffer.Height [get]

Returns the height in pixels of the buffer.

int ERY.AgateLib.PixelBuffer.Width [get]

Returns the width in pixels of the buffer.

Size ERY.AgateLib.PixelBuffer.Size [get]

Returns the size (width, height) in pixels of the buffer.

int ERY.AgateLib.PixelBuffer.RowStride [get]

Returns how many bytes a single row takes up. This value can be used to increase an index to go from one line of pixels to the next.


The documentation for this class was generated from the following file:
AgateLib
Awesome Game and Tool Engine Library
SourceForge.net Logo