problem with image scaning & displaing . win32 StretchDIBits ()
-
Hello All, General Idea:- I am developing application win32 cleint server type (It is like desktop monitoring ). On server side I am takeing screen shot. & sending it to client side. On server side I have function code like -------------------------------------------- | | |
hdc1 = GetDC(NULL);
hdc2 = CreateCompatibleDC(hdc1);
GetWindowRect(GetDesktopWindow(), &rc);
w = rc.right-rc.left;
h = rc.bottom-rc.top;
bmih.biSize = sizeof(BITMAPINFOHEADER);
bmih.biWidth = w;
bmih.biHeight = h;
bmih.biPlanes = 1;
bmih.biBitCount = 24;
bmih.biCompression = BI_RGB;
bmih.biSizeImage = ((((bmih.biWidth * bmih.biBitCount) + 31) & ~31) >> 3) * bmih.biHeight;
bi.bmiHeader = bmih;
aBmp = CreateDIBSection(hdc1, &bi ,DIB_RGB_COLORS, (void**)&dibvalues, NULL, NULL);
OldObj = SelectObject(hdc2, aBmp);
BitBlt(hdc2, 0, 0, w, h, hdc1, 0, 0, SRCCOPY);//////////////////////////////////////////////////////////////
I have class like
class DesktopScreen{
public:
BITMAPINFOHEADER bmih ;
BITMAPINFO bi; unsigned char dibvalues[lenght]; };------------------------------------------------------------------ using above code I am filling Object of this class & sending it to other side in binary formate (byte). On Client side deserializing is also OK (I check all value at time of debuging )
Now at time WM_Paint:
hDC = BeginPaint(hWnd, &Ps);i= StretchDIBits(hDC, // destination rectangle 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), // source rectangle 0, 0,desktopObj.bmih.biWidth , desktopObj.bmih.biHeight, desktopObj.dibvalues, &desktopObj.bi, DIB_RGB_COLORS, SRCCOPY);
//////////////////////////////////////////////////////////////////////////StretchDIBits is returning 0 . Application run properlly but image is not displying. also if i call StretchDIBits on server side passing same info to that function.I mages is displaying. Can you please tell me what should be the problem. ( sorry for posting code ,but I think it is necessary to get my Question to you ) Thanks , Ashish.