void copyBitmaptoBuffer(HDC hdc, HBITMAP bitmap)
{
BITMAPINFO MyBMInfo = { 0 };
MyBMInfo.bmiHeader.biSize = sizeof(MyBMInfo.bmiHeader);
GetDIBits(hdc, bitmap, 0, 0, NULL, &MyBMInfo, DIB_RGB_COLORS);
char* lpPixels = new char[MyBMInfo.bmiHeader.biSizeImage];
MyBMInfo.bmiHeader.biBitCount = 32;
MyBMInfo.bmiHeader.biCompression = BI_RGB;
MyBMInfo.bmiHeader.biHeight = abs(MyBMInfo.bmiHeader.biHeight);
GetDIBits(hdc, bitmap, 0, MyBMInfo.bmiHeader.biHeight,
lpPixels, &MyBMInfo, DIB_RGB_COLORS);
strcpy(picbuffer, lpPixels); //copy bytes to outputbuffer
}
我有像素数据缓冲区,但我无法找到将此过程反转回图像的方法。例如,我想通过套接字连接发送它并将其组装回客户端上的bmp文件。最好没有外部库。
如何从原始缓冲区像素数据构建bmp?