RedPixmapSw::~RedPixmapSw()
{
    HDC dc = ((RedPixmap_p*)get_opaque())->pixels_source_p.dc;
    if (dc) {
        HBITMAP prev_bitmap = ((RedPixmap_p*)get_opaque())->prev_bitmap;
        HBITMAP bitmap = (HBITMAP)SelectObject(dc, prev_bitmap);
        DeleteObject(bitmap);
        DeleteDC(dc);
    }
}
示例#2
0
void RedDrawable::frame_rect(const SpiceRect& area, rgb32_t color)
{
    RedDrawable_p* dest = (RedDrawable_p*)get_opaque();
    switch (dest->source.type) {
    case PIXELS_SOURCE_TYPE_X_DRAWABLE:
        frame_drawable(dest, area, color, _origin);
        break;
    case PIXELS_SOURCE_TYPE_PIXMAP:
        frame_pixmap(dest, area, color, _origin);
        break;
    default:
        THROW("invalid dest type %d", dest->source.type);
    }
}
示例#3
0
void RedDrawable::blend_pixels(const PixelsSource& src, int src_x, int src_y, const SpiceRect& area)
{
    PixelsSource_p* source = (PixelsSource_p*)src.get_opaque();
    RedDrawable_p* dest = (RedDrawable_p*)get_opaque();
    switch (dest->source.type) {
    case PIXELS_SOURCE_TYPE_X_DRAWABLE:
        blend_to_drawable(dest, area, _origin, source, src_x + src._origin.x,
                          src_y + src._origin.y);
        break;
    case PIXELS_SOURCE_TYPE_PIXMAP:
        blend_to_pixmap(dest, area, _origin, source, src_x + src._origin.x, src_y + src._origin.y);
        break;
    default:
        THROW("invalid dest type %d", dest->source.type);
    }
}
		TITANIUM_PROPERTY_GETTER(Animation, opaque)
		{
			return get_context().CreateBoolean(get_opaque());
		}
RedPixmapSw::RedPixmapSw(int width, int height, RedDrawable::Format format,
                         bool top_bottom, RedWindow *win)
    : RedPixmap(width, height, format, top_bottom)
{
    DWORD *pixel_format;
    ASSERT(format == RedDrawable::ARGB32 || format == RedDrawable::RGB32
           || format == RedDrawable::RGB16_555 || format == RedDrawable::RGB16_565
           || format == RedDrawable::A1);
    ASSERT(sizeof(RedPixmap_p) <= PIXELES_SOURCE_OPAQUE_SIZE);

    struct {
        BITMAPINFO inf;
        RGBQUAD palette[255];
    } bitmap_info;

    memset(&bitmap_info, 0, sizeof(bitmap_info));
    bitmap_info.inf.bmiHeader.biSize = sizeof(bitmap_info.inf.bmiHeader);
    bitmap_info.inf.bmiHeader.biWidth = _width;
    bitmap_info.inf.bmiHeader.biHeight = top_bottom ? -_height : _height;

/*#ifdef USE_OGL
    // -----------------------------------------------------------------------------
    // ensure valid access to additional stride.
    // apparently glReadPixels validate ((ptr of last line) + GL_PACK_ROW_LENGTH + 1).
    // seen on "ATI Radeon HD 2400 PRO" "2.0.6479 Release"
    if (top_bottom) {
        bitmap_info.inf.bmiHeader.biHeight--;
    } else {
        bitmap_info.inf.bmiHeader.biHeight++;
    }
    //------------------------------------------------------------------------------
#endif*/

    bitmap_info.inf.bmiHeader.biPlanes = 1;
    bitmap_info.inf.bmiHeader.biBitCount = RedDrawable::format_to_bpp(format);
    if (format == RedDrawable::RGB16_565) {
        bitmap_info.inf.bmiHeader.biCompression = BI_BITFIELDS;
    } else {
        bitmap_info.inf.bmiHeader.biCompression = BI_RGB;
    }
    switch (format) {
    case RedDrawable::A1:
        bitmap_info.inf.bmiColors[0].rgbRed = 0;
        bitmap_info.inf.bmiColors[0].rgbGreen = 0;
        bitmap_info.inf.bmiColors[0].rgbBlue = 0;
        bitmap_info.inf.bmiColors[1].rgbRed = 0xff;
        bitmap_info.inf.bmiColors[1].rgbGreen = 0xff;
        bitmap_info.inf.bmiColors[1].rgbBlue = 0xff;
        break;
    case RedDrawable::RGB16_565:
        pixel_format = (DWORD *)bitmap_info.inf.bmiColors;
        pixel_format[0] = 0xf800;
        pixel_format[1] = 0x07e0;
        pixel_format[2] = 0x001f;
        break;
    }
    AutoDC dc(create_compatible_dc());
    AutoGDIObject bitmap(CreateDIBSection(dc.get(), &bitmap_info.inf, 0,
                                          (VOID **)&_data, NULL, 0));
    if (!bitmap.valid()) {
        THROW("create compatible bitmap failed");
    }
/*#ifdef USE_OGL
    SetWindowOrgEx(dc.get(), 0, -1, NULL); // compensate for one pad line
#endif*/
    ((RedPixmap_p*)get_opaque())->prev_bitmap = (HBITMAP)SelectObject(dc.get(), bitmap.release());
    ((RedPixmap_p*)get_opaque())->pixels_source_p.dc = dc.release();
}