If you enjoy fiction, visit this Amazon.com page to read a new sci-fi novel and support this site!
Archive for the ‘Graphics Code’ Category
Thursday, June 19th, 2008 |
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, also available on this site) use variations of the gradient algorithm - so learn it well!
Download Code (10kb)
Posted in Graphics Code, VB6 | No Comments »
Thursday, June 19th, 2008 |
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. If that made no sense whatsoever, download the program to see what I mean! (Note: it’s much faster to just use the LoadImage API call (which uses a somewhat inaccurate but fast resampling algorithm), but obviously it’s always to a programmer’s advantage to know how a function actually works.)
Download Code (15kb)
Posted in Graphics Code, VB6 | No Comments »
Thursday, June 19th, 2008 |
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 the average is 127 (close enough for our purposes).
Many people have used this code in various open-source VB projects, but rest assured: this is the original, most complete, most correct copy.
Download Code (103kb)
Posted in Graphics Code, VB6 | No Comments »
Thursday, June 19th, 2008 |
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)
Posted in Graphics Code, VB6 | No Comments »