GetPixel
Returns the color value of the specified pixel as an Rgba color. No checking is done wether the pixel actually lies inside the pixel so make sure that you don't try to read a pixel out of the bounds of the bitmap, which would lead to a crash. This function is relatively slow so it's best to not to call this function per each pixel in the Bitmap! If you read only a few dozen of pixels per frame it shouldn't be too slow, though. To read the whole Bitmap, you should first get a copy of it in the memory by calling GetMemoryBitmap instead. Since OpenLayer 2.0, this function reads the color from the texture information in the graphics card. Thus if the Bitmap isn't loaded in the graphics card, this function won't work! Examples Bitmap myBmp( ... );
// Get the color of the pixel x = 7, y = 5 in the bitmap // Rgba color = myBmp.GetPixel( 7, 5 ); // That would lead to a crash if the size of the bitmap would be less than 8x6 // // The safe way would be: // Rgba color; int x = 7, y = 8; if( x >= 0 && x < myBmp.Width() && y >= 0 && y < myBmp.Height() ) { color = myBmp.GetPixel( 7, 5 ); } Other functions of the class Bitmap
Questions about GetPixel? Click here. |