The new vbAccelerator Site - more VB and .NET Code and Controls
Source Code
4 vbMedia &nbsp
 Colour Depth Control
 Reduce the number of colours in an image and save bitmaps at the correct colour depth

 NOTE: this code has been superceded by the version at the new site.


Colour Depth Reduction Sample

Download the Colour Depth demonstration project (50kb)


A VB StdPicture object can be passed to the SavePicture method in order to save it as a bitmap file on disk. However, this method will usually save bitmaps at the system colour depth, and you cannot specify whether you want to save to a different colour depth.

This sample shows how to colour reduce a DIBSection object using two different techniques and save that to a bitmap file at the correct colour depth.

Saving Bitmaps
The Bitmap file format, unlike compressed formats such as PNG and GIF, is straightforward:



   If NumColors       array[0 to NumColors-1] of RGBQUAD structures
   End If

   Bitmap Bits, scan-aligned to a DWORD boundary.

&nbsp &nbsp

About  Contribute  Send Feedback  Privacy

Copyright © 1998-1999, Steve McMahon ( All Rights Reserved.
Last updated: 15 November 1999.   First Published: 15 November 1999.