|
-
Jun 12th, 2008, 06:26 AM
#1
Thread Starter
KING BODWAD XXI
Using bitblt API on DXDrawSurface7
Hello people. I am trying to copy an image from a picture box onto a directdrawsurface7. For some reason the bitblt API just wont do its job. Every example I have seen on the web seems to be the same
Code:
'Create The Image
DDSD.lFlags = DDSD_CAPS + DDSD_HEIGHT + DDSD_WIDTH
DDSD.ddsCaps.lCaps = DDSCAPS_3DDEVICE
DDSD.lWidth = DXRect.Right - DXRect.Left
DDSD.lHeight = DXRect.Bottom - DXRect.Top
Set DXSurface = DDraw.CreateSurface(DDSD)
SurfaceDC = DXSurface.GetDC
Debug.Print BitBlt(SurfaceDC, 1, 1, DDSD.lWidth, DDSD.lHeight, PBBox.Image, DXRect.Left + 1, DXRect.Top + 1, vbSrcCopy)
DXSurface.ReleaseDC SurfaceDC
Anybody got any advice as to why it wont be working?
-
Jun 12th, 2008, 07:08 AM
#2
Re: Using bitblt API on DXDrawSurface7
Not sure about BitBlting to a directdrawsurface7, but I am familiar with BitBlt.
BitBlt requires a hDC for both the source and destination, your using a Bitmap handle for the source, try this
Code:
Debug.Print BitBlt(SurfaceDC, 1, 1, DDSD.lWidth, DDSD.lHeight, PBBox.hDC, DXRect.Left + 1, DXRect.Top + 1, vbSrcCopy)
BitBlt also does not invoke a refresh so normally you have to also refresh the target to see the result, I don't now how that would apply to a directdrawsurface7.
-
Jun 12th, 2008, 07:44 AM
#3
Thread Starter
KING BODWAD XXI
Re: Using bitblt API on DXDrawSurface7
No sorry that didnt work either. Thanks for the help though
-
Jun 12th, 2008, 07:48 AM
#4
Re: Using bitblt API on DXDrawSurface7
Did you refresh? What code did BitBlt return?
If it was non zero, BitBlt was successful, at least it thinks it was.
Last edited by Milk; Jun 12th, 2008 at 07:51 AM.
-
Jun 12th, 2008, 08:04 AM
#5
Thread Starter
KING BODWAD XXI
Re: Using bitblt API on DXDrawSurface7
Oh it always returns 0. I thought that meant success S
I dont think there is a refresh in DX.
-
Jun 12th, 2008, 08:08 AM
#6
Thread Starter
KING BODWAD XXI
Re: Using bitblt API on DXDrawSurface7
Hmmm it does work but its returning some weird image as though its off my screen. Its a block from the center of my screen not the picturebox S
-
Jun 12th, 2008, 08:14 AM
#7
Re: Using bitblt API on DXDrawSurface7
Ahh, set the source pictureboxes autoredraw property to true. If false the picturebox does not have it's own DC, and BitBlt will copy a portion of the desktop instead.
-
Jun 12th, 2008, 08:25 AM
#8
Thread Starter
KING BODWAD XXI
Re: Using bitblt API on DXDrawSurface7
Found it. The hdc is what I need but the picturebox HAS TO HAVE AUTOREFRESH ON. Otherwise it copies the image behind the picturebox 
Thanks for your help. Wouldnt have got anywhere if I didnt know the hdc and the fact that bitblit returns non zero as a success
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|