|
I want to display my image on window without saving it.
When data is received window size changes but there is no display
on window.
My Code is:
int iBufferLength;
int iEnd;
int iSpaceRemaining;
int i;
iBufferLength = iSpaceRemaining = sizeof(chIncomingDataBuffer);
iEnd = 0;
iSpaceRemaining -= iEnd;
iBytesRead = recv(Socket, chIncomingDataBuffer+iEnd, iSpaceRemaining, 0);
iEnd+=iBytesRead;
if (iBytesRead == SOCKET_ERROR)
MessageBox(hWnd,
"Socket Error",
"Connection strt",
MB_ICONINFORMATION|MB_OK);
chIncomingDataBuffer[iEnd] = '\0';
if (lstrlen(chIncomingDataBuffer) != 0)
{
GetWindowRect(hWnd, &rect);
SetWindowPos(hWnd, NULL, rect.left, rect.top, cBitmap.bmWidth, cBitmap.bmHeight, 0);
HDC ThisDC = GetDC(hWnd);
DeleteDC(RemoteDC);
RemoteDC = CreateCompatibleDC(ThisDC);
DeleteObject(hbitmap);
hbitmap= CreateCompatibleBitmap(ThisDC, cBitmap.bmWidth, cBitmap.bmHeight);
SelectObject(RemoteDC, hbitmap);
ReleaseDC(hWnd, ThisDC);
BITMAPINFO bi;
HBITMAP hbmap;
int bisize = sizeof(BITMAPINFO);
memcpy(&bi, chIncomingDataBuffer+iEnd, bisize );
SetDIBits(RemoteDC, hbitmap, 0, cBitmap.bmHeight, chIncomingDataBuffer+iEnd+bisize, &bi, DIB_RGB_COLORS);
InvalidateRect(hWnd, NULL, false);
can anyone tell me..where I am wrong?
|
|
|
|
|
Quote: memcpy(&bi, chIncomingDataBuffer+iEnd, bisize );
for instance, what are you doing in the above line?
Veni, vidi, vici.
|
|
|
|
|
toms from newdelhi wrote: can anyone tell me..where I am wrong? Yes, the same as I told you before. You are not checking that you have read all the data from the client so you have no way of being sure that you have a valid image. You are using sizeof and lstrlen to find the length of the data, neither of which will give you a valid answer.
|
|
|
|