Gili
2004-05-14 04:19:52 UTC
Hi,
I am trying to understand the layout and size of the pixel data buffer
returned by CreateDIBSection(). My code executes:
BITMAPINFO bitmapInfo = {0};
bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFO);
bitmapInfo.bmiHeader.biWidth = desktopWidth;
bitmapInfo.bmiHeader.biHeight = desktopHeight;
bitmapInfo.bmiHeader.biPlanes = 1;
bitmapInfo.bmiHeader.biBitCount = 8*3;
bitmapInfo.bmiHeader.biCompression = BI_RGB;
bitmapInfo.bmiHeader.biSizeImage = 0;
bitmapInfo.bmiHeader.biXPelsPerMeter = 0; //?
bitmapInfo.bmiHeader.biYPelsPerMeter = 0; //?
bitmapInfo.bmiHeader.biClrUsed = 3;
bitmapInfo.bmiHeader.biClrImportant = 0;
bitmapInfo.bmiColors->rgbRed = 0;
bitmapInfo.bmiColors->rgbGreen = 0;
bitmapInfo.bmiColors->rgbBlue = 0;
bitmapInfo.bmiColors->rgbReserved = 0;
bufferedImageBitmap = CreateDIBSection(hProgmanDC, &bitmapInfo,
DIB_RGB_COLORS, (void**) &bufferedImageBitmapData, 0, 0);
Now, in the above function call, what is the size of the returned
bufferedImageBitmapData buffer? I'm expecting it to be "desktopWidth *
desktopHeight * 4" but it is not (it is less). Can anyone explain why?
Furthermore, is my BITMAPINFO initialization correct or did I misinitialize
some fields? I wasn't sure what to put in for biXPelsPerMeter and
biYPelsPerMeter and I assumed setting them to zero will work fine.
Thanks,
Gili
I am trying to understand the layout and size of the pixel data buffer
returned by CreateDIBSection(). My code executes:
BITMAPINFO bitmapInfo = {0};
bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFO);
bitmapInfo.bmiHeader.biWidth = desktopWidth;
bitmapInfo.bmiHeader.biHeight = desktopHeight;
bitmapInfo.bmiHeader.biPlanes = 1;
bitmapInfo.bmiHeader.biBitCount = 8*3;
bitmapInfo.bmiHeader.biCompression = BI_RGB;
bitmapInfo.bmiHeader.biSizeImage = 0;
bitmapInfo.bmiHeader.biXPelsPerMeter = 0; //?
bitmapInfo.bmiHeader.biYPelsPerMeter = 0; //?
bitmapInfo.bmiHeader.biClrUsed = 3;
bitmapInfo.bmiHeader.biClrImportant = 0;
bitmapInfo.bmiColors->rgbRed = 0;
bitmapInfo.bmiColors->rgbGreen = 0;
bitmapInfo.bmiColors->rgbBlue = 0;
bitmapInfo.bmiColors->rgbReserved = 0;
bufferedImageBitmap = CreateDIBSection(hProgmanDC, &bitmapInfo,
DIB_RGB_COLORS, (void**) &bufferedImageBitmapData, 0, 0);
Now, in the above function call, what is the size of the returned
bufferedImageBitmapData buffer? I'm expecting it to be "desktopWidth *
desktopHeight * 4" but it is not (it is less). Can anyone explain why?
Furthermore, is my BITMAPINFO initialization correct or did I misinitialize
some fields? I wasn't sure what to put in for biXPelsPerMeter and
biYPelsPerMeter and I assumed setting them to zero will work fine.
Thanks,
Gili