Prechádzať zdrojové kódy

Set whitelevel in DNG output

Martijn Braam 1 rok pred
rodič
commit
99cf36ddeb
2 zmenil súbory, kde vykonal 4 pridanie a 1 odobranie
  1. 1 0
      include/libdng.h
  2. 3 1
      src/libdng.c

+ 1 - 0
include/libdng.h

@@ -21,6 +21,7 @@ typedef struct {
 		float neutral[3];
 		float analogbalance[3];
 		uint8_t cfapattern[4];
+		uint32_t whitelevel;
 
 		// Calibration data
 		float color_matrix_1[9];

+ 3 - 1
src/libdng.c

@@ -69,6 +69,7 @@ libdng_set_mode_from_index(libdng_info *dng, int index)
 	dng->cfapattern[3] = (cfa >> 0) & 0xFF;
 	dng->needs_repack = dng_mode_needs_repack(index);
 	dng->bit_depth = dng_bitdepth_from_mode(index);
+	dng->whitelevel = (1 << dng->bit_depth) - 1;
 	return 1;
 }
 
@@ -268,8 +269,9 @@ libdng_write(libdng_info *dng, const char *path, unsigned int width, unsigned in
 	TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
 	TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT);
 	TIFFSetField(tif, TIFFTAG_CFAREPEATPATTERNDIM, 2, dng->bayer_pattern_dimensions);
-	TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
+	TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, dng->bit_depth);
 	TIFFSetField(tif, DNGTAG_CFAPATTERN, 4, dng->cfapattern);
+	TIFFSetField(tif, DNGTAG_WHITELEVEL, 1, &dng->whitelevel);
 
 	unsigned int stride = width;
 	for (int row = 0; row < height; row++) {