Hi, I need help. the following code seem to crash where I've indicated: invoke LoadImage, hInst, 134, IMAGE_BITMAP, 120, 120, LR_CREATEDIBSECTION .if eax == 0 jmp GetOut .endif mov DibPoint, eax mov ebx, DibPoint mov eax, sizeof BITMAPFILEHEADER ; BITMAPINFO immediately follows .if eax == 0 jmp GetOut .endif add eax,ebx ; the header (pointed to by ebx) mov pbmi,eax ; Points to bitmap information mov esi,eax ; save to reg as well ; *********** Crashes Here \/ \/ mov eax, BITMAPFILEHEADER.bfOffBits; offset from BMFH struct to pix bits add eax,ebx mov pBits,eax ; This is a pointer to the actual DIB pixel bits ;Get the DIB width & height ;-------------------------- .IF BITMAPINFO.bmiHeader.biSize== sizeof BITMAPCOREHEADER ; width & height are WORDs xor eax,eax ; Make sure we clear high word mov ax, BITMAPCOREHEADER.bcWidth ; Width of bitmap mov cxDib, eax mov ax, BITMAPCOREHEADER.bcHeight ; Height mov cyDib, eax .ELSE ; width & heght are DWORDs xor eax,eax ; Make sure we clear high word mov eax, BITMAPINFO.bmiHeader.biWidth mov cxDib, eax mov eax, BITMAPINFO.bmiHeader.biHeight .IF eax < 1 neg eax ; Get abs value .ENDIF mov cyDib, eax .ENDIF Basically the code is loading a bitmap from a resource and converting it to a DIB. I almost positive that it crashes because LoadImage returns the DIB handle, not a pointer. Question is how do I get that pointer?
Posted on 2001-03-03 15:49:00 by Zadkiel
You're right, LoadImage returns a handle to the bitmap. If you really want to get a pointer to the raw resource data you've got to use the LoadResource function. Note that the BITMAPFILEHEADER is stripped from bitmap resources.
Posted on 2001-03-03 20:07:00 by Tola
That was it, I figured that any bitmap wouldn't just do, thats why I used loadImage for its LR_CREATEDIBSECTION option. But I was wrong, it wroks perfectly.
Posted on 2001-03-04 17:52:00 by Zadkiel