From 5898431f0a8cf2edc5e627bd0f2a436035aaf137 Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Sun, 4 Feb 2024 19:42:56 +0100 Subject: [PATCH] add read and write a image file --- src/kds_s2000w_image_converter.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) 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 -- 2.39.5