Beispiel #1
0
bool Blotter::cut_into_list(BITMAP* shapebit)
{
    for  (int y = 0; y < shapebit->h; ++y)
     for (int x = 0; x < shapebit->w; ++x) {
        if (getpixel(shapebit, x, y) != pink) {
            Area area(shapebit);
            find_connected_area(area, x, y);

            BITMAP* piece = create_bitmap(area.x_max - area.x_min + 1,
                                          area.y_max - area.y_min + 1);
            if (!piece || piece->w <= 0 || piece->h <= 0) {
                if (piece) destroy_bitmap(piece);
                return false;
            }
            clear_to_color(piece, pink);
            for (std::set <Xy> ::const_iterator
             itr = area.Xy.begin(); itr != area.Xy.end(); ++itr) {
                _putpixel32(piece,
                    itr->first - area.x_min, itr->second - area.y_min,
                    _getpixel32(area.ground, itr->first, itr->second));
            }
            shapes.push_back(piece);
            fill_area_with_color(area, pink);
        }
    }
    return true;
}
void Bitmap::PutPixel(int x, int y, color_t color)
{
    if (x < 0 || x >= _alBitmap->w || y < 0 || y >= _alBitmap->h)
    {
        return;
    }

	switch (bitmap_color_depth(_alBitmap))
	{
	case 8:
		return _putpixel(_alBitmap, x, y, color);
	case 15:
		return _putpixel15(_alBitmap, x, y, color);
	case 16:
		return _putpixel16(_alBitmap, x, y, color);
	case 24:
		return _putpixel24(_alBitmap, x, y, color);
	case 32:
		return _putpixel32(_alBitmap, x, y, color);
	}
    assert(0); // this should not normally happen
	return putpixel(_alBitmap, x, y, color);
}