sixel: use 64-bit cdetails variables #1391

pull/1407/head
nick black 4 years ago
parent 948749c1bc
commit 6debae3906
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -21,15 +21,15 @@ typedef struct colortable {
} colortable; } colortable;
typedef struct cdetails { typedef struct cdetails {
uint32_t sums[3]; int64_t sums[3];
int32_t count; int64_t count;
} cdetails; } cdetails;
// second pass: construct data for extracted colors over the sixels // second pass: construct data for extracted colors over the sixels
typedef struct sixeltable { typedef struct sixeltable {
colortable* ctab; colortable* ctab;
unsigned char* data; // |colors|x|sixelcount|-byte arrays unsigned char* data; // |maxcolors|x|sixelcount|-byte arrays
cdetails* deets; // |colors| cdetails* deets; // |maxcolors| cdetails structures
int sixelcount; int sixelcount;
} sixeltable; } sixeltable;
@ -194,9 +194,10 @@ write_sixel_data(FILE* fp, int lenx, sixeltable* stab){
int count = stab->deets[idx].count; int count = stab->deets[idx].count;
//fprintf(stderr, "RGB: %3u %3u %3u DT: %d SUMS: %3d %3d %3d COUNT: %d\n", rgb[0], rgb[1], rgb[2], idx, stab->deets[idx].sums[0] / count * 100 / 255, stab->deets[idx].sums[1] / count * 100 / 255, stab->deets[idx].sums[2] / count * 100 / 255, count); //fprintf(stderr, "RGB: %3u %3u %3u DT: %d SUMS: %3d %3d %3d COUNT: %d\n", rgb[0], rgb[1], rgb[2], idx, stab->deets[idx].sums[0] / count * 100 / 255, stab->deets[idx].sums[1] / count * 100 / 255, stab->deets[idx].sums[2] / count * 100 / 255, count);
//fprintf(fp, "#%d;2;%u;%u;%u", i, rgb[0], rgb[1], rgb[2]); //fprintf(fp, "#%d;2;%u;%u;%u", i, rgb[0], rgb[1], rgb[2]);
fprintf(fp, "#%d;2;%u;%u;%u", i, stab->deets[idx].sums[0] / count * 100 / 255, fprintf(fp, "#%d;2;%jd;%jd;%jd", i,
stab->deets[idx].sums[1] / count * 100 / 255, (intmax_t)(stab->deets[idx].sums[0] * 100 / count / 255),
stab->deets[idx].sums[2] / count * 100 / 255); (intmax_t)(stab->deets[idx].sums[1] * 100 / count / 255),
(intmax_t)(stab->deets[idx].sums[2] * 100 / count / 255));
} }
int p = 0; int p = 0;
while(p < stab->sixelcount){ while(p < stab->sixelcount){

Loading…
Cancel
Save