[Digikam-devel] extragear/graphics/digikam/libs/dimg/filters

Marcel Wiesweg marcel.wiesweg at gmx.de
Tue Feb 21 15:37:42 GMT 2006


SVN commit 512021 by mwiesweg:

digikam from trunk: rounding error of BCG modifier

With the current algorithm, even setting a gamma of 1.0 would create
changes, (x / 255.0) * 255.0 might be slightly less than x, so casting
this value to int would result in an error of 1.
I hope using the round() function is a correct fix for this,
at least the 1.0 value now creates a proper x=y mapping.



 M  +2 -2      bcgmodifier.cpp


--- trunk/extragear/graphics/digikam/libs/dimg/filters/bcgmodifier.cpp
 #512020:512021 @@ -152,7 +152,7 @@

     for (int i=0; i<65536; i++)
     {
-        val2 = (int)(pow(((double)d->map16[i] / 65535), (1 / val)) * 65535);
+        val2 = (int)round(pow(((double)d->map16[i] / 65535), (1 / val)) *
 65535); if (d->overIndicator && val2 > 65535)
             d->map16[i] = -1;
         else
@@ -161,7 +161,7 @@

     for (int i=0; i<256; i++)
     {
-        val2 = (int)(pow(((double)d->map[i] / 255), (1 / val)) * 255);
+        val2 = (int)round(pow(((double)d->map[i] / 255), (1 / val)) * 255);
         if (d->overIndicator && val2 > 255)
             d->map[i] = -1;
         else

-------------------------------------------------------



More information about the Digikam-devel mailing list