BRISC::Core::UnsafeBitmap Class Reference

Provides fast access to bitmap data via unsafe code. More...

List of all members.

Public Member Functions

 UnsafeBitmap (Bitmap bitmap)
 Creates a new UnsafeBitmap object based on an existing Bitmap.
 UnsafeBitmap (int width, int height)
 Create a new, blank UnsafeBitmap object with a given size.
 UnsafeBitmap (Bitmap bitmap, int width, int height)
 Create a new UnsafeBitmap object based on an existing Bitmap, but scaled to a new width and height (NOTE: currently only scales when both new dimensions are greater than the original size).
void Dispose ()
 Dispose of the Bitmap object.
void LockBitmap ()
 Prepares the bitmap for unsafe operations. Call this before using GetPixel() or SetPixel().
PixelData GetPixel (int x, int y)
 Get color data for a given pixel.
void SetPixel (int x, int y, PixelData colour)
 Set color data for a given pixel.
void UnlockBitmap ()
 Releases the bitmap data after unsafe operations. Call this after using GetPixel() or SetPixel().

Properties

Bitmap Bitmap [get]
 Returns a reference to the actual Bitmap object.
Point PixelSize [get]
 Returns the image size in pixels.

Private Member Functions

PixelDataPixelAt (int x, int y)
 Obtain a reference to a particular pixel.

Private Attributes

Bitmap bitmap
 Main bitmap object.
int width
 Number of bytes in a row.
BitmapData bitmapData = null
 Stores locked pixel data.
Byte * pBase = null
 Pointer to first pixel.

Classes

struct  PixelData
 Stores 8-bit color RGB component data (24 bpp). More...


Detailed Description

Provides fast access to bitmap data via unsafe code.

This class wraps the Bitmap class and provides additional functionality, in the form of GetPixel() and SetPixel() methods that work much faster than the ordinary ones, thanks to pointers and unsafe code. To use these functions, you must first lock the bitmap (make sure you unlock it when you're done). Use the PixelData class to represent colors.

        UnsafeBitmap uBmp = new UnsafeBitmap(Image.FromFile("image.png"));
        UnsafeBitmap.PixelData pData;
        uBmp.LockBitmap();
        pData.red = pData.blue = pData.green = 255;
        uBmp.SetPixel(0, 0, pData);
        uBmp.UnlockBitmap();
        picbox.Image = uBmp.Bitmap;


Constructor & Destructor Documentation

BRISC::Core::UnsafeBitmap::UnsafeBitmap ( Bitmap  bitmap  )  [inline]

Creates a new UnsafeBitmap object based on an existing Bitmap.

Parameters:
bitmap Bitmap object to use

BRISC::Core::UnsafeBitmap::UnsafeBitmap ( int  width,
int  height 
) [inline]

Create a new, blank UnsafeBitmap object with a given size.

Parameters:
width Width (in pixels) of new bitmap
height Height (in pixels) of new bitmap

BRISC::Core::UnsafeBitmap::UnsafeBitmap ( Bitmap  bitmap,
int  width,
int  height 
) [inline]

Create a new UnsafeBitmap object based on an existing Bitmap, but scaled to a new width and height (NOTE: currently only scales when both new dimensions are greater than the original size).

Parameters:
bitmap Bitmap object to use
width Width (in pixels) of new bitmap
height Height (in pixels) of new bitmap


Member Function Documentation

PixelData BRISC::Core::UnsafeBitmap::GetPixel ( int  x,
int  y 
) [inline]

Get color data for a given pixel.

Parameters:
x Column of pixel (zero-based)
y Row of pixel (zero-based)
Returns:
PixelData color structure

PixelData* BRISC::Core::UnsafeBitmap::PixelAt ( int  x,
int  y 
) [inline, private]

Obtain a reference to a particular pixel.

Parameters:
x Column of pixel (zero-based)
y Row of pixel (zero-based)
Returns:
Pointer to PixelData color structure

void BRISC::Core::UnsafeBitmap::SetPixel ( int  x,
int  y,
PixelData  colour 
) [inline]

Set color data for a given pixel.

Parameters:
x Column of pixel (zero-based)
y Row of pixel (zero-based)
colour PixelData color structure


The documentation for this class was generated from the following file:
Generated on Wed Aug 16 17:13:32 2006 by  doxygen 1.4.7