Re: Bitmap File Format

Search this archive.

From: Sergio Masci (sergio@titan.demon.co.uk)
Date: Sun 09 Jul 2000 - 23:45:13 IDT


> 
> > 
> On Sun, 9 Jul 2000, Sergio Masci wrote:
> 
> > 
> > Before applying the BMP colours to the hardware colour palette (via
> > vga_setpalette) try the following mystical incantation - it may help.
> > svgalib_red   = (bmp_red   >> 2) & 0x3f;
> > svgalib_green = (bmp_green >> 2) & 0x3f;
> > svgalib_blue  = (bmp_blue  >> 2) & 0x3f;
> 
> Thanks.  That worked.  But why?
> 
> 
> -pat


The individual components (RGB) of a colour palette entry are often
stored as 6 bit values (this is hardware dependent and some video cards
use a different number of bits but 6 seems to be the most common). These
6 bits correspond to the most significant bits of the colour so you need
to align the bmp component with the svgalib component (top bit) before
you plug it in. If you do not then you will lose VERY IMPORTANT colour
info from some of your colours. Discarding low end info is not as big a
problem as long you are consistant. As an experiment try disacarding 4
low end bits instead of 2

i.e.

svgalib_x = (bmp_x >> 4) & 0x0f;

or even

svgalib_x = (bmp_x >> 2) & 0x03c;

You still get an infinately better picture than you did before you
applied any alignment.


Regards
Sergio


This archive was generated by hypermail 2.1.4 : Wed 21 Jan 2004 - 22:10:23 IST