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 | |
| PixelData * | PixelAt (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... | |
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;
| BRISC::Core::UnsafeBitmap::UnsafeBitmap | ( | Bitmap | bitmap | ) | [inline] |
Creates a new UnsafeBitmap object based on an existing Bitmap.
| bitmap | Bitmap object to use |
| BRISC::Core::UnsafeBitmap::UnsafeBitmap | ( | int | width, | |
| int | height | |||
| ) | [inline] |
Create a new, blank UnsafeBitmap object with a given size.
| 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).
| bitmap | Bitmap object to use | |
| width | Width (in pixels) of new bitmap | |
| height | Height (in pixels) of new bitmap |
| PixelData BRISC::Core::UnsafeBitmap::GetPixel | ( | int | x, | |
| int | y | |||
| ) | [inline] |
Get color data for a given pixel.
| x | Column of pixel (zero-based) | |
| y | Row of pixel (zero-based) |
| PixelData* BRISC::Core::UnsafeBitmap::PixelAt | ( | int | x, | |
| int | y | |||
| ) | [inline, private] |
Obtain a reference to a particular pixel.
| x | Column of pixel (zero-based) | |
| y | Row of pixel (zero-based) |
| void BRISC::Core::UnsafeBitmap::SetPixel | ( | int | x, | |
| int | y, | |||
| PixelData | colour | |||
| ) | [inline] |
Set color data for a given pixel.
| x | Column of pixel (zero-based) | |
| y | Row of pixel (zero-based) | |
| colour | PixelData color structure |
1.4.7