Set TIFFTAG_CFAPATTERN depending on pixel format

Add a function to get a CFA pattern string that matches a given
pixel format, and use it to set TIFFTAG_CFAPATTERN on capture.
This commit is contained in:
Yassine Oudjana
2022-01-21 13:36:13 +04:00
parent d8f34f7f89
commit 7b403f2e79
3 changed files with 34 additions and 2 deletions

View File

@@ -488,9 +488,14 @@ process_image_for_capture(const uint8_t *image, int count)
static const short cfapatterndim[] = { 2, 2 };
TIFFSetField(tif, TIFFTAG_CFAREPEATPATTERNDIM, cfapatterndim);
#if (TIFFLIB_VERSION < 20201219) && !LIBTIFF_CFA_PATTERN
TIFFSetField(tif, TIFFTAG_CFAPATTERN, "\002\001\001\000"); // BGGR
TIFFSetField(tif,
TIFFTAG_CFAPATTERN,
mp_pixel_format_cfa_pattern(mode.pixel_format));
#else
TIFFSetField(tif, TIFFTAG_CFAPATTERN, 4, "\002\001\001\000"); // BGGR
TIFFSetField(tif,
TIFFTAG_CFAPATTERN,
4,
mp_pixel_format_cfa_pattern(mode.pixel_format));
#endif
printf("TIFF version %d\n", TIFFLIB_VERSION);
int whitelevel = camera->whitelevel;