Parametric Bitmap

Environment: Windows NT4 SP5, Visual C++ 6 SP3

Introduction

Let's think about grayscale palette like about gradient from black color to white. "Equal" colored palette can be represented as two gradients stacked side by side: gradient from black to "desired" color and gradient from "desired" color to white. Desired color usually placed in the middle (in grayscale palette this color is 50% gray), but it can be moved along gradient to varying brightness. If you replace grayscale palette by "equal" colored palette then you get an interesting effect (see image below). It might be useful.

ParametricBitmap1.jpg (20 Kb)

About parametric bitmap

Now I must explain what I mean then telling parametric bitmap. Parametric bitmap is a bitmap created from other bitmaps in which grayscale palette replaced by equal colored. You may want to use only some areas of produced image. Image may be composed from several layers by using various blending techniques (see "EBGfx library to get fast access to image data" by El Barto) and especially alpha-blending (every pixel besides red, green and blue components have additional component alpha (so-called alpha channel) which using in blending operations). Masks can be used too. Any layer can be also parametric. So, why I called it "parametric"? Parameters in this bitmap are start, middle and end colors in gradient; it may be changed.

Where can I use it?

It may be useful when you gonna use a lot of images of gradients and/or 3D objects pictured on this images in application design. You can realize parametric bitmaps in your programs "skins", bitmapped dialogs and everywhere where has usually used ordinary bitmaps, thereby you significantly improve exterior of your applications. Three colors in gradient(s) may be inputted by users in "Settings" dialog or they may depend on system color settings, so your application can make self-tuning for more integration in Windows by color (by retrieving current color of the target display element and handling WM_SYSCOLORCHANGE message later).

Some notes

When to create parametric bitmaps? You may create bitmaps then your program is loading but it probably increase total time of loading. It is faster to read created and saved earlier bitmaps from disk (or applications resources) instead of create it every time. Creation (or recreation) of the bitmaps on loading required when it running first time or if saved earlier bitmaps was deleted or damaged or when the system colors on which depend bitmaps changed since last run (in case of system color depending). Save created bitmaps (to save into resource use UpdateResource()) in the next cases: application is unloading after first run, user have changed colors and pressed "Apply" button in "Settings" dialog, system palette changed (in case of system color depending).

Conclusion

Instead the conclusion you may download and explore sample application. In this sample you can load background image which is a "parametric bitmap". By clicking in gradient area you can select its color in start, middle or end. By dragging slider you change brightness. Foreground image can be loaded too.

ParametricBitmap2.gif (6 Kb)

Downloads

Download sample project - 18 Kb
Download sample images - 180 Kb

Top White Papers and Webcasts

  • Ever-increasing workloads and the challenge of containing costs leave companies conflicted by the need for increased processing capacity while limiting physical expansion. Migration to HP's new generation of increased-density rack-and-blade servers can address growing demands for compute capacity while reducing costly sprawl. Sponsored by: HP and Intel® Xeon® processors Intel, the Intel logo, and Xeon Inside are trademarks of Intel Corporation in the U.S. and/or other countries. HP is the sponsor …

  • The impact of a data loss event can be significant. Real-time data is essential to remaining competitive. Many companies can no longer afford to rely on a truck arriving each day to take backup tapes offsite. For most companies, a cloud backup and recovery solution will eliminate, or significantly reduce, IT resources related to the mundane task of backup and allow your resources to be redeployed to more strategic projects. The cloud - can now be comfortable for you – with 100% recovery from anywhere all …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds