Screen Capture Under Win7 of JOGL Applet

Posted by binarybug on Stack Overflow See other posts from Stack Overflow or by binarybug
Published on 2010-01-28T12:28:57Z Indexed on 2010/04/03 8:53 UTC
Read the original article Hit count: 609

Filed under:
|
|

Hi

I'm trying to take a screen shot of an applet running inside a browser. The applet is using JOGL (OpenGL for Java) to display 3D models. (1) The screen shots always come out either black or white.The current solution uses the usual GDI calls. Screen shots of applets not running OpenGL are fine.
A few examples of JOGL apps can be found here https://jogl-demos.dev.java.net/ (2) Another thing I'm trying to achieve is to get the scrollable area inside the screen shot as well.

I found this code on the internet which works fine except for the 2 issues mentioned above.

import win32gui as wg  
import win32ui as wu  
import win32con  

def copyBitMap(hWnd, fname):  
    wg.SetForegroundWindow(hWnd)  
    cWnd = wu.CreateWindowFromHandle(hWnd)  
    rect = cWnd.GetClientRect()  
    (x,y) = (rect[2] - rect[0], rect[3] - rect[1])  
    hsrccDc = wg.GetDC(hWnd)  
    hdestcDc = wg.CreateCompatibleDC(hsrccDc)  
    hdestcBm = wg.CreateCompatibleBitmap(hsrccDc, x, y)  
    wg.SelectObject(hdestcDc, hdestcBm.handle)  
    wg.BitBlt(hdestcDc, 0, 0, x, y, hsrccDc, rect[0], rect[1], win32con.SRCCOPY)  
    destcDc = wu.CreateDCFromHandle(hdestcDc)  
    bmp = wu.CreateBitmapFromHandle(hdestcBm.handle)  
    bmp.SaveBitmapFile(destcDc, fname)  

© Stack Overflow or respective owner

Related posts about python

Related posts about gdi