从HICON获取字节,从服务器到客户端通过套接字发送 [英] Get bytes from HICON to sending via socket from server to client
问题描述
我需要从HICON句柄中获取字节,但我不知道如何。
i需要发送带有
发送的字节(套接字,(CHAR *) & Byte_to_send,sizeof(Byte_to_send);
Byte_to_send应该是与每个Windows应用程序的HICON关联的字节,我已经用这种方式得到它:
HICON icon =(HICON)GetClassLong(hWnd,GCL_HICON);
我尝试过:
send(socket,(CHAR *)& Byte_to_send,sizeof(Byte_to_send);
Byte_to_send应该是与每个Windows应用程序的HICON相关联的字节,我已经得到了它这样:
HICON icon =(HICON)GetClassLong(hWnd,GCL_HICON);
Hi, I need to get bytes from HICON handle but I do not know how.
i need to send the byte with
send(socket,(CHAR*)&Byte_to_send,sizeof(Byte_to_send);
Byte_to_send should be the bytes associated to HICON of each windows application, and I've got it in this way:
HICON icon = (HICON)GetClassLong(hWnd, GCL_HICON);
What I have tried:
send(socket,(CHAR*)&Byte_to_send,sizeof(Byte_to_send);
Byte_to_send should be the bytes associated to HICON of each windows application, and I've got it in this way:
HICON icon = (HICON)GetClassLong(hWnd, GCL_HICON);
推荐答案
使用 GetIconInfo函数(Windows) [ ^ ]或 GetIconInfoEx功能(Windows) [ ^ ]和发送这些数据。这需要使用HBITMAP
句柄来访问位图数据。
获取像素数据HBITMAP
将此用于DIB(设备独立位图):
Use GetIconInfo function (Windows)[^] or GetIconInfoEx function (Windows)[^] and send these data. This requires using theHBITMAP
handles to get access to the bitmap data.
To get the pixel data of anHBITMAP
use this for a DIB (Device Independant Bitmap):
DIBSECTION ds;
int nSizeDS = ::GetObject(hBitmap, sizeof(ds), &ds);
// hBitmap is a DIB
if (sizeof(ds) == nSizeDS)
{
// This should not be necessary.
// But many MSDN examples perform these calculations.
if (0 == ds.dsBmih.biSizeImage)
{
if (0 == ds.dsBm.bmWidthBytes)
ds.dsBm.bmWidthBytes = ((ds.dsBm.bmWidth * ds.dsBm.bmBitsPixel + 31) & ~31) / 8;
ds.dsBmih.biSizeImage = ds.dsBm.bmHeight * ds.dsBm.bmWidthBytes;
}
// Image data at ds.dsBm.bmBits
// Data size in ds.dsBmih.biSizeImage
}
这篇关于从HICON获取字节,从服务器到客户端通过套接字发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!