Author: post
Date: 2011-03-07 22:00:50 +0100 (Mon, 07 Mar 2011)
New Revision: 338

Modified:
   RawSpeed/RawImage.cpp
   RawSpeed/RawImage.h
Log:
Add helpers to image function for getting crop information, and add possibility 
for decoders to set individual black levels.

Modified: RawSpeed/RawImage.cpp
===================================================================
--- RawSpeed/RawImage.cpp       2011-03-02 21:26:05 UTC (rev 337)
+++ RawSpeed/RawImage.cpp       2011-03-07 21:00:50 UTC (rev 338)
@@ -33,6 +33,7 @@
     blackLevel(-1), whitePoint(65536),
     dataRefCount(0), data(0), cpp(1),
     uncropped_dim(0, 0) {
+  blackLevelSeparate[0] = blackLevelSeparate[1] = blackLevelSeparate[2] = 
blackLevelSeparate[3] = -1;
   pthread_mutex_init(&mymutex, NULL);
   subsampling.x = subsampling.y = 1;
 }
@@ -42,6 +43,7 @@
     blackLevel(-1), whitePoint(65536),
     dataRefCount(0), data(0), cpp(cpp),
     uncropped_dim(0, 0) {
+  blackLevelSeparate[0] = blackLevelSeparate[1] = blackLevelSeparate[2] = 
blackLevelSeparate[3] = -1;
   subsampling.x = subsampling.y = 1;
   createData();
   pthread_mutex_init(&mymutex, NULL);
@@ -122,6 +124,16 @@
   return &data[y*pitch+x*bpp];
 }
 
+iPoint2D RawImageData::getUncroppedDim()
+{
+  return uncropped_dim;
+}
+
+iPoint2D RawImageData::getCropOffset()
+{
+  return mOffset;
+}
+
 void RawImageData::subFrame(iPoint2D offset, iPoint2D new_size) {
   if (!new_size.isThisInside(dim - offset)) {
     printf("WARNING: RawImageData::subFrame - Attempted to create new subframe 
larger than original size. Crop skipped.\n");
@@ -203,7 +215,7 @@
 void RawImageData::scaleBlackWhite() {
   const int skipBorder = 150;
   int gw = (dim.x - skipBorder) * cpp;
-  if (blackLevel < 0 || whitePoint == 65536) {  // Estimate
+  if ((blackLevelSeparate[0] < 0 && blackLevel < 0) || whitePoint == 65536) {  
// Estimate
     int b = 65536;
     int m = 0;
     for (int row = skipBorder*cpp;row < (dim.y - skipBorder);row++) {
@@ -221,7 +233,10 @@
     printf("Estimated black:%d, Estimated white: %d\n", blackLevel, 
whitePoint);
   }
 
-  calculateBlackAreas();
+  /* If filter has not set separate blacklevel, compute or fetch it */
+  if (blackLevelSeparate[0] < 0)
+    calculateBlackAreas();
+
   int threads = getThreadCount(); 
   if (threads <= 1)
     scaleValues(0, dim.y);

Modified: RawSpeed/RawImage.h
===================================================================
--- RawSpeed/RawImage.h 2011-03-02 21:26:05 UTC (rev 337)
+++ RawSpeed/RawImage.h 2011-03-07 21:00:50 UTC (rev 338)
@@ -45,6 +45,8 @@
   uchar8* getData(uint32 x, uint32 y);    // Not super fast, but safe. Don't 
use per pixel.
   uchar8* getDataUncropped(uint32 x, uint32 y);
   virtual void subFrame( iPoint2D offset, iPoint2D new_size );
+  iPoint2D getUncroppedDim();
+  iPoint2D getCropOffset();
   void scaleBlackWhite();
   bool isCFA;
   ColorFilterArray cfa;


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

Reply via email to