Code: Select all
; Function CreateDIBSection
; Description The CreateDIBSection function creates a DIB (Device Independent Bitmap) that applications can write to directly
;
; w width of the bitmap to create
; h height of the bitmap to create
; hdc a handle to the device context to use the palette from
; bpp bits per pixel (32 = ARGB)
; ppvBits A pointer to a variable that receives a pointer to the location of the DIB bit values
;
; return returns a DIB. A gdi bitmap
;
; notes ppvBits will receive the location of the pixels in the DIB
CreateDIBSection(w, h, hdc:="", bpp:=32, ByRef ppvBits:=0) {
Ptr := A_PtrSize ? "UPtr" : "UInt"
hdc2 := hdc ? hdc : GetDC()
VarSetCapacity(bi, 40, 0)
NumPut(w, bi, 4, "uint")
, NumPut(h, bi, 8, "uint")
, NumPut(40, bi, 0, "uint")
, NumPut(1, bi, 12, "ushort")
, NumPut(0, bi, 16, "uInt")
, NumPut(bpp, bi, 14, "ushort")
hbm := DllCall("CreateDIBSection"
, Ptr, hdc2
, Ptr, &bi
, "uint", 0
, A_PtrSize ? "UPtr*" : "uint*", ppvBits
, Ptr, 0
, "uint", 0, Ptr)
if !hdc
ReleaseDC(hdc2)
return hbm
}
question is, how to read those bit values?ppvBits - A pointer to a variable that receives a pointer to the location of the DIB bit values.
example, nonworking code ive tried:
Code: Select all
CreateDIBSection(A_ScreenWidth, A_ScreenHeight, 0, 32, ppvBits)
MsgBox % ppvBits ; this should be the address of the pointer to the bits, if i understood this right
MsgBox % ptrToBits := NumGet(ppvBits) ; get the address of the bits?
MsgBox % NumGet(ptrToBits, "UInt") ; get the bits?