Archived

This topic is now archived and is closed to further replies.

jonny

DirectDraw primary surface

Recommended Posts

Hi. I have a problem with the DirectDraw. I need a code what can make a screenshot from a running game. I can locate the game''s HWND, I get the HDC, and I try to use the DirectDraw surface from HDC. But it contains nothing. How can I get the real pixels of the screen ? If anybody have source code or any idea, please send it to me. Thanks, Jonny

Share this post


Link to post
Share on other sites
Two options...
You can go the dc handle way which is extremely slow or
lock your primary surace get a pointer from ddsd.lpSurface
and quickly pass it over to an array.

Sorry.. I do not have any source code

Share this post


Link to post
Share on other sites
I try to lock the surface, and extract the pixels, but it doesn''t work. Maybe I do something wrong with the DirectDraw. That''s why i ask sources, because I can imagine how should it work, but it didn''t.

Jonny

Share this post


Link to post
Share on other sites
Just do it with "Lock (NULL, &ddsd, DDL_WAIT | DDL_SURFACEMEMORYPTR ...)" or something similar to that. You may need to specify that flag to get the "pitch" as well.

Where ddsd is your surface description structure (DDSURFACEDESC2 I believe). Then it will dump a pointer to the start of the data in the ddsd structure *somewhere* (it''ll say in the doc... I forget right now), and then you''re good to go.

Maybe someone could write this out in better code for him? I''m away from my programming comp/docs right now...

Share this post


Link to post
Share on other sites