• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!
Collapse

You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:

  • You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
  • You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
  • If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.

Previously on "CreateCompatibleBitmap"

Collapse

  • suityou01
    replied
    Originally posted by VectraMan View Post
    You've got the 7th & 8th parameters of both BitBlts wrong. It's xsrc, ysrc, not width and height, so should be 0,0.

    BitBlt won't stretch. If you're expecting to get a small thumbnail of the whole screen, you want StretchBlt.

    Code:
    // copy whole screen to Memory bitmap
    BitBlt(hMemDC, 0, 0, xWidth, yHeight, hScreenDC, 0, 0, SRCCOPY);
    
    hBitmap = SelectObject(hMemDC, hOldBitmap);
    
    // stretch to 100,100
    StretchBlt(clientDC, 0, 0, 100, 100, hMemDC, 0, 0, xWidth, yHeight, SRCCOPY);

    Thanks VM. That helped.

    Leave a comment:


  • VectraMan
    replied
    You've got the 7th & 8th parameters of both BitBlts wrong. It's xsrc, ysrc, not width and height, so should be 0,0.

    BitBlt won't stretch. If you're expecting to get a small thumbnail of the whole screen, you want StretchBlt.

    Code:
    // copy whole screen to Memory bitmap
    BitBlt(hMemDC, 0, 0, xWidth, yHeight, hScreenDC, 0, 0, SRCCOPY);
    
    hBitmap = SelectObject(hMemDC, hOldBitmap);
    
    // stretch to 100,100
    StretchBlt(clientDC, 0, 0, 100, 100, hMemDC, 0, 0, xWidth, yHeight, SRCCOPY);

    Leave a comment:


  • suityou01
    started a topic CreateCompatibleBitmap

    CreateCompatibleBitmap

    I have used one of these to do a screen grab. I have a device context to my GTK image widget, and want to load my bitmap into the image

    code is below.

    So I think I have done the screen grab ok, I just cannot see the end result. I would like to load it into the Image box I have, but dumping to file is just as good. Been googling this for a while now, and everything I try does not work.

    What is the shortest way to get this working? Any suggestions? This is only for POC so no need to go to town on it.

    Code:
    int doScreenGrab(HANDLE clientDC)
    {
    	HANDLE hScreenDC;
    	HANDLE hMemDC;
    	HANDLE hWnd;
    	HGDIOBJ     hOldBitmap , hBitmap;
    	
    	long xWidth = GetSystemMetrics(SM_CXSCREEN);
    	long yHeight = GetSystemMetrics(SM_CYSCREEN);
    	
    	g_print("Desktop metrics xWidth : %d yHeight : %d \n",xWidth,yHeight);
    	
    	hScreenDC = GetDC(0);
    	hMemDC = CreateCompatibleDC(hScreenDC);
    	
    	g_print ("Desktop Device Context %d \n", hScreenDC);
    	g_print ("Memory Device Context %d \n", hMemDC);
    	hWnd = WindowFromDC(hScreenDC);
    	g_print ("Desktop hWnd %d \n", hWnd);
    	
    	hBitmap = CreateCompatibleBitmap(hScreenDC, xWidth, yHeight);   
    	hOldBitmap =   SelectObject (hMemDC, hBitmap);
    	BitBlt(hMemDC, 0, 0, 100, 100, hScreenDC, xWidth, yHeight, SRCCOPY);
    
    	hBitmap = SelectObject(hMemDC, hOldBitmap);   
    	BitBlt(clientDC, 0, 0, 100, 100, hMemDC, xWidth, yHeight, SRCCOPY);
    	
    	DeleteDC(hScreenDC);     
    	DeleteDC(hMemDC);     
    }
Working...
X