使用GetBitmapBits直接获取到位图数据就可以用socket发送出去了: HBITMAP hbmp = CreateCompatibleBitmap(hdcScreen, prc->right - prc->left, // 位图宽 prc->bottom - prc->top); // 位图高 DOWORD dwBitmapSize = (prc->right - prc->left * prc->bottom - prc->top) * 24 /8 ; BYTE * pBitmap = new BYTE[dwBitmapSize ]; if (pBitmap ) { LONG lResult =GetBitmapBits( hbmp, // handle to bitmap dwBitmapSize , // number of bytes to copy pBitmap); // buffer to receive bits if (lResult >0 ) { // Send the bitmap data store in pBitmap with socket, it is length is dwBitmapSize } }
HBITMAP hbmp = CreateCompatibleBitmap(hdcScreen,
prc->right - prc->left, // 位图宽
prc->bottom - prc->top); // 位图高
DOWORD dwBitmapSize = (prc->right - prc->left * prc->bottom - prc->top) * 24 /8 ;
BYTE * pBitmap = new BYTE[dwBitmapSize ];
if (pBitmap )
{
LONG lResult =GetBitmapBits(
hbmp, // handle to bitmap
dwBitmapSize , // number of bytes to copy
pBitmap); // buffer to receive bits
if (lResult >0 )
{
// Send the bitmap data store in pBitmap with socket, it is length is dwBitmapSize
}
}