[Rawstudio-commit] rawspeed r57 - RawSpeed

Klaus Post klauspost at gmail.com
Sun Feb 8 12:48:04 CET 2009


Author: post
Date: 2009-02-08 12:48:04 +0100 (Sun, 08 Feb 2009)
New Revision: 57

Modified:
   RawSpeed/rawstudio-plugin-api.cpp
Log:
- Remove unneeded blit, copy while correcting black&scale instead.
- Don't collect min, max information all the way to the left side of image.
- "Fix" Compiler warnings.
- Proper indentation (Rawstudio style :)

Modified: RawSpeed/rawstudio-plugin-api.cpp
===================================================================
--- RawSpeed/rawstudio-plugin-api.cpp	2009-02-08 11:46:08 UTC (rev 56)
+++ RawSpeed/rawstudio-plugin-api.cpp	2009-02-08 11:48:04 UTC (rev 57)
@@ -54,7 +54,7 @@
 
 			GTimer *gt = g_timer_new();
 			d->decodeRaw();
-      d->decodeMetaData();
+			d->decodeMetaData();
 			printf("%s: %.03f\n", filename, g_timer_elapsed(gt, NULL));
 			g_timer_destroy(gt);
 
@@ -64,37 +64,23 @@
 			RawImage r = d->mRaw;
 
 			cpp = r->getCpp();
-      if (cpp == 1) {
-			  image = rs_image16_new(r->dim.x, r->dim.y, cpp, cpp);
-			  BitBlt((guchar *) GET_PIXEL(image, 0, 0), image->pitch*2*cpp, r->getData(), r->pitch, r->dim.x*r->bpp, r->dim.y);
-      } else if (cpp == 3) {
-        image = rs_image16_new(r->dim.x, r->dim.y, 3, 4);
-        for(row=0;row<image->h;row++)
-        {
-          gushort *inpixel = (gushort*)&r->getData()[row*r->pitch];
-          gushort *outpixel = GET_PIXEL(image, 0, row);
-          for(col=0;col<image->w;col++)
-          {
-            *outpixel++ =  *inpixel++;
-            *outpixel++ =  *inpixel++;
-            *outpixel++ =  *inpixel++;
-             outpixel++;
-          }
-        }
-        
-      } else {
-        printf("Unsupported component per pixel count");
-        return NULL;
-      }
+			if (cpp == 1) 
+				image = rs_image16_new(r->dim.x, r->dim.y, cpp, cpp);
+			else if (cpp == 3) 
+				image = rs_image16_new(r->dim.x, r->dim.y, 3, 4);
+			else {
+				printf("Unsupported component per pixel count");
+				return NULL;
+			}
 
-			if (cpp==1)
+			if (r->isCFA)
 				image->filters = r->cfa.getDcrawFilter();
 
 			/* Calculate black and white point */
 			for(row=100;row<image->h-100;row++)
 			{
-				gushort *pixel = GET_PIXEL(image, 100, row);
-				for(col=100;col<image->w*cpp-100;col++)
+				gushort *pixel = (gushort*)&r->getData()[row*r->pitch+100*r->bpp];
+				for(col=100*cpp;col<(image->w-200)*cpp;col++)
 				{
 					max = MAX(*pixel, max);
 					black = MIN(*pixel, black);
@@ -105,14 +91,31 @@
 			shift = (gint) (16.0-log((gdouble) max)/log(2.0));
 
 			/* Apply black and whitepoint */
-			for(row=0;row<image->h;row++)
+			if ( cpp == 1 ) 
 			{
-				gushort *pixel = GET_PIXEL(image, 0, row);
-				for(col=0;col<image->w*cpp;col++)
+				for(row=0;row<image->h;row++)
 				{
-					*pixel =  clampbits(((gint)*pixel-black)<<shift,16);
-					pixel++;
+					gushort *inpixel = (gushort*)&r->getData()[row*r->pitch];
+					gushort *outpixel = GET_PIXEL(image, 0, row);
+					for(col=0;col<image->w;col++)
+					{
+						*outpixel++ =  clampbits(((gint)(*inpixel++)-black)<<shift,16);
+					}
 				}
+			} else if (cpp == 3) 
+			{
+				for(row=0;row<image->h;row++)
+				{
+					gushort *inpixel = (gushort*)&r->getData()[row*r->pitch];
+					gushort *outpixel = GET_PIXEL(image, 0, row);
+					for(col=0;col<image->w;col++)
+					{
+						*outpixel++ =  clampbits(((gint)(*inpixel++)-black)<<shift,16);
+						*outpixel++ =  clampbits(((gint)(*inpixel++)-black)<<shift,16);
+						*outpixel++ =  clampbits(((gint)(*inpixel++)-black)<<shift,16);
+						outpixel++;
+					}
+				}
 			}
 		}
 		catch (RawDecoderException e)




More information about the Rawstudio-commit mailing list