Results 1 to 8 of 8

Thread: Using bitblt API on DXDrawSurface7

  1. #1

    Thread Starter
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176

    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?
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  2. #2
    Cumbrian Milk's Avatar
    Join Date
    Jan 2007
    Location
    0xDEADBEEF
    Posts
    2,448

    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.

  3. #3

    Thread Starter
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176

    Re: Using bitblt API on DXDrawSurface7

    No sorry that didnt work either. Thanks for the help though
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  4. #4
    Cumbrian Milk's Avatar
    Join Date
    Jan 2007
    Location
    0xDEADBEEF
    Posts
    2,448

    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.

  5. #5

    Thread Starter
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176

    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.
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  6. #6

    Thread Starter
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176

    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
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  7. #7
    Cumbrian Milk's Avatar
    Join Date
    Jan 2007
    Location
    0xDEADBEEF
    Posts
    2,448

    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.

  8. #8

    Thread Starter
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176

    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

    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width