From 9179b29f7c7c8960f3f5d8307331bbe3c3fdcec6 Mon Sep 17 00:00:00 2001 From: Sebastian Krzyszkowiak Date: Wed, 2 Jun 2021 04:41:33 +0200 Subject: [PATCH] process_pipeline: Handle non-RAW8 images when saving DNG --- src/process_pipeline.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/process_pipeline.c b/src/process_pipeline.c index 8cec510..4ade340 100644 --- a/src/process_pipeline.c +++ b/src/process_pipeline.c @@ -413,7 +413,7 @@ process_image_for_capture(const uint8_t *image, int count) TIFFSetField(tif, TIFFTAG_SUBFILETYPE, 0); TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, mode.width); TIFFSetField(tif, TIFFTAG_IMAGELENGTH, mode.height); - TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8); + TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, mp_pixel_format_bits_per_pixel(mode.pixel_format)); TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_CFA); TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1); TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); @@ -435,9 +435,9 @@ process_image_for_capture(const uint8_t *image, int count) TIFFCheckpointDirectory(tif); printf("Writing frame to %s\n", fname); - unsigned char *pLine = (unsigned char *)malloc(mode.width); + unsigned char *pLine = (unsigned char *)malloc(mp_pixel_format_width_to_bytes(mode.pixel_format, mode.width)); for (int row = 0; row < mode.height; row++) { - TIFFWriteScanline(tif, (void *) image + (row * mode.width), row, 0); + TIFFWriteScanline(tif, (void *) image + (row * mp_pixel_format_width_to_bytes(mode.pixel_format, mode.width)), row, 0); } free(pLine); TIFFWriteDirectory(tif);