var bitmap win.BITMAP
win.GetObject(win.HGDIOBJ(hBitmap), unsafe.Sizeof(bitmap), unsafe.Pointer(&bitmap))
var bmpInfo win.BITMAPINFO
bmpInfo.BmiHeader.BiSize = uint32(unsafe.Sizeof(Info.BmiHeader))
....................Width = width
....................Height = height
....................Planes = 1
....................BitCount = 24
....................Compression = win.BI_RGB
var hdc win.HDC
hdc = win.GetDC(0)
win.GetDIBits(hdc, bitmap, 0, uint32(bitmap.BmHeight), bitmapInfo, nil, 0)
pBits := make([]byte, imageSize)
win.GetDIBits(hdc, bitmap, 0, uint32(bitmap.BmHeight), bitmapInfo, (*byte)(unsafe.Pointer(&pBits)), 0)
use package github.com/lxn/win
First of all, we have done all the work before getting the GetDIBits function.
After that, I finally try to get the image data using the GetDIBits function, but it keeps returning 0.
I changed the data type of pBits to 'unsafe.Pointer' or '* byte' and tried it but it returned nil or 0.
How can I get the image data from the GetDIBits function?