Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Images look completely wrong - color depth problem?

Credits go to Kauhiz, Matthew Leverton, and Richard Phipps for helping out!
This thread is locked; no one can reply to it. rss feed Print
Images look completely wrong - color depth problem?
Michael Faerber
Member #4,800
July 2004
avatar

I'm loading and drawing an image with this code:

// setting up gfx mode
set_colov_conv(COLORCONV_TOTAL);

// ...

banana = load_bitmap("media/banana.pcx", NULL);

// ...

stretch_sprite(buffer, banana, 0, 0, SCREEN_W, SCREEN_H);

However, when it shows the image, all colors are plain wrong. Any idea?

--
"The basic of informatics is Microsoft Office." - An informatics teacher in our school
"Do you know Linux?" "Linux? Isn't that something for visually impaired people?"

Matthew Leverton
Supreme Loser
January 1999
avatar

You are setting color depth, setting the graphics mode, and then loading bitmaps, right?

Michael Faerber
Member #4,800
July 2004
avatar

No - first the graphics mode, then the color depth, then the color conversion, then the bitmaps loading.

--
"The basic of informatics is Microsoft Office." - An informatics teacher in our school
"Do you know Linux?" "Linux? Isn't that something for visually impaired people?"

Richard Phipps
Member #1,632
November 2001
avatar

Do it like this:

     set_color_depth(32);
      if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) != 0) {
         abort_on_error("Couldn't set a 32 bit color resolution");
      }

Kauhiz
Member #4,798
July 2004

You should do it in the order ML said -- color depth first.

edit: beaten by Phipps

---
It's Ridge Racer! RIIIIIDGE RAAAAACER!

Michael Faerber
Member #4,800
July 2004
avatar

Thanks a lot!

I've tried that before, but with set_color_depth(bitmap_color_depth(screen)), which works when called AFTER the gfx initialisation, but crashes when called BEFORE the gfx initialisation.

[EDIT]
I realize now that that was completely stupid.

--
"The basic of informatics is Microsoft Office." - An informatics teacher in our school
"Do you know Linux?" "Linux? Isn't that something for visually impaired people?"

Richard Phipps
Member #1,632
November 2001
avatar

BAF
Member #2,981
December 2002
avatar

desktop_color_depth() gets the desktop's depth.

Go to: