Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to get Bitmap bits array (RGB)
#1
Well, I am trying to get a bitmap file in memory, the function SaveBitmap saves a bitmap in hard disk, I need the file in a string without saving it, then I get this function that gets all bitmap format info(still incomplete):

Function bitmapFileFormat
Code:
Copy      Help
function
BITMAPINFOHEADER bmih
bmih.biSize=sizeof(BITMAPINFOHEADER)
;bmih.biBitCount=???param???
bmih.biClrImportant=0
bmih.biCompression=BI_RGB
;bmih.biHeight=???param???
;bmih.biWidth=???param???
bmih.biPlanes=1
;bmih.biSizeImage=width*height*(bitcount/8)

BITMAPFILEHEADER bfh
bfh.bfType=0x4d42
bfh.bfOffBits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)
bfh.bfSize=bfh.bfOffBits+bmih.biSizeImage
ret

The problem is that the above function requires a byte array to save the file, I don't need to save bitmap to hard disk, I only need to get the full file in a string(str), but I don't know hot to get the byte array, I have tryed GetBitmapBits but WinApi reference says that this function should not be used and in fact this function returns zero(maybe I didn't call it correctly).

Function Dlgrant
Code:
Copy      Help
;\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2030109 "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,case WM_PAINT
,,PAINTSTRUCT p
,,int dc=BeginPaint(hDlg &p)
,,
,,drawShape 0,0,100,105,dc
,,int bm=CreateCompatibleBitmap(dc 100 105)
,,drawShape 4,70,10,15,dc
,,BITMAP n
,,GetObject bm sizeof(BITMAP) &n
,,;int tsiz=n.bmWidth*n.bmHeight*n.bmBitsPixel
,,;byte* thebytes=calloc(tsiz sizeof(byte))
,,;free(thebytes) <--- here I would like to make some out of RGB byte array  :?:
,,
,,EndPaint hDlg &p
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1

Thank you

Regards.


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)