Answer the question
In order to leave comments, you need to log in
How to get a screenshot in the right color format?
Hello.
I'm working on a program that captures frames from a region of the screen and generates a GIF animation from them. Here is an example code:
hdcScreen = GetDC(hDesktopWnd);
hdcMemDC = CreateCompatibleDC(hdcScreen);
hbmScreen = CreateCompatibleBitmap(hdcScreen, width, height);
BitBlt( hdcMemDC, 0, 0, width,height, hdcScreen, x, y, SRCCOPY);
GetDIBits(hdcMemDC, hbmScreen, 0,
(UINT) height, lpbitmap,
(BITMAPINFO *)&bmpInfo, DIB_RGB_COLORS);
// на данном этапе в lpbitmap хранятся пиксели в RGB формате
// далее пиксели используются для генерации кадра GIF
bmpInfo.biBitCount = 32; // Works fine.Each pixel is 32 bit
bmpInfo.biBitCount = 24; // Works fine.Each pixel is 24 bit
bmpInfo.biBitCount = 16; // Works fine.Each pixel is 16 bit
bmpInfo.biBitCount = 8; // Causes Access violation
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question