Moved bit input and output streams into Svjatoslav Commons library.
[imagesqueeze.git] / src / main / java / eu / svjatoslav / imagesqueeze / codec / Channel.java
index 879326e..a4f01cc 100755 (executable)
@@ -1,52 +1,61 @@
+/*
+ * Imagesqueeze - Image codec optimized for photos.
+ * Copyright (C) 2012, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public License
+ * as published by the Free Software Foundation.
+ */
+
 package eu.svjatoslav.imagesqueeze.codec;
 
 public class Channel {
 
-       byte [] rangeMap;       
-       byte [] map;
+       byte[] rangeMap;
+       byte[] map;
 
-       byte [] decodedRangeMap;
-       byte [] decodedMap;
+       byte[] decodedRangeMap;
+       byte[] decodedMap;
 
        int bitCount;
-       
-       public Channel(int width, int height) {
+
+       public Channel(final int width, final int height) {
                rangeMap = new byte[width * height];
 
-               map = new byte[width * height];         
+               map = new byte[width * height];
 
                decodedRangeMap = new byte[width * height];
-               decodedRangeMap[0] = (byte)255;
+               decodedRangeMap[0] = (byte) 255;
 
                decodedMap = new byte[width * height];
        };
 
-       
-       public void reset(){
-               
-               for (int i=0; i < decodedMap.length; i++){
+       public void printStatistics() {
+               final float bitsPerPixel = (float) bitCount / (float) rangeMap.length;
+               System.out.println((bitCount / 8) + " bytes. " + bitsPerPixel
+                               + " bits per pixel.");
+       }
+
+       public void reset() {
+
+               for (int i = 0; i < decodedMap.length; i++) {
                        decodedMap[i] = 0;
                }
 
-               for (int i=0; i < decodedRangeMap.length; i++){
+               for (int i = 0; i < decodedRangeMap.length; i++) {
                        decodedRangeMap[i] = 0;
                }
-               decodedRangeMap[0] = (byte)255;
-               
-               for (int i=0; i < map.length; i++){
+               decodedRangeMap[0] = (byte) 255;
+
+               for (int i = 0; i < map.length; i++) {
                        map[i] = 0;
                }
 
-               for (int i=0; i < rangeMap.length; i++){
+               for (int i = 0; i < rangeMap.length; i++) {
                        rangeMap[i] = 0;
                }
-               
+
                bitCount = 0;
        }
-       
-       public void printStatistics(){
-               float bitsPerPixel = (float)bitCount / (float)rangeMap.length;
-               System.out.println( (bitCount/8) + " bytes. " + bitsPerPixel + " bits per pixel.");
-       }
-       
+
 }