@@ -115,7 +115,7 @@ Animation::~Animation()
115115void Animation::next_frame ()
116116{
117117 this ->current_frame_number += 1 ;
118- if (this ->current_frame_number >= this ->frames_order .size ())
118+ if (this ->current_frame_number >= ( int ) this ->frames_order .size ())
119119 {
120120 this ->current_frame_number = 0 ;
121121 }
@@ -147,8 +147,8 @@ bool Animation::read_frames_from_files()
147147
148148 // if a good format is found, proceed to load the files into textures
149149 this ->frames = (GLuint*)malloc (this ->total_frames_files * sizeof (GLuint));
150- this ->frames_pixels = (unsigned char **)malloc (this ->total_frames_files * sizeof (unsigned char *));
151- memset (this ->frames_pixels , 0 , this ->total_frames_files * sizeof (unsigned char *));
150+ this ->frames_pixels = (uint8_t **)malloc (this ->total_frames_files * sizeof (uint8_t *));
151+ memset (this ->frames_pixels , 0 , this ->total_frames_files * sizeof (uint8_t *));
152152 for (int i = 0 ; i < this ->total_frames_files ; i++)
153153 {
154154 if (!this ->LoadImageFromFile (this ->anim_folder + " frame_" + std::to_string (i), i))
@@ -163,7 +163,7 @@ bool Animation::LoadImageFromFile(std::string filename, int file_number)
163163 // Image dimensions
164164 int image_width = 128 ;
165165 int image_height = 64 ;
166- unsigned char * image_data = NULL ;
166+ uint8_t * image_data = NULL ;
167167
168168 if (this ->format == BM )
169169 {
@@ -178,12 +178,12 @@ bool Animation::LoadImageFromFile(std::string filename, int file_number)
178178 fseek (f, 0 , SEEK_END );
179179 int len = ftell (f);
180180 fseek (f, 0 , SEEK_SET );
181- unsigned char * buffer = (unsigned char *)malloc (len+1 );
182- unsigned char * out_buff = (unsigned char *)malloc (1024 );
181+ uint8_t * buffer = (uint8_t *)malloc (len+1 );
182+ uint8_t * out_buff = (uint8_t *)malloc (1024 );
183183 fread (buffer, sizeof (char ), len, f);
184184 fclose (f);
185185
186- unsigned char * good_buffer = NULL ;
186+ uint8_t * good_buffer = NULL ;
187187 if (buffer[0 ] == 1 )
188188 {
189189 // Decompress using lzss heatshrink lib
@@ -202,7 +202,7 @@ bool Animation::LoadImageFromFile(std::string filename, int file_number)
202202 heatshrink_decoder_finish (decoder);
203203 heatshrink_decoder_free (decoder);
204204
205- image_data = (unsigned char *)malloc ((1024 *8 )*4 );
205+ image_data = (uint8_t *)malloc ((1024 *8 )*4 );
206206 int pos = 0 ;
207207 // 1024: (128*64) / 8
208208 int count_bytes = (image_width * image_height) / 8 ;
@@ -239,7 +239,7 @@ bool Animation::LoadImageFromFile(std::string filename, int file_number)
239239 {
240240 good_buffer = buffer + 1 ;
241241
242- image_data = (unsigned char *)malloc ((1024 *8 )*4 );
242+ image_data = (uint8_t *)malloc ((1024 *8 )*4 );
243243 int pos = 0 ;
244244 for (int i = 0 ; i < 1024 ; i++)
245245 {
@@ -354,20 +354,22 @@ void Animation::export_to_bm()
354354
355355 std::string export_path = this ->anim_folder .substr (0 , this ->anim_folder .length () - 1 ) + std::string (" _compiled" );
356356 std::filesystem::create_directory (export_path);
357+ if (std::filesystem::exists (export_path + std::string (" /meta.txt" )))
358+ std::filesystem::remove (export_path + std::string (" /meta.txt" ));
357359 std::filesystem::copy_file (this ->anim_folder + std::string (" meta.txt" ), export_path + std::string (" /meta.txt" ));
358360
359361 int image_width = 128 ;
360362 int image_height = 64 ;
361363
362364 for (int f = 0 ; f < this ->total_frames_files ; f++)
363365 {
364- unsigned char * bm_frame = (unsigned char *)malloc (((image_width * image_height) / 8 ) + 1 );
366+ uint8_t * bm_frame = (uint8_t *)malloc (((image_width * image_height) / 8 ) + 1 );
365367 bm_frame[0 ] = 0 ;
366368 int bm_frame_pos = 1 ;
367369
368370 int L, P;
369371 int pixel_pos = 0 ;
370- unsigned char byte_buffer = 0 ;
372+ uint8_t byte_buffer = 0 ;
371373 int byte_buffer_count = 0 ;
372374 int count_bytes = (image_width * image_height) * 4 ;
373375 for (pixel_pos = 0 ; pixel_pos < count_bytes; pixel_pos+= 4 )
@@ -397,8 +399,9 @@ void Animation::export_to_bm()
397399 byte_buffer_count = 0 ;
398400 }
399401 }
402+ printf (" \n " );
400403 std::ofstream manifest_file;
401- manifest_file.open ((export_path + std::string (" /frame_" ) + std::to_string (f) + std::string (" .bm" )).c_str (), std::ofstream::out | std::ofstream::trunc );
404+ manifest_file.open ((export_path + std::string (" /frame_" ) + std::to_string (f) + std::string (" .bm" )).c_str (), std::ofstream::trunc | std::ofstream::binary );
402405
403406 if (!manifest_file.is_open ()) {
404407 perror (" Error: open frame" );
0 commit comments