I'm gho author of the DxWnd tool that tries to provide support to run old and legacy programs on modern windows environment.
A very strange game is G-Nome that, despite being able to run natively on Win7-10 systems, brings a serious problem for graphic manipulation.
The game links to ddraw, but builds every frame as a DIB_PAL_COLORS
DIB and brings the DIB to screen using SetDIBitsToDevice
user32 calls.
The operation is supported by OBJ_DC
type DC on video also on 32 bit color depth video modes, but produces bad colors when applied to MEM_DC type DC.
I found this while trying to scale the DIB using a typical schema like this (variable declarations and error checking stripped for brevity):
hTempDc=CreateCompatibleDC(hdc);
hbmPic=CreateCompatibleBitmap(hdc, OrigWidth, OrigHeight);
SelectObject(hTempDc, hbmPic);
SetDIBitsToDevice(hTempDc, 0, 0, OrigWidth, OrigHeight, XSrc, YSrc, uStartScan, cScanLines, lpvBits, lpbmi, fuColorUse);
StretchBlt(hdc, XDest, YDest, dwWidth, dwHeight, hTempDc, 0, 0, OrigWidth, OrigHeight, SRCCOPY);
According to MSDN, when you output a DIB_PAL_COLORS
DIB the pixels are mapped to the "current" realized palette, but of course on a 32 bit surface and on its memory DC clone there is no palette at all, so it's no wonder that the pixel colors look all wrong.
An alternative solution could be to emulate the SetDIBitsToDevice
behaviour building a 32 bit memory DC to be then scaled at will with StretchBlt
, but again it is not documented how I could convert a 8bpp DIB_PAL_COLORS
DIB to either a 32bpp DIB_RGB_DIB
or a 32bpp DC.
I already tried in several ways, but in all cases it seems that I can't identify the correct palette to be used to convert pixel indices.
Could someone help me to interpret the 8bpp DIB_PAL_COLORS
DIB format?