2009-08-14 19 views
5

Estoy haciendo las capturas de pantalla de IE usando PrintWindow. El problema es que algunas veces obtengo imágenes con áreas negras. Puede ser todo un contenido html que sea negro, algunas veces solo ciertas áreas son negras.Imágenes negras al hacer capturas de pantalla con PrintWindow

El contenido del IE no se cambia entre tomas.

Lo extraño es que en algunas computadoras obtengo imágenes negras muy a menudo, en algunas nunca las consigo.

Probé con Fx y tenía las mismas imágenes en negro.

HBITMAP ShootWindow(HWND hWnd) 
{ 
    RECT rect = {0}; 

    GetWindowRect(hWnd, & rect); 

    HDC hDC = GetDC(hWnd); 
    if(hDC == NULL) 
     throw "GetDC failed."; 

    HDC hTargetDC = CreateCompatibleDC(hDC); 
    if(hTargetDC == NULL) 
     throw "CreateCompatibleDC failed."; 

    HBITMAP hBitmap = CreateCompatibleBitmap(hDC, rect.right - rect.left, rect.bottom - rect.top); 
    if(hBitmap == NULL) 
     throw "CreateCompatibleBitmap failed."; 

    if(!SelectObject(hTargetDC, hBitmap)) 
     throw "SelectObject failed."; 

    if(!PrintWindow(hWnd, hTargetDC, 0)) 
     throw "PrintWindow failed."; 

    ReleaseDC(hWnd, hDC); 
    ReleaseDC(hWnd, hTargetDC); 

    return hBitmap; 
} 

he encontrado algunos enlaces, pero no dan la respuesta:

http://www.vbforums.com/showthread.php?t=555250 http://www.codeguru.com/forum/archive/index.php/t-357211.html http://social.msdn.microsoft.com/forums/en-US/winforms/thread/3e3decd8-ced1-4f17-a745-466e5aa91391/

+0

¿Existe una correlación entre áreas negras y SWF/Flash que se incluye en la página? – Mark

+0

No. Tengo agujeros negros con www.google.com simple. – alex2k8

+0

Veo el problema en Windows 2008. Aunque XP, Vista y Windows 7 parecen estar bien. – alex2k8

Respuesta

2

Esto parece ser común al tomar capturas de pantalla de aplicaciones que están utilizando la GPU. BitBlt puede copiar con éxito los píxeles donde falla PrintWindow.

WINDOWINFO wi; 
GetWindowInfo(hWnd, &wi); 

BitBlt(hdc, 0, 0, rect.right - rect.left, rect.bottom - rect.top, hDC, wi.rcClient.left, wi.rcClient.top, SRCCOPY); 
Cuestiones relacionadas