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

  • Live Event Date: December 11, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT Market pressures to move more quickly and develop innovative applications are forcing organizations to rethink how they develop and release applications. The combination of public clouds and physical back-end infrastructures are a means to get applications out faster. However, these hybrid solutions complicate DevOps adoption, with application delivery pipelines that span across complex hybrid cloud and non-cloud environments. Check out this …

  • CentreCorp is a fully integrated and diversified property management and real estate service company, specializing in the "shopping center" segment, and is one of the premier retail service providers in North America. Company executives travel a great deal, carrying a number of traveling laptops with critical current business data, and no easy way to back up to the network outside the office. Read this case study to learn how CentreCorp implemented a suite of business continuity services that included …

Most Popular Programming Stories

More for Developers

RSS Feeds