PDA

Click to See Complete Forum and Search --> : Bit Blitting


Jim Brown
Aug 25th, 2000, 04:10 AM
Can someone please explain what Bit Blitting with BitBlt actually is?

Fox
Aug 25th, 2000, 10:07 AM
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 (http://orion.spaceports.com/~mccloud/coding/graphical.htm#BitBlt sample)...

;)

Warmaster199
Aug 31st, 2000, 08:34 PM
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:

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.


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.

stupete
Sep 4th, 2000, 01:22 PM
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.