Results 1 to 4 of 4

Thread: Bit Blitting

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2000
    Posts
    350
    Can someone please explain what Bit Blitting with BitBlt actually is?


  2. #2
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Well,

    BitBlt is short form of Bit Block Transfer and you can use it to copy graphics from buffer to buffer. In other words it's a API (Application Programming Interface) call to copy graphics memory. It's not as fast as DirectDraw but it's very easy to implement. However, if you're interested download my BitBlt demo project...


  3. #3
    Hyperactive Member Warmaster199's Avatar
    Join Date
    Aug 2000
    Location
    Canada
    Posts
    306

    BitBlt

    Bitblt can be used for many graphics functions. One of them being Alpha-Blending. It usually is used to copy a picture to another area. One thing that Bitblt can do is use mask a mask to "cut" the backround of the image out to make it's backround appear clear.
    To Declare Bitblt, put the following in a module:
    Code:
    Declare Function BitBlt Lib "gdi32" (ByVal hDestDC_
     As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth_
     As Long, ByVal nHeight As Long, ByVal hSrcDC As Long,_
     ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As_
     Long) As Long
    Public Const SRCAND = &H8800C6
    Public Const SRCCOPY = &HCC0020
    Public Const SRCERASE = &H440328
    Public Const SRCINVERT = &H660046
    Public Const SRCPAINT = &HEE0086
    Now for this next sample, Add a form to your VB project. In that form, add 2 picture boxes(picSprite, and picMask. Keep them away from top left corner of form. Put a picture in picSprite and it's Mask in picmask. note: a mask is simply the picture all in white, with it's backround in white.), and a command button(cmdBlt). Now add this in the form.

    Code:
    Private Sub cmdBlt_Click()
        Me.Cls
        With picSprite
            BitBlt Me.hdc, 0, 0, .ScaleWidth, .ScaleHeight, _
            picMask.hdc, 0, 0, vbSrcAnd
            BitBlt Me.hdc, 0, 0, .ScaleWidth, .ScaleHeight, _
            picSprite.hdc, 0, 0, vbSrcPaint
        End With
        Me.Refresh
    End Sub
    If this runs correctly, Bitblt will blend picSprite with it's mask, effectively clearing away picSprite's backround making it trasparent in the top left corner of the form. You can apply this to games and other graphics apps. Hope this helps alot.
    Designer/Programmer of the Comtech Operating System(CTOS)

  4. #4
    New Member
    Join Date
    Sep 2000
    Location
    Posts
    2

    Thumbs up Tutorial on Drawing and Animation

    There is a good tutorial at
    http://www.vbexplorer.com/gdi1.asp
    about Drawing and Animation using the Win32 GDI.
    It covers:
    *BitBlit
    *sprite animation
    *Strechblt
    *Moving
    *timing
    *back buffering (remove flicker)
    *Backgrounds - side scrolling, multiple side scrolling, and Starfields
    *Game loops
    and even using and creating Memory DCs to load pictures(You can get rid of the overhead created by the Picturebox control)

    It is not all conclusive, but it is a good start if you are interested in Animation or Gaming in VB.





    Stuart

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