initial commit
[imagesqueeze.git] / src / main / java / eu / svjatoslav / imagesqueeze / codec / Channel.java
1 package eu.svjatoslav.imagesqueeze.codec;
2
3 public class Channel {
4
5         byte [] rangeMap;       
6         byte [] map;
7
8         byte [] decodedRangeMap;
9         byte [] decodedMap;
10
11         int bitCount;
12         
13         public Channel(int width, int height) {
14                 rangeMap = new byte[width * height];
15
16                 map = new byte[width * height];         
17
18                 decodedRangeMap = new byte[width * height];
19                 decodedRangeMap[0] = (byte)255;
20
21                 decodedMap = new byte[width * height];
22         };
23
24         
25         public void reset(){
26                 
27                 for (int i=0; i < decodedMap.length; i++){
28                         decodedMap[i] = 0;
29                 }
30
31                 for (int i=0; i < decodedRangeMap.length; i++){
32                         decodedRangeMap[i] = 0;
33                 }
34                 decodedRangeMap[0] = (byte)255;
35                 
36                 for (int i=0; i < map.length; i++){
37                         map[i] = 0;
38                 }
39
40                 for (int i=0; i < rangeMap.length; i++){
41                         rangeMap[i] = 0;
42                 }
43                 
44                 bitCount = 0;
45         }
46         
47         public void printStatistics(){
48                 float bitsPerPixel = (float)bitCount / (float)rangeMap.length;
49                 System.out.println( (bitCount/8) + " bytes. " + bitsPerPixel + " bits per pixel.");
50         }
51         
52 }