From: Bastian Dehn Date: Sun, 4 Feb 2024 18:42:56 +0000 (+0100) Subject: add read and write a image file X-Git-Tag: v1.0.0^2~344^2~14 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=5898431f0a8cf2edc5e627bd0f2a436035aaf137;p=sane-kds-s2000w-net.git add read and write a image file --- diff --git a/src/kds_s2000w_image_converter.c b/src/kds_s2000w_image_converter.c index 9ef396c..7607b8d 100644 --- a/src/kds_s2000w_image_converter.c +++ b/src/kds_s2000w_image_converter.c @@ -1,4 +1,5 @@ #include +#include #include #include "kds_s2000w_image_converter.h" @@ -14,5 +15,31 @@ void kds_s2000w_convert_terminate() void kds_s2000w_convert_jpg_to_pnm(const char* filename) { - printf("open image file: %s\n", filename); + printf("open input_image file: %s\n", filename); + + ExceptionInfo* exception = NULL; + Image* input_image = NULL; + Image* output_image = NULL; + ImageInfo* image_info = NULL; + + exception = AcquireExceptionInfo(); + image_info = CloneImageInfo(NULL); + strcpy(image_info->filename, filename); + input_image = ReadImage(image_info, exception); + + if (exception->severity != UndefinedException) + CatchException(exception); + if (input_image == NULL) + exit(1); + + DestroyImageInfo(image_info); + DestroyExceptionInfo(exception); + exception = AcquireExceptionInfo(); + image_info = CloneImageInfo(NULL); + strcpy(image_info->filename, "output_test.jpg"); + WriteImages(image_info, input_image, "output.jpg", exception); + + DestroyImageInfo(image_info); + DestroyImage(input_image); + DestroyExceptionInfo(exception); } \ No newline at end of file