![]() |
|
al_save_bitmap not working! |
Don Freeman
Member #5,110
October 2004
![]() |
I'm trying to convert some images for my game's assets but for some reason al_save_bitmap is not working. I have called al_init_image_addon during startup. Below is the offending code: 1oid ConvertUnitSmallImages( void )
2{
3 ALLEGRO_BITMAP *tmp = al_create_bitmap(320,128);
4 if ( !tmp )
5 return;
6 for ( UInt type = 0; type < 18; type++ )
7 {
8 ALLEGRO_STATE state;
9 al_store_state(&state,ALLEGRO_STATE_TARGET_BITMAP);
10 al_set_target_bitmap(tmp);
11 al_clear_to_color(al_map_rgb(255,0,255));
12 UInt x = 0;
13 UInt y = 0;
14 for ( UInt direction = 0; direction < 4; direction++ )
15 {
16 for ( UInt side = 0; side < 7; side++ )
17 {
18 for ( UInt frame = 0; frame < 2; frame++ )
19 {
20 DrawSmallUnitEx(type,side,direction,frame,x,y,32,32,0);
21 x+=32;
22 }
23 }
24 y+=32;
25 x = 0;
26 }
27 al_restore_state(&state);
28 al_draw_bitmap(tmp,0,0,0);
29 al_flip_display();
30 String fileName = "./gfx/Units/Small/New/";
31 fileName+=g_UnitFileNames[type];
32 fileName+="N.bmp";
33 if ( al_save_bitmap(fileName.c_str(),tmp) )
34 std::cout<<"Image saved to: "<<fileName<<"\n";
35 else
36 std::cout<<"Image NOT saved: "<<fileName<<"\n";
37 }
38 al_destroy_bitmap(tmp);
39 tmp = NULL;
40}
41///////////////////////////////////////////////////////////////////////////////
-- |
SiegeLord
Member #7,827
October 2006
![]() |
Does the /gfx/Units/Small/New/ exist? Also, try making a file using al_fopen(fileName.c_str(), "w") and see if that returns a non-NULL. "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
Don Freeman
Member #5,110
October 2004
![]() |
Both give an error. And yes, gfx/Units/Small/New exists. I've even tried to run as administrator thinking write permissions, but still can't. Edit: Edit 2: -- |
|