Sign in to follow this  
lubiancao12

How to surface-GetDc() success?

Recommended Posts

hi, i use directdraw to play video. so i create primary surface and offscreen surface. The primary surface is not FULLSCREEN. the offscreen format is UYVY. all things are ok. NOw i want to write "text" on the video. so i hope to get the offscreen surface dc. but OffscreenSurface->getDc() is fail. i have a test ,OffscreenSurface->getDc() will be ok if the surface format is RGB. but you know ,i can't change the format . how can i do to getdc with the uyvy? thanks!

Share this post


Link to post
Share on other sites
From the documentation for IDirect3DSurface9:

"GetDC is valid on the following formats only: D3DFMT_R5G6B5, D3DFMT_X1R5G5B5, D3DFMT_R8G8B8, and D3DFMT_X8R8G8B8."

It would appear you can't use UYVY.

The likely cause of the restriction is that GetDC uses GDI and GDI doesn't support non-RGB formats.

Share this post


Link to post
Share on other sites
You can probably do a ::LockRect() if the resource is in the correct pool. You could then do a manual blit from a GDI-compatible RGB surface to your UYVY surface.

Alternatively, you can use regular D3D rendering to draw a semi-transparent primitive over the top of your video feed with the text on. Chances are this will be more performant as locking/modifying resource memory directly tends to be quite slow...

hth
Jack

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this