commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1390625 - in /commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging: color/ColorConversions.java formats/bmp/BmpImageParser.java formats/gif/GifImageParser.java formats/jpeg/JpegImageParser.java
Date Wed, 26 Sep 2012 17:54:41 GMT
Author: damjan
Date: Wed Sep 26 17:54:40 2012
New Revision: 1390625

URL: http://svn.apache.org/viewvc?rev=1390625&view=rev
Log:
Various Findbugs cleanups.


Modified:
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/color/ColorConversions.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/color/ColorConversions.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/color/ColorConversions.java?rev=1390625&r1=1390624&r2=1390625&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/color/ColorConversions.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/color/ColorConversions.java
Wed Sep 26 17:54:40 2012
@@ -279,8 +279,18 @@ public abstract class ColorConversions {
 
         double var_Min = Math.min(var_R, Math.min(var_G, var_B)); // Min. value
                                                                   // of RGB
-        double var_Max = Math.max(var_R, Math.max(var_G, var_B)); // Max. value
-                                                                  // of RGB
+        double var_Max;
+        boolean maxIsR = false;
+        boolean maxIsG = false;
+        if (var_R >= var_G && var_R >= var_B) {
+            var_Max = var_R;
+            maxIsR = true;
+        } else if (var_G > var_B) {
+            var_Max = var_G;
+            maxIsG = true;
+        } else {
+            var_Max = var_B;
+        }
         double del_Max = var_Max - var_Min; // Delta RGB value
 
         double L = (var_Max + var_Min) / 2.0;
@@ -307,16 +317,12 @@ public abstract class ColorConversions {
             double del_G = (((var_Max - var_G) / 6) + (del_Max / 2)) / del_Max;
             double del_B = (((var_Max - var_B) / 6) + (del_Max / 2)) / del_Max;
 
-            if (var_R == var_Max)
+            if (maxIsR)
                 H = del_B - del_G;
-            else if (var_G == var_Max)
+            else if (maxIsG)
                 H = (1 / 3.0) + del_R - del_B;
-            else if (var_B == var_Max)
+            else
                 H = (2 / 3.0) + del_G - del_R;
-            else {
-                Debug.debug("uh oh");
-                H = 0; // cmc
-            }
 
             // Debug.debug("H1", H);
 
@@ -388,8 +394,18 @@ public abstract class ColorConversions {
 
         double var_Min = Math.min(var_R, Math.min(var_G, var_B)); // Min. value
                                                                   // of RGB
-        double var_Max = Math.max(var_R, Math.max(var_G, var_B)); // Max. value
-                                                                  // of RGB
+        boolean maxIsR = false;
+        boolean maxIsG = false;
+        double var_Max;
+        if (var_R >= var_G && var_R >= var_B) {
+            var_Max = var_R;
+            maxIsR = true;
+        } else if (var_G > var_B) {
+            var_Max = var_G;
+            maxIsG = true;
+        } else {
+            var_Max = var_B;
+        }
         double del_Max = var_Max - var_Min; // Delta RGB value
 
         double V = var_Max;
@@ -408,16 +424,12 @@ public abstract class ColorConversions {
             double del_G = (((var_Max - var_G) / 6) + (del_Max / 2)) / del_Max;
             double del_B = (((var_Max - var_B) / 6) + (del_Max / 2)) / del_Max;
 
-            if (var_R == var_Max)
+            if (maxIsR)
                 H = del_B - del_G;
-            else if (var_G == var_Max)
+            else if (maxIsG)
                 H = (1 / 3.0) + del_R - del_B;
-            else if (var_B == var_Max)
+            else
                 H = (2 / 3.0) + del_G - del_R;
-            else {
-                Debug.debug("uh oh");
-                H = 0; // cmc;
-            }
 
             if (H < 0)
                 H += 1;

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java?rev=1390625&r1=1390624&r2=1390625&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java
Wed Sep 26 17:54:40 2012
@@ -653,8 +653,6 @@ public class BmpImageParser extends Imag
         pw.println("bmp.dumpImageFile");
 
         ImageInfo imageData = getImageInfo(byteSource, null);
-        if (imageData == null)
-            return false;
 
         imageData.toString(pw, "");
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java?rev=1390625&r1=1390624&r2=1390625&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
Wed Sep 26 17:54:40 2012
@@ -606,27 +606,20 @@ public class GifImageParser extends Imag
             throws ImageReadException, IOException {
         pw.println("gif.dumpImageFile");
 
-        {
-            ImageInfo imageData = getImageInfo(byteSource);
-            if (imageData == null)
-                return false;
-
-            imageData.toString(pw, "");
-        }
-        {
-            ImageContents blocks = readFile(byteSource, false);
-
-            if (blocks == null)
-                return false;
-
-            pw.println("gif.blocks: " + blocks.blocks.size());
-            for (int i = 0; i < blocks.blocks.size(); i++) {
-                GifBlock gifBlock = blocks.blocks.get(i);
-                this.debugNumber(pw, "\t" + i + " ("
-                        + gifBlock.getClass().getName() + ")",
-                        gifBlock.blockCode, 4);
-            }
-
+        ImageInfo imageData = getImageInfo(byteSource);
+        if (imageData == null)
+            return false;
+
+        imageData.toString(pw, "");
+        
+        ImageContents blocks = readFile(byteSource, false);
+
+        pw.println("gif.blocks: " + blocks.blocks.size());
+        for (int i = 0; i < blocks.blocks.size(); i++) {
+            GifBlock gifBlock = blocks.blocks.get(i);
+            this.debugNumber(pw, "\t" + i + " ("
+                    + gifBlock.getClass().getName() + ")",
+                    gifBlock.blockCode, 4);
         }
 
         pw.println("");

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java?rev=1390625&r1=1390624&r2=1390625&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java
Wed Sep 26 17:54:40 2012
@@ -283,8 +283,7 @@ public class JpegImageParser extends Ima
         byte bytes[] = assembleSegments(filtered);
 
         if (debug)
-            System.out.println("bytes" + ": "
-                    + ((bytes == null) ? null : "" + bytes.length));
+            System.out.println("bytes" + ": " + bytes.length);
 
         if (debug)
             System.out.println("");



Mime
View raw message