Playing around with imagelists right now, mainly looking for the means to extract single images from one list and transfer them to another. So in examining the API for something that would do this, I find nothing, except for ImageList_GetImageInfo which seems to come close in that it returns the handle to the bitmap, along with the bounding rectangle of the selected image. Found out through experimentation that the image list's bitmap is stored as a grid, 4 across and N down, depending on how many images are stored in the list. At least with a bitmap imagelist, have not tinkered with icon lists yet.
Returns me the information about the imagelist, and "selected" image, sort of arbitrary at this point, was still looking to extract a single image from the imagelist, the code prints the following for an 8 bit imagelist:
And this from a 32 bit imagelist:
The "ImageList_Draw=1" is from code a bit further along. Armed with the above information, I executed:
When the imagelist is in 24 or 32 bit mode, the results is the imagelist as I've determined to be setup in memory, 4 across and N down. It also works when the imagelist is in 8 bit mode, however, I only know this because of the size of the resulting image, and when examining the contents of the file itself with frhed, I see the bits of the images in the bitmap, but no color table. Which was expected, more or less. The ImageList_GetImageInfo returns a handle to the bitmap, and a pointer to the BITS of the bitmap, nothing in there about the color table. So the next step, obviously, was to get the color table of the bitmap, and attach it to the hDib from FreeImage.
Not so fast it seems, the bitmap maintained by the imagelist when in an 8 bit mode seems to be a DDB, not a DIB, hence GetDIBColorTable does not work. When I tried it, it returned a color count of 2, so as far as the DC into which I selected the imagelist's bitmap into was concerned, it was a monochrome bitmap.
I tried using a GRAPHIC BITMAP to capture the whole image via a bitblt, and just the "selected" image within the imagelist via ImageList_Draw:
And according to walking through the results with frehed, at offset 0x1c, the WORD there should be biBitCount and it says it's a 24 bit image. And the resulting image is "visible", that is, it's got color. But this is a 24 bit image and for the destination, I desire an 8 bit image.
Any ideas on how to get the color table of the imagelist's color table?
Code:
LOCAL pImage AS IMAGEINFO LOCAL hImageList AS DWORD LOCAL pBits AS BITMAP LOCAL pSize AS LONG LOCAL hDib, hDC AS DWORD LOCAL filename AS ASCIIZ * %MAX_PATH CONTROL SEND hDialog, idControl, %LVM_GETIMAGELIST, %LVSIL_SMALL, 0 _ TO hImageList ImageList_GetImageInfo hImageList, 0, pImage pSize = SIZEOF(pBits) GetObject pImage.hbmImage, pSize, pBits #DEBUG PRINT "pBits.bmWidth="& FORMAT$(pBits.bmWidth) _ &" pBits.bmHeight="& FORMAT$(pBits.bmHeight) _ &" pBits.bmWidthBytes="& FORMAT$(pBits.bmWidthBytes) _ &" pBits.bmBitsPixel="& FORMAT$(pBits.bmBitsPixel) _ &" pBits.bmBits="& FORMAT$(pBits.bmBits) #DEBUG PRINT "hbmImage="& FORMAT$(pImage.hbmImage) _ &" rcImage.nLeft="& FORMAT$(pImage.rcImage.nLeft) _ &" rcImage.nTop="& FORMAT$(pImage.rcImage.nTop) _ &" rcImage.nRight="& FORMAT$(pImage.rcImage.nRight) _ &" rcImage.nBottom="& FORMAT$(pImage.rcImage.nBottom)
Code:
pBits.bmWidth=160 pBits.bmHeight=80 pBits.bmWidthBytes=160 _ pBits.bmBitsPixel=8 pBits.bmBits=21626880 hbmImage=2986676997 rcImage.nLeft=0 rcImage.nTop=0 _ rcImage.nRight=40 rcImage.nBottom=40 ImageList_Draw=1
Code:
pBits.bmWidth=160 pBits.bmHeight=80 pBits.bmWidthBytes=640 _ pBits.bmBitsPixel=32 pBits.bmBits=21626880 hbmImage=2802127693 rcImage.nLeft=0 rcImage.nTop=0 _ rcImage.nRight=40 rcImage.nBottom=40 ImageList_Draw=1
Code:
hDib = FreeImage_ConvertFromRawBits(BYVAL pBits.bmBits, _ pBits.bmWidth, pBits.bmHeight, pBits.bmWidthBytes, _ pBits.bmBitsPixel, 0,0,0, %FALSE) filename = EXE.PATH$ &"imagelist.bmp" FreeImage_Save %fif_bmp, hDib, filename hDib = UnloadDib(hDib) ' this is a MACRO wrapper around the unload and returns Zero
Not so fast it seems, the bitmap maintained by the imagelist when in an 8 bit mode seems to be a DDB, not a DIB, hence GetDIBColorTable does not work. When I tried it, it returned a color count of 2, so as far as the DC into which I selected the imagelist's bitmap into was concerned, it was a monochrome bitmap.
I tried using a GRAPHIC BITMAP to capture the whole image via a bitblt, and just the "selected" image within the imagelist via ImageList_Draw:
Code:
GRAPHIC BITMAP NEW 40, 40 TO hDib ' remember, I released this above GRAPHIC ATTACH hDib, 0 GRAPHIC GET DC TO hDC #DEBUG PRINT "ImageList_Draw="& _ FORMAT$( ImageList_Draw (hImageList, 0, hDC, 0, 0, %ILD_NORMAL )) filename = EXE.PATH$ &"image.bmp" GRAPHIC SAVE filename GRAPHIC BITMAP END
Any ideas on how to get the color table of the imagelist's color table?
Comment