mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2025-12-31 02:41:52 +00:00
client: Support 16bpp pixmaps on win32
This commit is contained in:
parent
7dddbfe488
commit
1e4ec1f513
@ -33,7 +33,10 @@ RedPixmapCairo::RedPixmapCairo(int width, int height, RedDrawable::Format format
|
||||
bool top_bottom, RedWindow *win)
|
||||
: RedPixmap(width, height, format, top_bottom)
|
||||
{
|
||||
ASSERT(format == RedDrawable::ARGB32 || format == RedDrawable::RGB32 || format == RedDrawable::A1);
|
||||
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 {
|
||||
@ -61,7 +64,11 @@ RedPixmapCairo::RedPixmapCairo(int width, int height, RedDrawable::Format format
|
||||
|
||||
bitmap_info.inf.bmiHeader.biPlanes = 1;
|
||||
bitmap_info.inf.bmiHeader.biBitCount = RedDrawable::format_to_bpp(format);
|
||||
bitmap_info.inf.bmiHeader.biCompression = BI_RGB;
|
||||
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;
|
||||
@ -71,6 +78,12 @@ RedPixmapCairo::RedPixmapCairo(int width, int height, RedDrawable::Format format
|
||||
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,
|
||||
|
||||
@ -30,9 +30,12 @@ struct RedPixmap_p {
|
||||
};
|
||||
|
||||
RedPixmapGdi::RedPixmapGdi(int width, int height, RedDrawable::Format format, bool top_bottom)
|
||||
: RedPixmap(width, height, format, top_bottom )
|
||||
: RedPixmap(width, height, format, top_bottom)
|
||||
{
|
||||
ASSERT(format == RedDrawable::ARGB32 || format == RedDrawable::RGB32 || format == RedDrawable::A1);
|
||||
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 {
|
||||
@ -47,7 +50,12 @@ RedPixmapGdi::RedPixmapGdi(int width, int height, RedDrawable::Format format, bo
|
||||
|
||||
bitmap_info.inf.bmiHeader.biPlanes = 1;
|
||||
bitmap_info.inf.bmiHeader.biBitCount = RedDrawable::format_to_bpp(format);
|
||||
bitmap_info.inf.bmiHeader.biCompression = BI_RGB;
|
||||
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;
|
||||
@ -57,7 +65,13 @@ RedPixmapGdi::RedPixmapGdi(int width, int height, RedDrawable::Format format, bo
|
||||
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));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user