|
@@ -1,5 +1,6 @@
|
|
|
#include <math.h>
|
|
|
#include <stdlib.h>
|
|
|
+#include <string.h>
|
|
|
#include <png.h>
|
|
|
#include "counter.h"
|
|
|
#include "powers_table.h"
|
|
@@ -16,7 +17,7 @@ static int nth_digit(unsigned long number, int n) {
|
|
|
return (number / powers_table[n][0]) % 10;
|
|
|
}
|
|
|
|
|
|
-void counter_create(unsigned long number, char *filename) {
|
|
|
+void counter_create(unsigned long number, FILE *fd) {
|
|
|
png_structp png;
|
|
|
png_infop info;
|
|
|
|
|
@@ -27,8 +28,6 @@ void counter_create(unsigned long number, char *filename) {
|
|
|
|
|
|
png_byte **rows;
|
|
|
|
|
|
- FILE *fd;
|
|
|
-
|
|
|
png = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
|
|
info = png_create_info_struct(png);
|
|
|
|
|
@@ -47,8 +46,6 @@ void counter_create(unsigned long number, char *filename) {
|
|
|
memcpy(rows[y] + (i * DIGIT_WIDTH * 4), digits_data[digits[i]][y], DIGIT_WIDTH * 4);
|
|
|
}
|
|
|
|
|
|
- fd = fopen(filename, "wb");
|
|
|
-
|
|
|
png_init_io(png, fd);
|
|
|
png_set_IHDR(
|
|
|
png,
|
|
@@ -66,8 +63,6 @@ void counter_create(unsigned long number, char *filename) {
|
|
|
png_write_end(png, info);
|
|
|
png_destroy_write_struct(&png, &info);
|
|
|
|
|
|
- fclose(fd);
|
|
|
-
|
|
|
for (int y = 0; y < DIGIT_HEIGHT; y++)
|
|
|
free(rows[y]);
|
|
|
|