Programming

This category contains 27 posts

Game Map Editor (Tile-Based) in VB6

Who doesn’t love a classic tile-based game? VB6 seems to be especially popular for writing tile games, so I’ve put together a simple tile-based map editor for any aspiring game creators out there. The demo is pretty self-explanatory – click on the tile bar at the top (with either the left or right mouse button) to select a tile, then click on the large center window to draw that tile onto the map. Scrolling and zoom are fully implemented, as are saving and loading map files. I’ve also written the engine using both StretchBlt and PaintPicture, and you can use the combo box on the left to specify a painting method.

Smooth color gradients using only VB6 (NO images)

This program demonstrates how to create a smooth color gradient between any two colors on any size of form. While gradients are often used for visual effects, perhaps the most useful aspect of this project is the gradient algorithm itself. Many other algorithms (like image resampling) use variations of the gradient algorithm – so learn [...]

Image Resampling in VB6

Resampling uses specialized interpolation algorithms when resizing an image to minimize any negative impacts to image quality. For example, when you resize a 50×50 image to 500×500, the image looks horrible – like a bunch of giant squares. Resampling reduces that “blockiness” by interpolating pixels, so the image looks rounded even after being resized. If [...]

Real-time Image Contrast in VB6

Here’s the first (and still the best!) VB-based example that demonstrates how to correctly adjust an image’s contrast. I use DIB sections to maximize speed; it’s also worth mentioning that to perfectly determine contrast, you would have to first find the average brightness of the image – I use the shortcut method and assume that [...]

How to properly capture the screen in VB6

There are many bad ways to capture the screen in VB6 (i.e. to copy the image on your monitor to a form or picture box), so I wrote this code to demonstrate one of several right ways.  Each of the 4 required API calls is explained in detail.

VB Graphics Programming: Part 4 (Optimizations Checklist)

Even Faster? This part of the tutorial is slightly different from the previous sections.  Instead of discussing specific graphics routines, I’m going to give you my “Top 10 List of Graphics Code Optimizations.”  This checklist of optimization techniques will give you a good guide for speeding up your graphics application.  We’ll start with the easiest [...]

VB Graphics Programming: Part 3 (Advanced API)

Advanced API Pixel Routines Next comes two advanced ways of getting and setting pixels in Visual Basic: the API routines of GetBitmapBits/SetBitmapBits and GetDIBits/StretchDIBits.  If you haven’t already, I strongly recommend reading the previous two tutorials, “Pure VB Pixel Routines” and “Basic API Pixel Routines,” as they provide the foundation for the advanced graphics principles [...]

VB Graphics Programming: Part 2 (Beginning API)

Basic API Pixel Routines Next, let’s discuss the basics of per-pixel graphics programming using the simple API routines of GetPixel and SetPixel/SetPixelV.  If you haven’t already, I recommend reading the previous page, “Pure VB Pixel Routines,” as it provides the foundation for the advanced graphics principles discussed in this and the next two sections. Assuming [...]

VB Graphics Programming: Part 1 (Pure VB)

Pure VB Pixel Routines First, let’s discuss the basics of per-pixel graphics programming using only built-in Visual Basic functions.  I recommend that even hardened VB veterans glance through this document, as it provides the foundation for the advanced graphics principles discussed in the next three tutorials.  We will discuss the only VB per-pixel graphics functions [...]

VB Graphics Programming: An Introduction

Visual Basic CAN do fast graphics – I promise To my fellow VB 6.0 users: In my experience, many VB programmers seem to believe that fast graphics programming is impossible in VB.  Most complain that PSet and Point (or GetPixel and SetPixel) just aren’t fast enough for their needs, and they feel like they have [...]