Code: Select all
; RGBQUAD structure
; https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-rgbquad
bmiColors := Buffer(4, 0)
; BITMAPINFOHEADER structure
; https://learn.microsoft.com/en-us/previous-versions/dd183376(v=vs.85)
NumPut "uint" , 40, ; DWORD biSize;
"uint" , 1920, ; LONG biWidth;
"uint" , 1080, ; LONG biHeight;
"Ushort", 1, ; WORD biPlanes;
"Ushort", 32, ; WORD biBitCount;
"uint" , 0, ; DWORD biCompression;
"uint" , 0, ; DWORD biSizeImage;
"uint" , 0, ; LONG biXPelsPerMeter;
"uint" , 0, ; LONG biYPelsPerMeter;
"uint" , 0, ; DWORD biClrUsed;
"uint" , 0, ; DWORD biClrImportant;
bmiHeader := Buffer(4*10)
; BITMAPINFO structure
; https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-bitmapinfo
NumPut "ptr", bmiHeader, ; BITMAPINFOHEADER bmiHeader;
"ptr", bmiColors, ; RGBQUAD bmiColors[1];
bmi := Buffer(44, 0)
Not only that, but I quickly learned that even passing the Buffer.Ptr didnt actually copy the objects content to that address but instead just placed the Buffer.Ptr value to that address.If an object is passed to a Ptr parameter, the value of the object's Ptr property is used.
![Sad :(](./images/smilies/icon_e_sad.gif)
I wish Numput would support receiving a buffer-like object and just copy the values as they are into the target to have a more intuitive way of filling out structures as seen in MSDN.
You can see the solution to this problem by clicking below
Spoiler