]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
add write image from blob
authorBastian Dehn <hhaalo@arcor.de>
Sun, 4 Feb 2024 19:59:44 +0000 (20:59 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 4 Feb 2024 19:59:44 +0000 (20:59 +0100)
src/kds_s2000w_image_converter.c
tools/convert.c

index b889ce1a82d29748e48a30923e4e75546ba6e50d..25da8a68bb743c1b03a6f37609c5ee3ac1beeee0 100644 (file)
@@ -16,10 +16,8 @@ void kds_s2000w_convert_terminate()
        MagickCoreTerminus();
 }
 
-void kds_s2000w_convert_jpg_to_pnm(const char* filename)
+void kds_s2000w_convert_jpg_to_pnm(void* blob, size_t size)
 {
-       printf("open input_image file: %s\n", filename);
-
        ExceptionInfo* exception = NULL;
        Image* input_image = NULL;
        Image* output_image = NULL;
@@ -27,8 +25,9 @@ void kds_s2000w_convert_jpg_to_pnm(const char* filename)
 
        exception = AcquireExceptionInfo();
        image_info = CloneImageInfo(NULL);
-       strcpy(image_info->filename, filename);
-       input_image = ReadImage(image_info, exception);
+       const char* streamname = "stream.jpg";
+       strcpy(image_info->filename, streamname);
+       input_image = BlobToImage(image_info, blob, size , exception);
 
        if (exception->severity != UndefinedException)
                CatchException(exception);
index 19d9132da0e40919f30370bac406b3cb58076375..2f057100ebd002371bf12e213c46a42975999b57 100644 (file)
@@ -5,7 +5,7 @@
 int main(int argc, char* argv[])
 {
        FILE* fptr = NULL;
-       int size = 0;
+       size_t size = 0;
        char* buf = malloc(sizeof(char));
 
        fptr = fopen("test.jpg", "r");
@@ -21,12 +21,11 @@ int main(int argc, char* argv[])
        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_jpg_to_pnm(buf, size);
        kds_s2000w_convert_terminate();
+
+       free(buf);
+       buf = NULL;
        return 0;
 }
\ No newline at end of file