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

  • You probably have several goals for your patient portal of choice. Is "community" one of them? With a bevy of vendors offering portal solutions, it can be challenging for a hospital to know where to start. Fortunately, YourCareCommunity helps ease the decision-making process. Read this white paper to learn more. "3 Ways Clinicians can Leverage a Patient Portal to Craft a Healthcare Community" is a published document owned by www.medhost.com

  • With JRebel, developers get to see their code changes immediately, fine-tune their code with incremental changes, debug, explore and deploy their code with ease (both locally and remotely), and ultimately spend more time coding instead of waiting for the dreaded application redeploy to finish. Every time a developer tests a code change it takes minutes to build and deploy the application. JRebel keeps the app server running at all times, so testing is instantaneous and interactive.

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds