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.
Make sure you call set_color_depth() and set_gfx_mode() before loading your image file.
I did.
Post code. And the image, to make sure.
ok
| 1 | #include <allegro.h> |
| 2 | #include "createeditor.h" |
| 3 | |
| 4 | |
| 5 | |
| 6 | BITMAP* editScreen; |
| 7 | BITMAP* buffer; |
| 8 | bool editorUp = true; |
| 9 | createEditor editor; |
| 10 | |
| 11 | |
| 12 | |
| 13 | int 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 | } |
| 34 | END_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 | */ |
| 9 | class 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 |
| 6 | createEditor::createEditor() |
| 7 | { |
| 8 | // insert your code here |
| 9 | } |
| 10 | |
| 11 | // class destructor |
| 12 | createEditor::~createEditor() |
| 13 | { |
| 14 | // insert your code here |
| 15 | } |
You need to call set_color_depth()before set_gfx_mode();
Thanks a lot! it works now!:)