]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
read a test file into memory
authorBastian Dehn <hhaalo@arcor.de>
Sun, 4 Feb 2024 19:46:45 +0000 (20:46 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 4 Feb 2024 19:46:45 +0000 (20:46 +0100)
tools/convert.c

index 565385a9449aa1ce7259155da6d77d1d94736b85..19d9132da0e40919f30370bac406b3cb58076375 100644 (file)
@@ -1,8 +1,30 @@
 #include <stdio.h>
+#include <stdlib.h>
 #include "../src/kds_s2000w_image_converter.h"
 
 int main(int argc, char* argv[])
 {
+       FILE* fptr = NULL;
+       int size = 0;
+       char* buf = malloc(sizeof(char));
+
+       fptr = fopen("test.jpg", "r");
+       while(fread(buf, sizeof(char), 1, fptr)) {
+               size++;
+       }
+       fseek(fptr, 0L, SEEK_SET);
+       printf("file size in bufs: %i\n", size);
+       free(buf);
+       buf = NULL;
+
+       buf = malloc(sizeof(char) * size);
+       fread(buf, size, 1, fptr);
+       fclose(fptr);
+
+       free(buf);
+       buf = NULL;
+       return 0;
+
        kds_s2000w_convert_init();
        kds_s2000w_convert_jpg_to_pnm("test.jpg");
        kds_s2000w_convert_terminate();