Hello, below is a block of my code. I don't understand why CreateDIBSection() returns NULL. Thanks a lot in advance.
Code:
pPackedDib = (BITMAPINFO *)(malloc (sizeof(BITMAPINFOHEADER) + 256*sizeof(WORD)));
pPackedDib->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
pPackedDib->bmiHeader.biWidth = 300;
pPackedDib->bmiHeader.biHeight = 450;
pPackedDib->bmiHeader.biPlanes = 1;
pPackedDib->bmiHeader.biBitCount = 8;          // max 256 colors supported
pPackedDib->bmiHeader.biCompression = BI_RGB;
pPackedDib->bmiHeader.biSizeImage = 0;
pPackedDib->bmiHeader.biXPelsPerMeter = 0;
pPackedDib->bmiHeader.biYPelsPerMeter = 0;
pPackedDib->bmiHeader.biClrUsed = 0;
pPackedDib->bmiHeader.biClrImportant = 0;
pPackedDib->bmiColors[0].rgbRed = 204;
pPackedDib->bmiColors[0].rgbGreen = 204;
pPackedDib->bmiColors[0].rgbBlue = 204;
pPackedDib->bmiColors[0].rgbReserved = 0;

if (pPackedDib)
    {
    // Create the DIB section from the DIB
        hBitmap = CreateDIBSection (NULL,
                                               pPackedDib, 
                                               DIB_PAL_COLORS,
                                               &pBits, 
                                               NULL, 0);
        ...

        free(pPackedDib);
    }