minor fixes
[imagesqueeze.git] / src / main / java / eu / svjatoslav / imagesqueeze / codec / ImageEncoder.java
index 613064c..7e8af8d 100755 (executable)
@@ -92,16 +92,19 @@ public class ImageEncoder {
                                final int colorBufferIndex = index * 3;
 
                                int blue = pixels[colorBufferIndex];
-                               if (blue < 0)
+                               if (blue < 0) {
                                        blue = blue + 256;
+                               }
 
                                int green = pixels[colorBufferIndex + 1];
-                               if (green < 0)
+                               if (green < 0) {
                                        green = green + 256;
+                               }
 
                                int red = pixels[colorBufferIndex + 2];
-                               if (red < 0)
+                               if (red < 0) {
                                        red = red + 256;
+                               }
 
                                color.r = red;
                                color.g = green;
@@ -184,10 +187,12 @@ public class ImageEncoder {
                                final int decodedDifference = decodeValueFromGivenBits(
                                                bitEncodedDifference, computedRange, computedBitCount);
                                int decodedValue = averageDecodedValue - decodedDifference;
-                               if (decodedValue > 255)
+                               if (decodedValue > 255) {
                                        decodedValue = 255;
-                               if (decodedValue < 0)
+                               }
+                               if (decodedValue < 0) {
                                        decodedValue = 0;
+                               }
 
                                decodedMap[index] = (byte) decodedValue;
                        } else {
@@ -219,8 +224,9 @@ public class ImageEncoder {
                rangeGridSquare(step / 2, 0, step);
                rangeGridSquare(0, step / 2, step);
 
-               if (step > 2)
+               if (step > 2) {
                        rangeGrid(step / 2);
+               }
        }
 
        public void rangeGridDiagonal(final int offsetX, final int offsetY,
@@ -275,8 +281,9 @@ public class ImageEncoder {
                rangeRoundGridSquare(step / 2, 0, step);
                rangeRoundGridSquare(0, step / 2, step);
 
-               if (step < 1024)
+               if (step < 1024) {
                        rangeRoundGrid(step * 2);
+               }
        }
 
        public void rangeRoundGridDiagonal(final int offsetX, final int offsetY,
@@ -370,8 +377,9 @@ public class ImageEncoder {
                saveGridSquare(step / 2, 0, step);
                saveGridSquare(0, step / 2, step);
 
-               if (step > 2)
+               if (step > 2) {
                        saveGrid(step / 2);
+               }
        }
 
        public void saveGridDiagonal(final int offsetX, final int offsetY,
@@ -464,8 +472,9 @@ public class ImageEncoder {
 
        public static int byteToInt(final byte input) {
                int result = input;
-               if (result < 0)
+               if (result < 0) {
                        result = result + 256;
+               }
                return result;
        }
 
@@ -496,8 +505,9 @@ public class ImageEncoder {
                        int decodedValue = (range * encodedValue)
                                        / realvalueForThisBitcount;
 
-                       if (decodedValue > range)
+                       if (decodedValue > range) {
                                decodedValue = range;
+                       }
 
                        if (negativeBit == 0) {
                                return decodedValue;
@@ -529,15 +539,17 @@ public class ImageEncoder {
                        // still one or more bits left, encode value as precisely as
                        // possible
 
-                       if (value > range)
+                       if (value > range) {
                                value = range;
+                       }
 
                        final int realvalueForThisBitcount = 1 << remainingBitCount;
                        // int valueMultiplier = range / realvalueForThisBitcount;
                        int encodedValue = (value * realvalueForThisBitcount) / range;
 
-                       if (encodedValue >= realvalueForThisBitcount)
+                       if (encodedValue >= realvalueForThisBitcount) {
                                encodedValue = realvalueForThisBitcount - 1;
+                       }
 
                        encodedValue = (encodedValue << 1) + negativeBit;