Hello all! I am making a utility that reads raw data and displays it as a bitmap. My problem lies in the filling out of the structures. 1. What is the right way to fill out a n-index RGBQUAD structure? 2. How does one associate STRUCTURES with other STRUCTURES? ie. BITMAPINFO has a bmiHeader index which has to be associated with a BITMAPINFOHEADER structure? Any help is much appreciated.

WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM 
    LOCAL ps:PAINTSTRUCT 
    LOCAL hdc:HDC 
    LOCAL hMemDC:HDC 
    LOCAL rect:RECT 
    LOCAL bi:BITMAPINFO
    LOCAL bih:BITMAPINFOHEADER
    LOCAL brgb[255]:RGBQUAD
    LOCAL PixelData[307200]:BYTE
    
    .if uMsg==WM_CREATE 
mov bi.bmiHeader, OFFSET bih
mov bi.bmiColors, OFFSET brgb

        mov brgb.rgbBlue, 1  ;not properly filled out
        mov brgb.rgbRed, 1
        mov brgb.rgbGreen, 1
        
        mov bih.biSize, SIZEOF BITMAPINFOHEADER       ;length of header info
        mov bih.biWidth, 640                          ;size of bitmap
        mov bih.biHeight, 480
        mov bih.biPlanes, 1
        mov bih.biBitCount, 8                         ;bpp
        mov bih.biCompression, BI_RGB                 ;none
        mov bih.biSizeImage, 0                        ;uncompressed
        mov bih.biXPelsPerMeter, 0                    ;res of target device
        mov bih.biYPelsPerMeter, 0
        mov bih.biClrUsed, 0                          ;use max colors
        mov bih.biClrImportant, 0                     ;all colors important
        invoke CreateDIBitmap, hInstance, addr bi.bmiHeader, CBM_INIT, addr PixelData, addr bi, 0
        mov hBitmap,eax 

    .elseif uMsg==WM_PAINT 
.
.
Posted on 2001-04-22 14:23:00 by MaiMai
1. What is the right way to fill out a n-index RGBQUAD structure?
An RGBQUAD structure contains 4 bytes in the order: blue, green, red and reserved. Reserved is always 0. So an array of RGBQUAD structures is n * (blue byte, green byte, red byte, 0 byte), where n is the number of colors in the table.
2. How does one associate STRUCTURES with other STRUCTURES? ie. BITMAPINFO has a bmiHeader index which has to be associated with a BITMAPINFOHEADER structure?
The BITMAPINFO structure is defined as:

BITMAPINFO STRUCT
  bmiHeader  BITMAPINFOHEADER <>
  bmiColors  RGBQUAD <>
BITMAPINFO ENDS
The bmiHeader member is a structure member (a structure in a structure). You can use it like any other stucture. For example, if you want to access the biBitCount member of the BITMAPINFOHEADER structure:

.data?
SomeBitmap BITMAPINFO 
.code
mov SomeBitmap.bmiHeader.biBitCount, 16
Thomas
Posted on 2001-04-22 16:02:00 by Thomas
thanks! :)
Posted on 2001-04-22 18:58:00 by MaiMai