BitBlt demos

rpgnewbie
12-19-2003, 01:41 AM
A Newbie Bitblt Tutorial with Samples...

At the request of Pooyae in the following thread:
http://www.visualbasicforum.com/t128032.html

...and because there is little in the way of simple BitBlt examples/tutorials on this forum, I am posting the following in hopes that some moderator may deem it worthy for Tutor's Corner (in order to assist those VB programmers new to using Bitblt in the development of their games).

Attached should be:

"BitBlt_Grass Tiling Demo.zip" - which demonstrates using Bitblt to fill a picture box control with grass tile images

"BitBlt_Walking_Man_ Demo.zip" - the grass tiling code in this demo is the same as the "BitBlt_Grass_Tiling_Demo" except the BitBlt command has been replaced by the PaintPicture code to show how to easy it is to interchange both graphic functions.
This demo also features a BitBlt-ed moving image (sprite) that is animated by flipping through a sequence of three frames. Because it uses bitblt-ing (instead of image controls) the animation is seamless and flickerfree. The sprite moves from left to right and stops just before reaching the right edge of the picturebox and shows a msgbox.
All graphics images (including masks) are included in the zipped files. The BitBlt Public Declare function is in it's own module, as this is the way it is usually done in larger projects.

Through the generous permission of dark2025 the following is also included:
BltDemo is a fully commented tutorial tucked inside a demo program showing a red ball which is moved around by the mouse against a complex background both with and without sprite background transparency. The Bitblt Declaration, as well as GetTickCount Declaration, are both in a bas module.

All three demos have been designed with simplicity and ease of understanding for VB beginners in mind. Hopefully you will find them helpful.

If you are interested in a VB program for that automatically creates design time masks, you can check out "AutoSpriteMaskCreator2.zip" attached at the bottom of this thread:
http://www.visualbasicforum.com/t107858.html


After learning the basics of Bitblt-ing with masks created at design time, you may wish to try runtime (programmatic) masking. If so, you may find it useful to explore the following thread links:

Thread with run time masking code from shmoove (uses "CreateCompatibleDC):
http://www.visualbasicforum.com/t51613.html

Programmatic masking demo with class-based caching In the Code Library (by OnErrOr):
http://www.visualbasicforum.com/t109862.html

noi_max
11-09-2004, 09:42 AM
Since the newbie BitBlt demos have been such a useful resource, it seems logical to have a link to the backbuffer example in the same thread as well.

BackBufferPark:
http://www.xtremevbtalk.com/t157310.html

This article demonstrates how the use of a backbuffer can help eliminate flicker and how creating your own DCs can eliminate the need of using controls to hold your images. (No pictureboxes! Yaaay!)

anon
11-09-2004, 02:10 PM
I think you are being far far too modest noi_max :o

You've taken rpgnewbie's BackBufferPark code and extended it in many interesting and useful ways...as demonstrated by the attachments in your Bitblt Sprite Sheet thread:
http://www.xtremevbtalk.com/t184577.html

However, (unforutnately) there are still newbies who are still struggling with the basics of Gary Beebe's Bitblt tutorial on the old Lucky's site:
http://www.rookscape.com/vbgaming/GBeebe/bitblt.php

There are a couple issues with the tutorial:
1.) It doesn't use the in-built VB6 constants (vbSrcCopy, vbSrcAnd, vbSrcPaint) to replace the constants that used to have to be declared:

Public Const SRCCOPY = &HCC0020
Public Const SRCPAINT = &HEE0086
Public Const SRCAND = &H8800C6

2.) It also doesn't use any kind of backbuffer. Once you start using Bitblt to do animation it quickly becomes apparent how useful it is to have a backbuffer.

I really hope eventually everyone will move to using memoryDC backbuffers (as the above sited attachments from rpgnewbie and noi_max demonstrate), but I realize that for many newbies (that are still climbing the learning curve) this is too much to ask right away.

So I recently posted an example of how you can use a hidden picturebox (with the AutoRedraw property set to True) as a backbuffer to "upgrade" the Beebe Bitblt tutorial code to provide a little flickerfree movement. It's attached to this post:
http://www.xtremevbtalk.com/showpost.php?p=884299

I know there aren't a lot of BitBlt examples in the forum's Code Library, but please Please PLEASE also do a search if you have any questions on the use of the Bitblt API. There are many many additional Bitblt tutorials -- if you type in "Bitblt Tutorial" (in the forum's search feature) or "VB Bitblt Tutorial" (in Google) you will come up with many hits.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum