Vista/Win7 Ingame-Screenshots sind schwarz



  • Hallo,

    wir sind dabei ein Tool zu schreiben, das autmatisch ingame.screenshots macht. Leider sind die bei Win7/Vista immer schwarz. Ich habe bissl über GETDC und BITBLD gelesen, das das Problem damit zu tun hat. bzw. das es was mit MSDN
    ( http://msdn.microsoft.com/en-us/library/aa969540(VS.85).aspx ) zu tun hat. Leider ist der coder beruflich sehr eingespannt und hat kaum Zeit. Ich versuch ihm nun etwas unter die Arme zu greifen und will schaun was an seinem Code falsch ist. Unten mal der Code, welchen er verwendet um die Screens zu machen.

    QPixmap QPixmap::grabWindow(WId winId, int x, int y, int w, int h )
    {
        RECT r;
        GetClientRect(winId, &r);
    
        if (w < 0) w = r.right - r.left;
        if (h < 0) h = r.bottom - r.top;
    
    #ifdef Q_OS_WINCE_WM
        if (qt_wince_is_pocket_pc()) {
            QWidget *widget = QWidget::find(winId);
            if (qobject_cast<QDesktopWidget *>(widget)) {
                RECT rect = {0,0,0,0};
                AdjustWindowRectEx(&rect, WS_BORDER | WS_CAPTION, FALSE, 0);
                int magicNumber = qt_wince_is_high_dpi() ? 4 : 2;
                y += rect.top - magicNumber;
            }
        }
    #endif
    
        // Create and setup bitmap
        HDC display_dc = GetDC ;
        HDC bitmap_dc = CreateCompatibleDC(display_dc);
        HBITMAP bitmap = CreateCompatibleBitmap(display_dc, w, h);
        HGDIOBJ null_bitmap = SelectObject(bitmap_dc, bitmap);
    
        // copy data
        HDC window_dc = GetDC(winId);
        BitBlt(bitmap_dc, 0, 0, w, h, window_dc, x, y, SRCCOPY
    #ifndef Q_OS_WINCE
                                        | CAPTUREBLT
    #endif
                );
    
        // clean up all but bitmap
        ReleaseDC(winId, window_dc);
        SelectObject(bitmap_dc, null_bitmap);
        DeleteDC(bitmap_dc);
    
        QPixmap
    

    Danke
    ICQ:298922990
    MSN & Mail:renemoerke@gmail.com


  • Mod

    Hm, das habe ich schon mal irgendwo gelesen, ist wohl ein Bekanntes Problem.
    Eine Lösung kenne ich allerdings nicht dazu.


Anmelden zum Antworten