Blting to Offscreen bitmap

ochensati
05-20-2002, 04:30 PM
I need to move the directX primary surface to an offscreen bitmap to use as a background.

I have
'Flip the primary surface
If screenFlags = ddWindowed Then
Dim r1 As RECT 'The screen size
'Gets the bounding rect for the entire window handle, stores in r1
Call dx.GetWindowRect(BackO.hwnd, r1)
Call Primary.Blt(r1, Back, ScreenRect, DDBLT_WAIT)

Else

Primary.Flip Nothing, DDFLIP_WAIT
End If

Which displays my image on the screen, but I cannot figure out how to capture it so I can use paintpicture or bitblt on it.

any advise?

Squirm
05-20-2002, 06:13 PM
So, you're wanting to use API on DirectX surfaces?

This is easily done using the .GetDC and .ReleaseDC methods of the surface:

Dim hDC As Long

hDC = MySurf.GetDC

'Here we do any API/GDI drawing, using hDC whenever a DC is required.
'Do ALL API inside this block, then call:

MySurf.ReleaseDC hDC

'Blah blah more DirectX stuff
MySurf.Flip Nothing, DDFLIP_WAIT

AndreRyan
05-21-2002, 04:53 AM
Why do you want to copy to another surface you could just leave it there and draw over it.

But if you need to copy it to another surface just Blt it.

ochensati
05-21-2002, 12:46 PM
Ok So now I have

hDC = Primary.GetDC

F3D.Picture1.AutoRedraw = True
r2.top = F3D.Picture1.ScaleHeight
r2.Left = F3D.Picture1.ScaleWidth

jj = BitBlt(F3D.Picture1.hDC, 0, 0, r2.left, r2.left, hDC, r2.Left, r2.top, SRCCOPY)
F3D.Picture1.AutoRedraw = False
Primary.ReleaseDC hDC
F3D.Picture1.Cls

But this seems to miss the surface and I get a nice picture of the lower left hand corner of my screen, not the directdraw surface.
Thank you for the help I was going crazy trying to figure out how to lock the surface!

ochensati
05-21-2002, 01:00 PM
Nevermind I got it. I now have

Dim hDC As Long, r2 As RECT
hDC = Back.GetDC

F3D.Picture1.AutoRedraw = True
r2.top = F3D.Picture1.ScaleHeight
r2.Left = F3D.Picture1.ScaleWidth
jj = BitBlt(F3D.Picture1.hDC, 0, 0, F3D.Picture1.ScaleWidth, F3D.Picture1.ScaleHeight, hDC, 0, 0, SRCCOPY)
F3D.Picture1.AutoRedraw = False
Back.ReleaseDC hDC

Which also is nice as the backbuffer does not seem to have the clipping problems.

Thanks for your help!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum