- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
integer*4 hdcBits, cClrBits
integer*4 nBitmapWidth, nBitmapHeight
integer*4 hBitmap, hOldBitmap ! bitmap handle
integer(1), ALLOCATABLE:: lpBits(:)
integer(1), ALLOCATABLE:: lpBitsCompr(:)
pointer (p, pbmi)
type (T_BITMAPINFO) pbmi
........
cClrBits = 24
nMem = SizeOf(pbmi%bmiHeader)
p = LocalAlloc(LPTR, nMem)
! Prepare BITMAPINFO for the bitmap
pbmi%bmiHeader%biSize = SizeOf(pbmi%bmiHeader)
pbmi%bmiHeader%biWidth = nBitmapWidth
pbmi%bmiHeader%biHeight = nBitmapHeight
pbmi%bmiHeader%biPlanes = 1
pbmi%bmiHeader%biBitCount = cClrBits
pbmi%bmiHeader%biCompression = BI_RGB
pbmi%bmiHeader%biSizeImage = IAND(pbmi%bmiHeader%biWidth * cClrBits + 31, INOT(31))/8 * pbmi%bmiHeader%biHeight
pbmi%bmiHeader%biXPelsPerMeter = 0
pbmi%bmiHeader%biYPelsPerMeter = 0
pbmi%bmiHeader%biClrUsed = 0
if (cClrBits < 16) pbmi%bmiHeader%biClrUsed = 2**cClrBits
pbmi%bmiHeader%biClrImportant = 0
ALLOCATE(lpBits(pbmi%bmiHeader%biSizeImage), STAT=AllocErr)
if (AllocErr == 0) then
hBitmap = CreateDIBSection(hDC, pbmi, DIB_RGB_COLORS, LOC(lpBits), 0, 0)
hdcBits = CreateCompatibleDC(hDC)
hOldBitmap = SelectObject(hdcBits, hBitmap)
! Prepare the bitmap by painting the spectrum
call CfPrBMP(hdcBits, nBitmapWidth, nBitmapHeight)
! Replace a new object with the original, default object
i = SelectObject(hdcBits, hOldBitmap)
! Retrieve the color table (RGBQUAD array) and the bits (array of palette indices) from the DIB.
nScan = GetDIBits(hdcBits, hBitmap, 0, pbmi%bmiHeader%biHeight, loc(lpBits), loc(pbmi), DIB_RGB_COLORS)
........
end if
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Take a look at the arguments for calling GetDIBits; according to MS,
"If lpvBits is NULL and the bit count member of BITMAPINFO is initialized to zero, GetDIBits fills in a BITMAPINFOHEADER structure or BITMAPCOREHEADER without the color table. This technique can be used to query bitmap attributes."
So if you call with null values [ie, GetDIBits (hdc, hbitmap, 0, 0, 0, LOC(bitmapInfo), DIB_RGB_COLORS)] the colormap properties are returned in the info header structure.- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page