Color shifting is a very fast, very simple effect that can greatly simplify the work of game artists. (Above is a demonstration using a classic StarCraft Siege Tank.) It is also extremely simple to implement – all we do is shift the red, green, and blue values of each pixel to the right or left. This allows us to generate two additional color variations on a source image without any extra work. (Read the rest of the article for details and sample code…)
Because gray-toned values have RGB values that are identical (or nearly identical), color shifting doesn’t change the appearance of gray pixels. This is pretty clear on the siege tanks above, as the color shifting merely adjusted the subtle hues of the gray regions…
This is one of my all-time favorite image effects – a simulated blacklight that looks GREAT on any image with people in it. I invented this algorithm myself, and the provided code will allow you to test the effect in real-time on any image below 2MB. (The sample image is Squall from FF8 – the greatest RPG ever made, btw…)
This is the first of its kind in VB: accurate, real-time image level adjustment. Image levels provide better control over luminance than strict brightness/contrast methods, but not quite as much control as a well-built Curves Dialog. Adjusting an image using input/output/midtone levels is useful for brightening or darkening an image without losing detail at either end of the luminance spectrum. I’ve included simple histogram drawing code (as the screenshot shows) so you can see the effect that adjusting levels has on an image’s histogram. The code is well-commented and fast – please post comments and/or requests for future VB graphics projects.
By request, here is the first of its kind in VB: a fast, accurate, real-time image curves dialog. (This should be familiar to any PhotoShop users out there :) Curves is similar in theory both “Image Levels” post and standard gamma correction, but it provides a much more powerful interface for adjusting the luminance of an image. This project provides results very similar to Photoshop’s, and it allows the creation of more spline knots (32 instead of 16). The code is well-commented and very fast – please post comments, requests for future Photoshop-related code, and many heaps of praise (as this was a complicated routine to sort out…)!
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 (especially since the advent of modern OSes), perhaps the most useful aspect of this project is the algorithm used to draw a gradient. Many other algorithms (like image [...]
Resampling involves using interpolation algorithms when resizing an image to minimize negative impact on image quality. For example, when you resize a 50×50 image to 500×500 the image looks horrible – it looks like a bunch of giant squares. Resampling reduces that blockiness by interpolating pixels, so the image looks rounded even after it’s resampled. [...]
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.
Download Code (7k)
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 ways [...]