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