understanding palette and BITMAP

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
amirsadig

understanding palette and BITMAP

Post 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);
    }
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:understanding palette and BITMAP

Post 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?
amirsadig

Re:understanding palette and BITMAP

Post 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.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:understanding palette and BITMAP

Post 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.
Post Reply