Click here to Skip to main content
15,919,423 members

Comments by Member 12891988 (Top 15 by date)

Member 12891988 6-Apr-17 11:38am View    
One last thing, side c#,
I receive data normally using this:
byte[] buffer = new byte[1500];
int iRx = sck.Receive(buffer);
char[] chars = new char[iRx];
System.Text.Decoder d = System.Text.Encoding.UTF8.GetDecoder();
int charLen = d.GetChars(buffer, 0, iRx, chars, 0);
System.String szData = new System.String(chars);

and then I print in listview like so:

listView1.Items.Add(szData)));

-----------------------------------------
But if I have to create the Icon, I have to use DIBSECTION ds to create the image/icon;

width = ds.dsBm.bmWidth;
height = ds.dsBm.bmHeight;
stride = ds.dsBm.bmWidthBytes;
ecc...
But how I can convert byte that I have received to DIBSECTION ds?
So if I convert byte array to ds I can use ds to create the Icon.

Member 12891988 6-Apr-17 8:07am View    
thank you
Member 12891988 6-Apr-17 6:49am View    
You think this should be correct?
I have substituted that condition with tihs if:
if(!nSizeDS){//failure}
else{//is a DIB}

here there the complete part of code:

ICONINFO oIconInfo;
if (::GetIconInfo(icon, &oIconInfo))
{
// Get bitmap info for colour mask
DIBSECTION ds;
int nSizeDS = ::GetObject(oIconInfo.hbmColor, sizeof(ds), &ds);
if(!nSizeDS){
cout <<"Failure!"<<endl;
}else{
// is a DIB
cout <<"Success!"<<endl;
// Send the DIBSECTION
send(newConnection, (CHAR*)&ds, sizeof(ds), NULL);
// Send raw bitmap
send(newConnection, (CHAR*)ds.dsBm.bmBits, ds.dsBmih.biSizeImage, NULL);
}
}
Member 12891988 6-Apr-17 6:25am View    
When I try that piece of code,the if (sizeof(ds) == nSizeDS) condition, isn't ever verified.
How about using the two send without this if (sizeof(ds) == nSizeDS) ?
In this case without the if condition works, but I'm afraid this should be wrong.
Member 12891988 6-Apr-17 6:12am View    
Yes sorry I read, and I have deleted this last my question from here, but maybe to late.