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

  • QA teams don't have time to test everything yet they can't afford to ship buggy code. Learn how Coverity can help organizations shrink their testing cycles and reduce regression risk by focusing their manual and automated testing based on the impact of change.

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds