Exemple #1
0
int Cutbit::get_pixel(const int fx, const int fy,
                      const int px, const int py) const
{
    // Frame oder Pixel pro Frame nicht existent
    if  (fx < 0 || fy < 0 || fx >= x_frames || fy >= y_frames
     ||  px < 0 || py < 0 || px >= xl       || py >= yl) return -1;
    // Ansonsten liefere Farbe
    else if (x_frames == 1 && y_frames == 1)
         return _getpixel16(bitmap, px, py);
    else return _getpixel16(bitmap, fx * (xl+1) + 1 + px,
                                    fy * (yl+1) + 1 + py);
}
int Bitmap::GetPixel(int x, int y) const
{
    if (x < 0 || x >= _alBitmap->w || y < 0 || y >= _alBitmap->h)
    {
        return -1; // Allegros getpixel() implementation returns -1 in this case
    }

	switch (bitmap_color_depth(_alBitmap))
	{
	case 8:
		return _getpixel(_alBitmap, x, y);
	case 15:
		return _getpixel15(_alBitmap, x, y);
	case 16:
		return _getpixel16(_alBitmap, x, y);
	case 24:
		return _getpixel24(_alBitmap, x, y);
	case 32:
		return _getpixel32(_alBitmap, x, y);
	}
    assert(0); // this should not normally happen
	return getpixel(_alBitmap, x, y);
}