Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. problem with image scaning & displaing . win32 StretchDIBits ()

problem with image scaning & displaing . win32 StretchDIBits ()

Scheduled Pinned Locked Moved C / C++ / MFC
sysadminhelpquestionlounge
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ashish8patil
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups