However, you cannot use the function as defined in the Win32API, you have to modify it due to misinterpretation of the parameters required for the operation to be successful. Specifically:
lpbi
[in/out] Pointer to a BITMAPINFO structure that specifies the desired format for the DIB data.
[in/out] Pointer to a BITMAPINFO structure that specifies the desired format for the DIB data.
This works just as fine:
Code:
TYPE BITMAPCOLORS biSize AS LONG biWidth AS LONG biHeight AS LONG biPlanes AS INTEGER biBitCount AS INTEGER biCompression AS LONG biSizeImage AS LONG biXPelsPerMeter AS LONG biYPelsPerMeter AS LONG biClrUsed AS LONG biClrImportant AS LONG biColors(255) AS RGBQUAD END TYPE DECLARE FUNCTION GetDIBColors LIB "GDI32.DLL" ALIAS "GetDIBits" _ (BYVAL hdc AS DWORD, BYVAL hBitmap AS DWORD, _ BYVAL nStartScan AS DWORD, BYVAL nNumScans AS DWORD, _ lpBits AS ANY, lpBI AS BITMAPCOLORS, _ BYVAL wUsage AS DWORD) AS LONG
That aside, I set up the header information with the required data, then executed the call, and copied the palette to the hDib created by FreeImage, and it works as expected, I end up with a palettizied image containing all the bitmaps contained in the ImageList.
Code:
hDib = FreeImage_ConvertFromRawBits(BYVAL pBits.bmBits, _ pBits.bmWidth, pBits.bmHeight, pBits.bmWidthBytes, _ pBits.bmBitsPixel, 0,0,0, %FALSE) hDC = CreateCompatibleDC(0) memBit = SelectObject(hDC, pImage.hbmImage) pBitmap.biSize = SIZEOF(BITMAPINFOHEADER) pBitmap.biWidth = pBits.bmWidth pBitmap.biHeight = pBits.bmHeight pBitmap.biPlanes = 1 pBitmap.biBitCount = pBits.bmBitsPixel pBitmap.biCompression = %BI_RGB GetDIBColors hDC, pImage.hbmImage, 0, pBits.bmHeight, _ BYVAL 0, pBitmap, %DIB_RGB_COLORS SelectObject hDC, memBit DeleteDC hDC CopyMemory(BYVAL FreeImage_GetPalette(hDib),pBitmap.biColors(0),1024) filename = EXE.PATH$ &"imagelist.bmp" FreeImage_Save %fif_bmp, hDib, filename hDib = UnloadDib(hDib)
Leave a comment: