A small bitmap problem

Started by
5 comments, last by Llamasoft.net 23 years, 10 months ago
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
Nick - Head Designer, Llamasoft.net--Visit our website...Llamasoft.netGames, goodies and ingenuity
Advertisement
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
Mad House Software

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

Edited by - Muzzafarath on June 19, 2000 11:20:17 AM
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
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

--
Visit our website...

Llamasoft.net
Games, goodies and ingenuity

Edited by - Llamasoft.net on June 19, 2000 2:25:22 PM
Nick - Head Designer, Llamasoft.net--Visit our website...Llamasoft.netGames, goodies and ingenuity
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
=======================Game project(s):www.fiend.cjb.net
Ok, sorry Muzzafarath, you were right, I got it now
Cheers for the help!

Nick - Head Designer, Llamasoft.net

--
Visit our website...

Llamasoft.net
Games, goodies and ingenuity
Nick - Head Designer, Llamasoft.net--Visit our website...Llamasoft.netGames, goodies and ingenuity
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
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
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

--
Visit our website...

Llamasoft.net
Games, goodies and ingenuity


BeSIt's Da BOMB Baby!!!. o O ~ A little nonsense now and then,is relished by the wisest men~ O o .-- Willy Wonka

This topic is closed to new replies.

Advertisement