- gif.c modificat

This commit is contained in:
2023-10-12 21:43:08 +02:00
parent 1309e5d7d8
commit a1d3209dd3
3 changed files with 47 additions and 16 deletions

View File

@@ -334,7 +334,8 @@ unsigned char* process_image_descriptor( unsigned char* buffer,
*/
#define rb (*(buffer++))
uint32_t* LoadPalette(unsigned char *buffer) {
uint32_t* LoadPalette(unsigned char *b, int *paletteSize = NULL) {
unsigned char *buffer = b;
unsigned char header[7];
screen_descriptor_t screen_descriptor;
//int color_resolution_bits;
@@ -346,12 +347,12 @@ uint32_t* LoadPalette(unsigned char *buffer) {
READ(&screen_descriptor, 7);
//color_resolution_bits = ((screen_descriptor.fields & 0x70) >> 4) + 1;
global_color_table = (uint32_t *)calloc(1, 1024);
//global_color_table = (uint32_t *)calloc(1, 1024);
if (screen_descriptor.fields & 0x80) {
global_color_table_size = 1 << (((screen_descriptor.fields & 0x07) + 1));
//global_color_table = (rgb *)malloc(3 * global_color_table_size);
if (paletteSize != NULL) *paletteSize = global_color_table_size;
global_color_table = (uint32_t *)malloc(3 * global_color_table_size);
//READ(global_color_table, 3 * global_color_table_size);
for (int i=0; i<global_color_table_size;++i) {
global_color_table[i] = (buffer[0]<<16) + (buffer[1]<<8) + buffer[2];