At long last, here is the most-requested image processing technique for this site – a comprehensive collection of grayscale conversion techniques. To my knowledge, this is the only project on the Internet that presents 7+ unique grayscale conversion algorithms, including two written from scratch for this very project.
A software-based “diffuse filter” – random displacement of image pixels within a specified radius – was used in a number of SNES, Genesis, and DOS games to simulate an explosion effect. Today’s project provides the source code for generating a diffuse effect in real-time.
This little program demonstrates two key graphics programming principles: 1) simple “painting” code – basically, connecting a series of lines together as the user drags their mouse around, and 2) an implementation of the hard-to-find (and poorly documented) dll call for filling a contiguous region of an image. (Photoshop users should know this as the “paint bucket” tool.) As always, sample code and full documentation is provided…
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 [...]
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 [...]
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 [...]
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.
This last section of my graphics programming tutorials takes a different approach from the previous three 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 provide a simple, straightforward mechanism for speeding up your graphics application. We’ll start [...]
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 [...]
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 [...]