diff --git a/source/gif.c b/source/gif.c index 66a63cc..7c73f11 100644 --- a/source/gif.c +++ b/source/gif.c @@ -334,8 +334,7 @@ unsigned char* process_image_descriptor( unsigned char* buffer, */ #define rb (*(buffer++)) -uint32_t* LoadPalette(unsigned char *b, int *paletteSize = NULL) { - unsigned char *buffer = b; +uint32_t* LoadPalette(unsigned char *buffer, int *paletteSize = NULL) { unsigned char header[7]; screen_descriptor_t screen_descriptor; //int color_resolution_bits; @@ -349,10 +348,12 @@ uint32_t* LoadPalette(unsigned char *b, int *paletteSize = NULL) { //color_resolution_bits = ((screen_descriptor.fields & 0x70) >> 4) + 1; //global_color_table = (uint32_t *)calloc(1, 1024); - if (screen_descriptor.fields & 0x80) { + if (screen_descriptor.fields & 0x80) + { global_color_table_size = 1 << (((screen_descriptor.fields & 0x07) + 1)); + if (paletteSize != NULL) *paletteSize = global_color_table_size; - global_color_table = (uint32_t *)malloc(3 * global_color_table_size); + global_color_table = (uint32_t *)malloc(4 * global_color_table_size); //READ(global_color_table, 3 * global_color_table_size); for (int i=0; i