#### Archived

This topic is now archived and is closed to further replies.

# A small bitmap problem

This topic is 6388 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey guys, I was just fiddling in DJGPP / Allegro, and decided to try and make a tilemap reading thing (sorry i''m not too hot on terminoligy ). I''d never tried it really before, but I now have a working program that displays my tiles fine... the only problem is, the palette... It''s totally, totally wrong! I have only just started fiddling with allegro, but the problem seems to lie with when loading bitmaps... I have to supply a bitmap, and an RGB palette value; load_bmp(char *filename, RGB *pal). The filename is no problem, but does anyone know what the hell i put as the RGB value? Yes ok that''s Red Green Blue, but that''s about all I can figure... I tried putting 0, and the pallete comes our horribley wrong (grey is red, blue is grey...). I tried putting other numbers, too, but most gave me a compilation error (i''ll tell you later if necessary, but atm i''m in a hurry ). So, simply, does anyone know what the best value to put as the RGB value when loading a bitmap, that gives me the proper colours, as opposed to lurid hybrid messes Cheers all, Nick - Head Designer, Llamasoft.net -- Visit our website... Llamasoft.net Games, goodies and ingenuity

##### Share on other sites
When an Allegro function wants a RGB pointer, just pass them a PALETTE. Example:

  PALETTE your_pal;BITMAP *tiles;// Load bitmap and palettetiles = load_bitmap("yourbmp.bmp", your_pal);// Set the paletteset_palette(your_pal);

If yourbmp.bmp is a 256 color bitmap, the colors should come up correctly.

The PALETTE struct/typedef/whatever is weird, I have looked through allegro.h and Allegro's source files, but I have never found the definition of PALETTE... But as long as it works

/. Muzzafarath

Edited by - Muzzafarath on June 19, 2000 11:10:52 AM

Edited by - Muzzafarath on June 19, 2000 11:20:17 AM

##### Share on other sites
Thanks, Muzzafarath, but I still can't get it working ... In your example, you declare your PALETTE as your_pal, and then use it, but what do you 'do' to your_pal? I can't believe you simply declare it and then pass it as the RGB value, and in fact I tired that, and it didn't work... I tried things like allegro's desktop_pallete too, but my colours are still completely wrong... I am using an 8bit 256 colour bitmap, and I know the palette indexes are being read correctley, but it just comes out wrong... As i said, grey is red, red is green, blue is grey... Also, black is white, white is black, and yet brown is also white...
Ahem
Any other ideas?

Nick - Head Designer, Llamasoft.net

--

Llamasoft.net
Games, goodies and ingenuity

Edited by - Llamasoft.net on June 19, 2000 2:25:22 PM

##### Share on other sites
Ok, in what program do you make your bitmap''s?
some programs use a strange RGB system (GRB or something)

and did u initialize the gfx_mode correctly?

  set_gfx_mode(GFX_AUTODETECT,320,200,0,0);

But my solution would be using 16 bit colors instead of 8...

========================
Game project(s):
www.fiend.cjb.net

##### Share on other sites
Ok, sorry Muzzafarath, you were right, I got it now
Cheers for the help!

Nick - Head Designer, Llamasoft.net

--

Llamasoft.net
Games, goodies and ingenuity

##### Share on other sites
This method uses the pallete the the image is attached to. If you have multiple images (with different palletes) your palletes will once again be screwed up. In this case you need to convert all of your images to one pallete that all of your images will use. then you load and set that pallete which in Allegro is very easy.

JoeMont001@aol.com

##### Share on other sites
What was your problem, and how did you fix it?

quote:
Original post by Llamasoft.net

Ok, sorry Muzzafarath, you were right, I got it now
Cheers for the help!

Nick - Head Designer, Llamasoft.net

--

Llamasoft.net
Games, goodies and ingenuity

• ### Forum Statistics

• Total Topics
628728
• Total Posts
2984418

• 25
• 11
• 10
• 16
• 14