Author: post
Date: 2010-01-18 18:34:50 +0100 (Mon, 18 Jan 2010)
New Revision: 188

Modified:
   RawSpeed/DngDecoder.cpp
Log:
DNG: More relaxed whitelevel reading, plus use defaults.

Modified: RawSpeed/DngDecoder.cpp
===================================================================
--- RawSpeed/DngDecoder.cpp     2010-01-18 17:24:38 UTC (rev 187)
+++ RawSpeed/DngDecoder.cpp     2010-01-18 17:34:50 UTC (rev 188)
@@ -334,10 +334,23 @@
       }
     }
   }
-  mRaw->whitePoint = raw->getEntry(WHITELEVEL)->getInt();
+
   new_size = mRaw->dim;
 
-  int black = -1; // Estimate, if no blacklevel
+  // Default white level is (2 ** BitsPerSample) - 1
+  mRaw->whitePoint = (1 >> raw->getEntry(BITSPERSAMPLE)->getShort()) - 1;
+  // Black defaults to 0
+  int black = 0; 
+
+  if (raw->hasEntry(WHITELEVEL)) {
+    TiffEntry *whitelevel = raw->getEntry(WHITELEVEL);
+    if (whitelevel->type == TIFF_LONG)
+      mRaw->whitePoint = whitelevel->getInt();
+    else if (whitelevel->type == TIFF_SHORT)
+      mRaw->whitePoint = whitelevel->getShort();
+  }
+
+
   if (raw->hasEntry(BLACKLEVELREPEATDIM)) {
     black = 65536;
     const gushort *blackdim = 
raw->getEntry(BLACKLEVELREPEATDIM)->getShortArray();


_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit

Reply via email to