txlyre 10 months ago
parent
commit
622f0e5df1
2 changed files with 1513 additions and 1504 deletions
  1. 5 3
      counter.c/counter.c
  2. 1508 1501
      counter.c/digits_data.h

+ 5 - 3
counter.c/counter.c

@@ -40,10 +40,10 @@ void counter_create(unsigned long number, FILE *fd) {
     digits[i] = nth_digit(number, digits_count-1-i);
 
   for (int y = 0; y < DIGIT_HEIGHT; y++) {
-    rows[y] = malloc(width * 4);
+    rows[y] = malloc(width);
 
     for (int i = 0; i < digits_count; i++)
-      memcpy(rows[y] + (i * DIGIT_WIDTH * 4), digits_data[digits[i]][y], DIGIT_WIDTH * 4);
+      memcpy(rows[y] + i * DIGIT_WIDTH, digits_data[digits[i]][y], DIGIT_WIDTH);
   }
 
   png_init_io(png, fd);
@@ -53,11 +53,13 @@ void counter_create(unsigned long number, FILE *fd) {
     width,
     DIGIT_HEIGHT,
     8,                 
-    PNG_COLOR_TYPE_RGBA,
+    PNG_COLOR_TYPE_PALETTE,
     PNG_INTERLACE_NONE,
     PNG_COMPRESSION_TYPE_BASE,
     PNG_FILTER_TYPE_BASE
   );
+  png_set_PLTE(png, info, PLTE_data, PLTE_SIZE);
+  png_set_tRNS(png, info, tRNS_data, TRNS_SIZE, NULL);
   png_set_compression_level(png, 1);
   png_write_info(png, info);
   png_write_image(png, rows);

File diff suppressed because it is too large
+ 1508 - 1501
counter.c/digits_data.h


Some files were not shown because too many files changed in this diff