Capturing Screen w/GDI (8 BPP)
Hi all ! I'm new to the forum. I've registered because this is getting to my nerves, and I was hoping to get a helping hand.
I'm trying to capture my desktop screen using WinGDI and C++ and then save it to disk as a. bmp file (kind of what you get when you PrntScreen + Paste in Paint). I've manged to do this in 16, 24 and 32 bits per pixel mode, but it doesn't seem to be working in 8 BPP mode: all I was able to make is a crappy .bmp with mixed up colors.
I've already tried to get the system palette (GetSystemPaletteEntries()) to make my own Identity Palette (including those 20 Window's reserved colors) and selected it into my drawing DC (the one I BitBlt in) and fwrite this palette in the final .bmp file's header, but to no avail.
Theorically, if you call CreateDIBSection with DIB_PAL_COLORS in 256 colors mode, the RGB palette defined in the RGBQUAD struct included in the BITMAPINFOHEADER is used to draw and interpret the bitmap selected in the DC, but... how could I possibly know which colors are going to be needed to capture my screen ? Moreover, doesn't the actual logical palette depend on which window is on top (aka, have focus)?
Perhaps, I'm getting it all wrong... or, maybe there's no way of achieving this using GDI.
Any help will be appreciated.