Page 1 of 1

understanding palette and BITMAP

Posted: Wed Jun 23, 2004 1:35 pm
by amirsadig
I have searched for seting palette when running in 32 bit based modem but does not find nothing good for me.

could someone put here some link about understanding palette.

I have a small BMP file, which I want to draw it. the problem it is 8 bit BMP. every byte is an index on the palette. when plotting the bitmap I convert the index to its color, but I see the picture not as origin.

getting palette:

Code: Select all

for(i=0;i<256;i++)
    {

      b=fgetc(file);
      g=fgetc(file);
      r=fgetc(file);
      palette[i][0] = 0;
      palette[i][1] = b;
      palette[i][2] = g;
      palette[i][3] = r;
      fgetc(file);
    }

Re:understanding palette and BITMAP

Posted: Wed Jun 23, 2004 2:53 pm
by Candy
amirsadig wrote: I have a small BMP file, which I want to draw it. the problem it is 8 bit BMP. every byte is an index on the palette. when plotting the bitmap I convert the index to its color, but I see the picture not as origin.
What sort of BMP file? What code do you use to read it? (the full code with surrounding calls etc) How do you convert from index to palette color? What do you get?

Re:understanding palette and BITMAP

Posted: Wed Jun 23, 2004 3:55 pm
by amirsadig
it is a windows BMP. I load the file with my FAT driver.
I have found how to change 8 bit BMB to 32 bit.
you know 8 bit BMP has 255 color each color has R G B. those color included in palette table on file, which normal I can send it VGA register via IO Port. but because I run 32 bit Video Mode, I save the palette on an array of [256][4]. every pixel saved on file, tell us which color of the 256 to use.

Re:understanding palette and BITMAP

Posted: Thu Jun 24, 2004 1:17 am
by Pype.Clicker
you may like "www.wotsit.org" for any file format information and the HardWareVga category in the FAQ should point you towards VGA information repository that will provide you all the theory about VGA registers and palette setting.

Very basically, you can see the palette as a collection of colors which you will refer to in your picture (using a 4 or 8 bits index), much in the way of colours[] array in our previous discussion, except that it's performed in hardware.

For immediate code snippets, see google: VGA palette tutorial result.