[so] [WinAPI]Capture Window with Alpha Channel

Alin Popescu alinpopescu at live.com
Tue Jun 16 01:01:54 EEST 2009


Salut!

Nu are legatura cu ce s-a facut pe la so, dar are legatura cu mult prea  
obscurul WinAPI.
Incerc sa fac o captura de fereastra si sa salvez pixelii intr-o textura  
de Direct3D. In final ferestre 3D cu transparenta :)

Problema mea e ca nu reusesc sa salvez si alpha channel din fereastra.
Am incercat sa folosesc si GetDIBits, dar fara rezultate.

Poate a mai incercat cineva de pe aici si i-a gasit solutie.
L-as ruga sa o impartaseasca cu comunitatea de WinAPI devs.

void CaptureWindow(HWND hWnd, LPDIRECT3DTEXTURE9 Tex)
{
    HDC hdcWindow = GetWindowDC(hWnd);
    HDC hdcMemory = CreateCompatibleDC(hdcWindow);
    HBITMAP hBitmap = CreateCompatibleBitmap(hdcWindow, Width, Height);
    hOld = SelectObject(hdcMemory, hBitmap);
    bool bResult = PrintWindow(hWnd, hdcMemory, 0);

    D3DLOCKED_RECT rect;
    Tex->LockRect(0, &rect, NULL, D3DLOCK_DISCARD);
    GetBitmapBits(hBitmap, Width * Height * 4, rect.pBits);
    Tex->UnlockRect(0);}

    SelectObject(hdcMemory, hOld);
    DeleteObject(hBitmap);
    DeleteDC(hdcMemory);
    ReleaseDC(hWnd, hdcWindow);
}

Thanx in advance.


More information about the so mailing list