mirror of
https://github.com/gnustep/libs-back.git
synced 2025-04-22 15:31:14 +00:00
* Source/winlib/WIN32GState.m (GSCreateBitmap): Add support for
(8 bit-greyscale, 8-bit alpha) format. This fixes various default images not showing (menu arrows, scroller arrows, etc.) git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@33582 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
726d4a0801
commit
883c8cbd61
2 changed files with 44 additions and 1 deletions
|
@ -1,3 +1,9 @@
|
|||
2011-07-18 Eric Wasylishen <ewasylishen@gmail.com>
|
||||
|
||||
* Source/winlib/WIN32GState.m (GSCreateBitmap): Add support for
|
||||
(8 bit-greyscale, 8-bit alpha) format. This fixes various default
|
||||
images not showing (menu arrows, scroller arrows, etc.)
|
||||
|
||||
2011-07-15 Eric Wasylishen <ewasylishen@gmail.com>
|
||||
|
||||
* Source/x11/XGServerWindow.m: Add Xcursor support (for RGBA
|
||||
|
|
|
@ -749,6 +749,43 @@ HBITMAP GSCreateBitmap(HDC hDC, int pixelsWide, int pixelsHigh,
|
|||
}
|
||||
bits = tmp;
|
||||
}
|
||||
else if (bitsPerPixel == 16 && samplesPerPixel == 2) // 8 bit greyscale 8 bit alpha
|
||||
{
|
||||
BITMAPV4HEADER *bmih;
|
||||
unsigned char *tmp;
|
||||
unsigned int pixels = pixelsHigh * pixelsWide;
|
||||
unsigned int i = 0, j = 0;
|
||||
|
||||
((BITMAPINFOHEADER*)bitmap)->biBitCount = 32;
|
||||
|
||||
bmih = (BITMAPV4HEADER*)bitmap;
|
||||
bmih->bV4Size = sizeof(BITMAPV4HEADER);
|
||||
bmih->bV4V4Compression = BI_BITFIELDS;
|
||||
bmih->bV4BlueMask = 0x000000FF;
|
||||
bmih->bV4GreenMask = 0x0000FF00;
|
||||
bmih->bV4RedMask = 0x00FF0000;
|
||||
bmih->bV4AlphaMask = 0xFF000000;
|
||||
tmp = malloc(pixels * 4);
|
||||
if (!tmp)
|
||||
{
|
||||
NSLog(@"Failed to allocate temporary memory for bitmap. Error %d",
|
||||
GetLastError());
|
||||
free(bitmap);
|
||||
DeleteObject(hbitmap);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while (i < pixels*4)
|
||||
{
|
||||
tmp[i+0] = bits[j];
|
||||
tmp[i+1] = bits[j];
|
||||
tmp[i+2] = bits[j];
|
||||
tmp[i+3] = bits[j + 1];
|
||||
i += 4;
|
||||
j += 2;
|
||||
}
|
||||
bits = tmp;
|
||||
}
|
||||
else if (bitsPerPixel == 24)
|
||||
{
|
||||
unsigned char* tmp;
|
||||
|
@ -795,7 +832,7 @@ HBITMAP GSCreateBitmap(HDC hDC, int pixelsWide, int pixelsHigh,
|
|||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"Unsure how to handle images with %d bits", bitsPerPixel);
|
||||
NSLog(@"Unsure how to handle images with %d bpp %d spp", bitsPerPixel, samplesPerPixel);
|
||||
}
|
||||
free(bitmap);
|
||||
DeleteObject(hbitmap);
|
||||
|
|
Loading…
Reference in a new issue