]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
refactor image converter
authorBastian Dehn <hhaalo@arcor.de>
Thu, 1 Aug 2024 07:42:56 +0000 (09:42 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Thu, 1 Aug 2024 07:42:56 +0000 (09:42 +0200)
src/kds_s2000w_image_converter.c

index 42d6cb1f33d672b5f5e2f845322655a8c8c1473b..ef36412926fff40c7bc69d438deba0d3918d2847 100644 (file)
@@ -18,13 +18,9 @@ void kds_s2000w_convert_to_pnm_with_depth(blobdata* in,
 #ifndef NODEBUG
        debug_printf(ALL, "kds_s2000w_convert_to_pnm_With_depth");
 #endif
-       
-       ExceptionInfo* exception = NULL;
-       Image* input_image = NULL;
-       ImageInfo* image_info = NULL;
 
-       exception = AcquireExceptionInfo();
-       image_info = CloneImageInfo(NULL);
+       ExceptionInfo* exception = AcquireExceptionInfo();
+       ImageInfo* image_info = CloneImageInfo(NULL);
 
        sprintf(image_info->filename, "streamin.%s", format);
 
@@ -32,7 +28,7 @@ void kds_s2000w_convert_to_pnm_with_depth(blobdata* in,
        debug_printf(DEBUG, image_info->filename);
 #endif
 
-       input_image = BlobToImage(image_info, in->data, in->size , exception);
+       Image* input_image = BlobToImage(image_info, in->data, in->size , exception);
 
        if (exception->severity != UndefinedException) {
                fprintf(stderr, "%s\n", GetExceptionMessage(exception->error_number));
@@ -59,8 +55,11 @@ void kds_s2000w_convert_to_pnm_with_depth(blobdata* in,
        out->data = ImageToBlob(image_info, input_image, &out->size, exception);
 
        DestroyImageInfo(image_info);
+       image_info = NULL;
        DestroyImage(input_image);
+       input_image = NULL;
        DestroyExceptionInfo(exception);
+       exception = NULL;
 }
 
 void kds_s2000w_convert_jpg_to_pnm_with_depth(blobdata* in, blobdata* out, int depth)
@@ -89,15 +88,11 @@ void kds_s2000w_metadata_from_image(blobdata* image, image_metadata* mdata)
        debug_printf(ALL, "kds_s2000w_metadata_from_image");
 #endif
 
-       ExceptionInfo* exception = NULL;
-       Image* input_image = NULL;
-       ImageInfo* image_info = NULL;
-
-       exception = AcquireExceptionInfo();
-       image_info = CloneImageInfo(NULL);
+       ExceptionInfo* exception = AcquireExceptionInfo();
+       ImageInfo* image_info = CloneImageInfo(NULL);
        sprintf(image_info->filename, "image.pnm");
 
-       input_image = BlobToImage(image_info, image->data, image->size , exception);
+       Image* input_image = BlobToImage(image_info, image->data, image->size , exception);
 
        if (exception->severity != UndefinedException) {
                fprintf(stderr, "%s\n", GetExceptionMessage(exception->error_number));
@@ -109,6 +104,9 @@ void kds_s2000w_metadata_from_image(blobdata* image, image_metadata* mdata)
        mdata->depth = input_image->depth;
 
        DestroyImageInfo(image_info);
+       image_info = NULL;
        DestroyImage(input_image);
+       input_image = NULL;
        DestroyExceptionInfo(exception);
+       exception = NULL;
 }
\ No newline at end of file