|The bitmap transform classes|
|Monday, 22 March 2010|
Page 3 of 3
Pixel format conversion
The FormatConvertedBitmap class does what you might expect - it coverts the pixel format of one bitmap to a specified format.
Notice however that it is much simpler than the ColorConvertedBitmap class which performs a colour conversion taking account of color profiles rather than a format conversion.
The class works in the same way as the other transformation classes. All you have to do is set the Source property to the input bitmap and the DestinationPixel property for the output bitmap. For example:
FormatConvertedBitmap fcb =
This converts the pixel format to gray32 and the result is a grey scale image.
Original and pixel format converted to grey scale
Notice you can't modify the way colors are mapped to grey.
Color space conversion
The ColorConvertedBitmap class takes an object derived from BitmapSource and changes the way that color is represented at each pixel.
It isn't really about changing the pixelformat but about remapping the range of colors used - it really is about changing the color space.
For example, if you have a color bitmap obtained from a scanner that you have a color profile for you can convert its color space so that it displays correctly on an output device that you have a color profile for.
The class already knows about the standard color spaces and can use custom ICC or ICM color profiles.
Windows maintains a set of color profiles for system devices and you can view these using the Color Management tool in the Control Panel.
Profiles can also be downloaded for many printers and display devices - visit the manufacturer's website - and many are installed when you install the device drivers.
You can find most of the color profiles installed in your system in
The ultimate in color management is having a custom profile prepared for a display or a printer by a specialist company using a spectrophotometer.
The ColorConvertedBitmap works in much the same way as the other transformation classes. You simply set the Source property to the bitmap you need to convert and the DestinationFormat which specifies the pixel format of the output bitmap - this can be the same as the input bitmap. In addition you have to specify the color profile of the source and destination bitmap in the SourceColorContext and the DestinationColorContext respectively.
You can specify default color profiles for the pixel formats in use simply by using the pixel formats in the ColorContext constructor. However, in most cases if you are interested in color space conversion you need to make use of profiles. It is also worth noting that some bitmap formats store their ColorContext as part of the file.
For example, suppose that there is a profile for an Epson inkjet printer stored in:
then we can convert a bitmap to this printer's color space using something like:
ColorConvertedBitmap ccb =
The SourceColorContext is set to the default for its pixel format but the DestinationColorContext is set to the profile stored on disk. Notice that the pixel formats are not changed by the conversion.
If you display the result using an Image control on a standard display then the result will look different from the original - but how different depends on the profile and the display device.
Original with default color profile and a printer profile
Color profiling and control is a big subject but essentially if you have color profiles for every display, input device and printer and make use of them when ever you get a bitmap ready for rendering to the device everything should look as good as it possibly can given the limitations of the devices.
|Last Updated ( Monday, 22 March 2010 )|