dhpoware logo
navbar
home products source demos contact us
navbar navbar
box top left corner box top right corner
 
 
Bitmap Class.

The Bitmap class is a simple wrapper around the Win32 DIB (Device Independent Bitmap) API.

The Bitmap class uses the IPicture COM interface to load images. The Bitmap class can import the following file formats: BMP, EMF, GIF, ICO, JPG, TGA, and WMF. The Bitmap class can export its pixel data to a BMP file. Once an image is loaded into the Bitmap class methods are provided to allow direct access and manipulation of the pixel data.

Also supported is the ability to capture a screen shot of the Windows desktop and loading that as an image into the Bitmap class.

All Win32 DIBs are aligned to 4-byte (DWORD) memory boundaries. This means that each row of pixels in the DIB is padded with extra bytes to ensure that the next row of pixels starts on a memory boundary that is a multiple of 4-bytes. The Bitmap class takes care of these details. Overloaded array operators are provided to allow the pixel data to be accessed like a 2D array.

Since the Bitmap class makes use of the IPicture COM interface applications using the Bitmap class must link to the olepro32.lib import library.

An earlier version of the Bitmap class originally appeared on flipcode as the DIB24 class.

zip file Download source.

Change History:

5 August 2007.
Updated the grayscale conversion formula to Y = 0.2125R + 0.7154G + 0.0721B. This formula is based on modern CRT and HDTV phosphors and is the same one that Real-Time Rendering Second Edition (Moller and Haines 2002) recommends.

15 October 2006.
Updated the implementation of fill() with a more optimized version. Updated the implementation of resize(). The nearest neighbor sampling filter has been replaced with a bilinear sampling filter. Bilinear sampling provides superior image quality compared to nearest neighbor sampling. However bilinear sampling is slower than nearest neighbor sampling.

30 August 2006.
Added flipHorizontal(), flipVertical(), resize(), and saveTarga() methods. When saving as a Targa (TGA) file the resulting file will always have a color depth of 32-bits. The resize() method currently supports nearest neighbor sampling only. A future version will support bilinear sampling.

10 June 2006.
The Bitmap class' internal pixel depth is now 32 bits per pixel. All existing file importing methods have been updated to perform automatic color conversion to the Bitmap class' new 32-bit pixel depth. A new loadTarga() method had been added. This method allows the importing of 8-bit (grayscale), 24-bit, and 32-bit TGA files.

 
box bottom left corner content box box bottom right corner
logo logo