X-Git-Url: http://www2.svjatoslav.eu/gitweb/?p=imagesqueeze.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Fimagesqueeze%2Fcodec%2FChannel.java;h=68e731589eeb1224a88322c47e82c61a0b5f55ad;hp=879326e803602e4b891c71dfd107d69c958e9e20;hb=HEAD;hpb=c7d0b8e1723045c0df086d9214a35f54db47684c diff --git a/src/main/java/eu/svjatoslav/imagesqueeze/codec/Channel.java b/src/main/java/eu/svjatoslav/imagesqueeze/codec/Channel.java index 879326e..68e7315 100755 --- a/src/main/java/eu/svjatoslav/imagesqueeze/codec/Channel.java +++ b/src/main/java/eu/svjatoslav/imagesqueeze/codec/Channel.java @@ -1,52 +1,56 @@ +/* + * Image codec. Author: Svjatoslav Agejenko, svjatoslav@svjatoslav.eu + * This project is released under Creative Commons Zero (CC0) license. + */ package eu.svjatoslav.imagesqueeze.codec; -public class Channel { - - byte [] rangeMap; - byte [] map; - - byte [] decodedRangeMap; - byte [] decodedMap; - - int bitCount; - - public Channel(int width, int height) { - rangeMap = new byte[width * height]; - - map = new byte[width * height]; - - decodedRangeMap = new byte[width * height]; - decodedRangeMap[0] = (byte)255; - - decodedMap = new byte[width * height]; - }; - - - public void reset(){ - - for (int i=0; i < decodedMap.length; i++){ - decodedMap[i] = 0; - } - - for (int i=0; i < decodedRangeMap.length; i++){ - decodedRangeMap[i] = 0; - } - decodedRangeMap[0] = (byte)255; - - for (int i=0; i < map.length; i++){ - map[i] = 0; - } - - 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."); - } - +class Channel { + + final byte[] rangeMap; + final byte[] map; + + final byte[] decodedRangeMap; + final byte[] decodedMap; + + int bitCount; + + public Channel(final int width, final int height) { + rangeMap = new byte[width * height]; + + map = new byte[width * height]; + + decodedRangeMap = new byte[width * height]; + decodedRangeMap[0] = (byte) 255; + + decodedMap = new byte[width * height]; + } + + 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++) { + decodedRangeMap[i] = 0; + } + decodedRangeMap[0] = (byte) 255; + + for (int i = 0; i < map.length; i++) { + map[i] = 0; + } + + for (int i = 0; i < rangeMap.length; i++) { + rangeMap[i] = 0; + } + + bitCount = 0; + } + }