From bdc1abc4d1d9894ecdc3965ce7f1e69e5f75611c Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Mon, 5 Feb 2024 20:06:20 +0100 Subject: [PATCH] convert with depth --- src/kds_s2000w_image_converter.c | 9 +++++++++ src/kds_s2000w_image_converter.h | 1 + tools/convert.c | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/kds_s2000w_image_converter.c b/src/kds_s2000w_image_converter.c index 3237cad..0ba9c12 100644 --- a/src/kds_s2000w_image_converter.c +++ b/src/kds_s2000w_image_converter.c @@ -17,6 +17,11 @@ void kds_s2000w_convert_terminate() } void kds_s2000w_convert_jpg_to_pnm(blobdata* in, blobdata* out) +{ + kds_s2000w_convert_jpg_to_pnm_With_depth(in, out, -1); +} + +void kds_s2000w_convert_jpg_to_pnm_With_depth(blobdata* in, blobdata* out, int depth) { ExceptionInfo* exception = NULL; Image* input_image = NULL; @@ -39,6 +44,10 @@ void kds_s2000w_convert_jpg_to_pnm(blobdata* in, blobdata* out) exception = AcquireExceptionInfo(); image_info = CloneImageInfo(NULL); strcpy(image_info->filename, "streamout.pnm"); + + if (depth > -1) + SetImageDepth(input_image, depth); + out->data = ImageToBlob(image_info, input_image, &out->size, exception); DestroyImageInfo(image_info); diff --git a/src/kds_s2000w_image_converter.h b/src/kds_s2000w_image_converter.h index f0aed4e..d6baa98 100644 --- a/src/kds_s2000w_image_converter.h +++ b/src/kds_s2000w_image_converter.h @@ -9,4 +9,5 @@ void kds_s2000w_convert_init(); void kds_s2000w_convert_terminate(); void kds_s2000w_convert_jpg_to_pnm(blobdata* in, blobdata* out); +void kds_s2000w_convert_jpg_to_pnm_With_depth(blobdata* in, blobdata* out, int depth); #endif \ No newline at end of file diff --git a/tools/convert.c b/tools/convert.c index 1886348..6d54d9e 100644 --- a/tools/convert.c +++ b/tools/convert.c @@ -33,7 +33,7 @@ int main(int argc, char* argv[]) fptr = NULL; kds_s2000w_convert_init(); - kds_s2000w_convert_jpg_to_pnm(&blob, &output); + kds_s2000w_convert_jpg_to_pnm_With_depth(&blob, &output, 8); kds_s2000w_convert_terminate(); fptr = fopen("output.pnm", "w"); -- 2.39.5