From: Bastian Dehn Date: Sun, 4 Feb 2024 19:46:45 +0000 (+0100) Subject: read a test file into memory X-Git-Tag: v1.0.0^2~344^2~11 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=422255a4722fa12c48ce2016cdf1c1e309af2c6f;p=sane-kds-s2000w-net.git read a test file into memory --- diff --git a/tools/convert.c b/tools/convert.c index 565385a..19d9132 100644 --- a/tools/convert.c +++ b/tools/convert.c @@ -1,8 +1,30 @@ #include +#include #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();