Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Importing bitmaps? I dunno about this palette stuff...

Credits go to LennyLen for helping out!
This thread is locked; no one can reply to it. rss feed Print
Importing bitmaps? I dunno about this palette stuff...
7 kilos
Member #8,154
December 2006

I am importing a bitmap, and I don't understand all this palette stuff.

My file is NOT 256 color, it is 32 bit. How would I get it into my program? I've set the color mode, but when I try to blit it to the screen, I get a 256 color image.

???

__________________________________________________
"The game I'm making is a mmrpg" quoted from piccolo

Matthew Leverton
Supreme Loser
January 1999
avatar

Make sure you call set_color_depth() and set_gfx_mode() before loading your image file.

7 kilos
Member #8,154
December 2006

I did.

__________________________________________________
"The game I'm making is a mmrpg" quoted from piccolo

gnolam
Member #2,030
March 2002
avatar

Post code. And the image, to make sure.

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

7 kilos
Member #8,154
December 2006

ok

1#include <allegro.h>
2#include "createeditor.h"
3 
4 
5 
6BITMAP* editScreen;
7BITMAP* buffer;
8bool editorUp = true;
9createEditor editor;
10 
11 
12 
13int main()
14{
15 allegro_init();
16 install_keyboard();
17 set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640,480, 0,0);
18 set_color_depth(32);
19 PALLETE pal;
20 get_palette(pal);
21 editScreen = load_bitmap("editor.bmp", NULL);
22
23
24 while (!key[KEY_ESC])
25 {
26 if (editorUp == true)
27 {
28 blit(editScreen, screen, 0, 0, 0, 0, 640, 480);
29 }
30 }
31 destroy_bitmap(editScreen);
32 return 0;
33}
34END_OF_MAIN();

1// Class automatically generated by Dev-C++ New Class wizard
2 
3#ifndef CREATEEDITOR_H
4#define CREATEEDITOR_H
5 
6/*
7 * No description
8 */
9class createEditor
10{
11 public:
12 // class constructor
13 createEditor();
14 // class destructor
15 ~createEditor();
16};
17 
18#endif // CREATEEDITOR_H

1// Class automatically generated by Dev-C++ New Class wizard
2 
3#include "createeditor.h" // class's header file
4 
5// class constructor
6createEditor::createEditor()
7{
8 // insert your code here
9}
10 
11// class destructor
12createEditor::~createEditor()
13{
14 // insert your code here
15}

__________________________________________________
"The game I'm making is a mmrpg" quoted from piccolo

LennyLen
Member #5,313
December 2004
avatar

You need to call set_color_depth()before set_gfx_mode();

7 kilos
Member #8,154
December 2006

Thanks a lot! it works now!:)

__________________________________________________
"The game I'm making is a mmrpg" quoted from piccolo

Go to: