]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
change jpg gray convert with pnm
authorBastian Dehn <hhaalo@arcor.de>
Wed, 29 Jan 2025 17:14:51 +0000 (18:14 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Wed, 29 Jan 2025 17:14:51 +0000 (18:14 +0100)
src/kds_s2000w_image_converter_netpbm.c

index 30e662d79f27b5d5d25f91af8cbff1e044c3f365..9dffe0fdc9167011a09d3149ddd36ff23c753ec1 100644 (file)
@@ -190,15 +190,17 @@ void _kds_s2000w_image_gray_jpg_to_pnm(j_decompress_ptr cinfo,
        }
        fclose(jpeg_stream);
 
-       gray** pixels = malloc(sizeof(gray*) * cinfo->output_height);
+       xel** pixels = malloc(sizeof(xel*) * cinfo->output_height);
        for (int i = 0; i < cinfo->output_height; i++) {
-               pixels[i] = malloc(sizeof(gray) * cinfo->output_width);
+               pixels[i] = malloc(sizeof(xel) * cinfo->output_width);
        }
 
        int currwidth = 0;
        int currheight = 0;
        for (int i = 0; i < decompress_size; i += GRAY) {
-               pixels[currheight][currwidth] = decompress_data[i];
+               pixels[currheight][currwidth].r = 0;
+               pixels[currheight][currwidth].g = 0;
+               pixels[currheight][currwidth].b = decompress_data[i];
                currwidth++;
                if (currwidth >= cinfo->output_width) {
                        currwidth = 0;
@@ -206,7 +208,7 @@ void _kds_s2000w_image_gray_jpg_to_pnm(j_decompress_ptr cinfo,
                }
        }
 
-       pgm_writepgm(pnm_stream, pixels, cinfo->output_width, cinfo->output_height, PNM_MAXMAXVAL, 0);
+       pnm_writepnm(pnm_stream, pixels, cinfo->output_width, cinfo->output_height, PGM_MAXMAXVAL, PGM_FORMAT, 0);
 
        for (int i = 0; i < cinfo->output_height; i++) {
                free(pixels[i]);