CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: StretchDIBits

  1. #1
    Join Date
    Mar 2013
    Posts
    4

    StretchDIBits

    I write a software that take screen shots from remote PCs but when the screen is displayed at my window the remote screen is distorted and i can't' view the remote screen! This is part of teh code of the client that capture remote screens:

    BITMAPINFO BMPInfo;
    BMPInfo.bmiHeader.biSize = sizeof(BITMAPINFO);
    BMPInfo.bmiHeader.biWidth = Horz;
    BMPInfo.bmiHeader.biHeight = Vert;

    BMPInfo.bmiHeader.biBitCount = CPP;
    BMPInfo.bmiHeader.biPlanes = BitPlanes;
    BMPInfo.bmiHeader.biSizeImage = Horz * Vert * 4;
    BMPInfo.bmiHeader.biCompression = BI_RGB;

    BMPInfo.bmiHeader.biClrUsed = 24;
    BMPInfo.bmiHeader.biClrImportant = 0;
    HDC Mdc = GetDC(GetDlgItem(Spy,IDC_STATIC1));
    HWND mDlg = GetDlgItem(Spy,IDC_STATIC1);
    GetClientRect(mDlg,&rect);
    StretchDIBits(
    Mdc, // handle to DC
    NULL, // x-coord of destination upper-left corner
    NULL, // y-coord of destination upper-left corner
    rect.right, // width of destination rectangle
    rect.bottom, // height of destination rectangle
    NULL, // x-coord of source upper-left corner
    NULL, // y-coord of source upper-left corner
    Horz, // width of source rectangle
    Vert, // height of source rectangle
    (CONST void *)BufOfPixels, // bitmap bits
    &BMPInfo, // bitmap data
    DIB_RGB_COLORS, // usage options
    SRCCOPY // raster operation code
    );
    *** this code don't works??? Where is wrong???

  2. #2
    Join Date
    Mar 2013
    Posts
    4

    Angry Re: StretchDIBits

    W T F NOBODY ANSWER??? I AM ALREADY OUTBREAK!!! ANSWER NOW I HAVE IMPATIENCE
    Last edited by Steve R Jones; March 26th, 2013 at 08:14 AM.

  3. #3
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    Re: StretchDIBits

    If you have nothing to do while waiting for an answer then please, read the Announcement: Before you post....
    And BTW, why do you think the others would have a lot of patience trying to read/understand your absolutely unreadable code snippet and absolutely uninfornative problem description?
    Victor Nijegorodov

  4. #4
    Join Date
    Mar 2013
    Posts
    4

    Re: StretchDIBits

    Quote Originally Posted by VictorN View Post
    If you have nothing to do while waiting for an answer then please, read the Announcement: Before you post....
    And BTW, why do you think the others would have a lot of patience trying to read/understand your absolutely unreadable code snippet and absolutely uninfornative problem description?
    ***** you make me fly off the handle!
    YOU ARE THE *****EST IN THE WORLD!
    I'LL BLOW UP YOUR HEAD AND I BLOW UP YOUR CORNOS IF YOU DON'T SAY SORRY TO ME NOW!!!
    YOU CA'T COMPROBE TEH LIES THAT YOU'VE SAY!
    Last edited by Steve R Jones; March 26th, 2013 at 08:13 AM.

  5. #5
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    Re: StretchDIBits

    Excuse me, but for such types of posts you may be banned.
    Victor Nijegorodov

  6. #6
    Join Date
    Feb 2013
    Location
    United States
    Posts
    56

    Post Re: StretchDIBits

    Quote Originally Posted by Haker View Post
    Code:
    	BITMAPINFO BMPInfo;
    	BMPInfo.bmiHeader.biSize = sizeof(BITMAPINFO);
    	BMPInfo.bmiHeader.biWidth = Horz;
    	BMPInfo.bmiHeader.biHeight = Vert;
    
    	BMPInfo.bmiHeader.biBitCount = CPP;
    	BMPInfo.bmiHeader.biPlanes = BitPlanes;
    	BMPInfo.bmiHeader.biSizeImage = Horz * Vert * 4;
    	BMPInfo.bmiHeader.biCompression = BI_RGB;
    
    	BMPInfo.bmiHeader.biClrUsed = 24;
    	BMPInfo.bmiHeader.biClrImportant = 0;
    What is CPP?
    What is BitPlanes? This should be 1.
    Unless CPP is 32, BMPInfo.bmiHeader.biSizeImage is miscalculated.
    Why do you set BMPInfo.bmiHeader.biClrUsed to 24? This is saying that you want to use a color palette with 24 entries, but you do not define any entries. Did you mean to set BMPInfo.bmiHeader.biBitCount to 24?

    For future reference, please enclose your code between [CODE] and [/CODE] tags.

  7. #7
    Join Date
    Mar 2013
    Posts
    4

    Re: StretchDIBits

    Quote Originally Posted by Coder Dave View Post
    What is CPP?
    What is BitPlanes? This should be 1.
    Unless CPP is 32, BMPInfo.bmiHeader.biSizeImage is miscalculated.
    Why do you set BMPInfo.bmiHeader.biClrUsed to 24? This is saying that you want to use a color palette with 24 entries, but you do not define any entries. Did you mean to set BMPInfo.bmiHeader.biBitCount to 24?

    For future reference, please enclose your code between [CODE] and [/CODE] tags.
    I already modified my code but the image is still distorted! Here teh code:
    Code:
                                                                    BITMAPINFO BMPInfo;
    					memset((void *)&BMPInfo,0,sizeof(BITMAPINFO));
    					BMPInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    					BMPInfo.bmiHeader.biWidth = Horz;
    					BMPInfo.bmiHeader.biHeight = Vert;
    					BMPInfo.bmiHeader.biBitCount = CPP;
    					BMPInfo.bmiHeader.biPlanes = BitPlanes;
    					BMPInfo.bmiHeader.biSizeImage = 0;
    					BMPInfo.bmiHeader.biCompression = BI_RGB;
    					BMPInfo.bmiHeader.biClrUsed = 0;
    					BMPInfo.bmiHeader.biClrImportant = 0;
    			
    					HDC Mdc = GetDC(GetDlgItem(Spy,IDC_STATIC1));
    					HWND mDlg = GetDlgItem(Spy,IDC_STATIC1);
    					GetClientRect(mDlg,&rect);			
    					StretchDIBits(
    					Mdc,                      // handle to DC
    					NULL,                    // x-coord of destination upper-left corner
    					NULL,                    // y-coord of destination upper-left corner
    					rect.right,               // width of destination rectangle
    					rect.bottom,              // height of destination rectangle
    					NULL,                     // x-coord of source upper-left corner
    					NULL,                     // y-coord of source upper-left corner
    					Head.HAD,                // width of source rectangle
    					Head.VAD,               // height of source rectangle
    					(CONST void *)BufOfPels,           // bitmap bits
    					(CONST BITMAPINFO *)&BMPInfo, // bitmap data
    					DIB_RGB_COLORS,                  // usage options
    					SRCCOPY                   // raster operation code
    					);
    WHERE Horz,Vert ARE THE HORIZONTAL AND VERTICAL ACTIVE DISPLAY FROM THE SERVER, CPP IS THE COLORS PER PIXEL FROM SERVER AND BIT PLANES IS 1

    Where is the error???
    Last edited by Haker; March 19th, 2013 at 06:48 AM.

  8. #8
    Join Date
    Sep 2000
    Location
    Indianapolis
    Posts
    6,754

    Re: StretchDIBits

    Quote Originally Posted by Haker View Post
    ***** you make me fly off the handle!
    YOU ARE THE *****EST IN THE WORLD!
    I'LL BLOW UP YOUR HEAD AND I BLOW UP YOUR CORNOS IF YOU DON'T SAY SORRY TO ME NOW!!!
    Threats are not tolerated on this forum.
    -----------------------------------------------
    Brad! Jones,
    Yowza Publishing
    LotsOfSoftware, LLC

    -----------------------------------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured