commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1228802 - in /commons/proper/sanselan/trunk/src: main/java/org/apache/commons/sanselan/color/ColorConversions.java test/java/org/apache/commons/sanselan/color/ColorConversionsTest.java
Date Sun, 08 Jan 2012 06:44:50 GMT
Author: damjan
Date: Sun Jan  8 06:44:49 2012
New Revision: 1228802

URL: http://svn.apache.org/viewvc?rev=1228802&view=rev
Log:
Deleted a test that's wrong by design.

The Adobe and Ghostscript formulas for converting
CMYK to RGB are fundamentally designed to give
different outputs, it is meaningless to test
them against each other and expect the same results.


Modified:
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/color/ColorConversions.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/commons/sanselan/color/ColorConversionsTest.java

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/color/ColorConversions.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/color/ColorConversions.java?rev=1228802&r1=1228801&r2=1228802&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/color/ColorConversions.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/color/ColorConversions.java
Sun Jan  8 06:44:49 2012
@@ -209,6 +209,12 @@ public abstract class ColorConversions
 
     public static final int convertCMYtoRGB(ColorCmy cmy)
     {
+        // From Ghostscript's gdevcdj.c: 
+        // *   Ghostscript:    R = (1.0 - C) * (1.0 - K)
+        // *   Adobe:          R = 1.0 - min(1.0, C + K)
+        // and similarly for G and B.
+        // This is Ghostscript's formula with K = 0.
+        
         //        CMY values = 0 ÷ 1
         //        RGB values = 0 ÷ 255
 
@@ -516,7 +522,7 @@ public abstract class ColorConversions
         return convertRGBtoRGB(R, G, B);
     }
 
-    public static final int convertCMYKtoRGB_old(int sc, int sm, int sy, int sk)
+    public static final int convertCMYKtoRGB_Adobe(int sc, int sm, int sy, int sk)
     //    throws ImageReadException, IOException
     {
         int red = 255 - (sc + sk);

Modified: commons/proper/sanselan/trunk/src/test/java/org/apache/commons/sanselan/color/ColorConversionsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/test/java/org/apache/commons/sanselan/color/ColorConversionsTest.java?rev=1228802&r1=1228801&r2=1228802&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/test/java/org/apache/commons/sanselan/color/ColorConversionsTest.java
(original)
+++ commons/proper/sanselan/trunk/src/test/java/org/apache/commons/sanselan/color/ColorConversionsTest.java
Sun Jan  8 06:44:49 2012
@@ -35,26 +35,6 @@ public class ColorConversionsTest extend
             0xff7f7f7f,
     };
 
-    public void testCMYKtoRGB() throws Exception
-    {
-        for (int C = 0; C <= 256; C += 64)
-        {
-            for (int M = 0; M <= 256; M += 64)
-            {
-                for (int Y = 0; Y <= 256; Y += 64)
-                {
-                    for (int K = 0; K <= 256; K += 64)
-                    {
-                        int rgb1 = ColorConversions.convertCMYKtoRGB(Math.min(255, C), Math.min(255,
M), Math.min(255, Y), Math.min(255, K));
-                        int rgb2 = ColorConversions.convertCMYKtoRGB_old(Math.min(255, C),
Math.min(255, M), Math.min(255, Y), Math.min(255, K));
-                        
-                        assertEquals(new ColorCmyk(C, M, Y, K).toString(), Integer.toHexString(rgb1).toUpperCase(),
Integer.toHexString(rgb2).toUpperCase());
-                    }
-                }
-            }
-        }
-    }
-
     public void testRGBtoCMYK() throws Exception
     {
         for (int i = 0; i < SAMPLE_RGBS.length; i++)



Mime
View raw message