[so] [WinAPI]Capture Window with Alpha Channel
Alin Popescu
alinpopescu at live.com
Tue Jun 16 01:23:21 EEST 2009
Uite un exemplu de window capturer "perfect".
http://www.windowclippings.com/
Acesta salveaza si alpha in fisiere.
On Tue, 16 Jun 2009 01:18:20 +0300, Alin Popescu <alinpopescu at live.com>
wrote:
> Salut
>
> Multumesc pentru raspunsul rapid.
>
> Ideea e ca orice fereastra de windows are transparenta. La XP ea e se
> poate observa la colturile ferestrelor, care sunt netede
> (rotunde). Eu incerc sa salvez si alpha channel din device context-ul
> unde se renderizeaza fereastra ca apoi,
> in Direct3D, sa apara la fel de netede.
>
> Pana acum nu am reusit sa salvez decat RGB + A constant. Prin urmare in
> colturi imi apare o zona neagra.
> Alpha-ul texturii e 255 constant. As putea sa fac un pixel shader si sa
> ma folosesc de alpha test
> ca sa scot colturile negre, dar apare o problema daca in ferestra exista
> pixeli negrii(de exemplu text).
>
>
> On Tue, 16 Jun 2009 01:10:15 +0300, Daniel Flamaropol
> <raptorclw at gmail.com> wrote:
>
>> Salut.
>>
>> Ce vrei sa spui prin "nu reusesc sa salvez si alpha channel" ?. Din ce
>> am
>> inteles eu, vrei sa faci un print screen la o fereastra.
>> Unde ar fi alpha channel acolo? De asemenea, ce intelegi prin "ferestre
>> 3D
>> cu transparenta"?
>>
>> Presupun ca vrei sa faci o fereastra de Direct3D care sa para
>> transparenta,
>> la fiecare frame facand un capture la ce se afla
>> in spatele ei, si randand respectiva textura in Direct3D (pe un quad
>> eventual). Asta e?
>>
>> Numai bine,
>> Dani
>>
>> 2009/6/16 Andrei Cibotaru <andreicibotaru at gmail.com>
>>
>>> Pai nu poti sa ii dai tu din direct3d transparenta?
>>>
>>> 2009/6/16 Alin Popescu <alinpopescu at live.com>
>>>
>>> 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.
>>>> _______________________________________________
>>>> so mailing list
>>>> so at cursuri.cs.pub.ro
>>>> http://cursuri.cs.pub.ro/cgi-bin/mailman/listinfo/so
>>>>
>>>
>>>
>>>
>>> --
>>> Cibo
>>>
>>> _______________________________________________
>>> so mailing list
>>> so at cursuri.cs.pub.ro
>>> http://cursuri.cs.pub.ro/cgi-bin/mailman/listinfo/so
>>>
>>>
>
>
> --
> _______________________________________________
> so mailing list
> so at cursuri.cs.pub.ro
> http://cursuri.cs.pub.ro/cgi-bin/mailman/listinfo/so
>
--
More information about the so
mailing list