Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 43475CF65 for ; Sat, 26 May 2012 15:35:33 +0000 (UTC) Received: (qmail 17935 invoked by uid 500); 26 May 2012 15:35:33 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 17863 invoked by uid 500); 26 May 2012 15:35:33 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 17855 invoked by uid 99); 26 May 2012 15:35:32 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 26 May 2012 15:35:32 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 26 May 2012 15:35:29 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 45CAC2388BA4 for ; Sat, 26 May 2012 15:35:09 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1342914 [5/5] - in /commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging: ./ color/ common/ common/bytesource/ common/itu_t4/ common/mylzw/ Date: Sat, 26 May 2012 15:35:06 -0000 To: commits@commons.apache.org From: damjan@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120526153509.45CAC2388BA4@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/itu_t4/T4_T6_Tables.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/itu_t4/T4_T6_Tables.java?rev=1342914&r1=1342913&r2=1342914&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/itu_t4/T4_T6_Tables.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/itu_t4/T4_T6_Tables.java Sat May 26 15:35:04 2012 @@ -22,12 +22,12 @@ class T4_T6_Tables { public static class Entry { String bitString; Integer value; - + public Entry(String bitString, Integer value) { this.bitString = bitString; this.value = value; } - + public void writeBits(BitArrayOutputStream outputStream) { for (int i = 0; i < bitString.length(); i++) { if (bitString.charAt(i) == '0') { @@ -38,225 +38,228 @@ class T4_T6_Tables { } } } - + public static final Entry[] whiteTerminatingCodes = { - new Entry("00110101", Integer.valueOf(0)), - new Entry("000111", Integer.valueOf(1)), - new Entry("0111", Integer.valueOf(2)), - new Entry("1000", Integer.valueOf(3)), - new Entry("1011", Integer.valueOf(4)), - new Entry("1100", Integer.valueOf(5)), - new Entry("1110", Integer.valueOf(6)), - new Entry("1111", Integer.valueOf(7)), - new Entry("10011", Integer.valueOf(8)), - new Entry("10100", Integer.valueOf(9)), - new Entry("00111", Integer.valueOf(10)), - new Entry("01000", Integer.valueOf(11)), - new Entry("001000", Integer.valueOf(12)), - new Entry("000011", Integer.valueOf(13)), - new Entry("110100", Integer.valueOf(14)), - new Entry("110101", Integer.valueOf(15)), - new Entry("101010", Integer.valueOf(16)), - new Entry("101011", Integer.valueOf(17)), - new Entry("0100111", Integer.valueOf(18)), - new Entry("0001100", Integer.valueOf(19)), - new Entry("0001000", Integer.valueOf(20)), - new Entry("0010111", Integer.valueOf(21)), - new Entry("0000011", Integer.valueOf(22)), - new Entry("0000100", Integer.valueOf(23)), - new Entry("0101000", Integer.valueOf(24)), - new Entry("0101011", Integer.valueOf(25)), - new Entry("0010011", Integer.valueOf(26)), - new Entry("0100100", Integer.valueOf(27)), - new Entry("0011000", Integer.valueOf(28)), - new Entry("00000010", Integer.valueOf(29)), - new Entry("00000011", Integer.valueOf(30)), - new Entry("00011010", Integer.valueOf(31)), - new Entry("00011011", Integer.valueOf(32)), - new Entry("00010010", Integer.valueOf(33)), - new Entry("00010011", Integer.valueOf(34)), - new Entry("00010100", Integer.valueOf(35)), - new Entry("00010101", Integer.valueOf(36)), - new Entry("00010110", Integer.valueOf(37)), - new Entry("00010111", Integer.valueOf(38)), - new Entry("00101000", Integer.valueOf(39)), - new Entry("00101001", Integer.valueOf(40)), - new Entry("00101010", Integer.valueOf(41)), - new Entry("00101011", Integer.valueOf(42)), - new Entry("00101100", Integer.valueOf(43)), - new Entry("00101101", Integer.valueOf(44)), - new Entry("00000100", Integer.valueOf(45)), - new Entry("00000101", Integer.valueOf(46)), - new Entry("00001010", Integer.valueOf(47)), - new Entry("00001011", Integer.valueOf(48)), - new Entry("01010010", Integer.valueOf(49)), - new Entry("01010011", Integer.valueOf(50)), - new Entry("01010100", Integer.valueOf(51)), - new Entry("01010101", Integer.valueOf(52)), - new Entry("00100100", Integer.valueOf(53)), - new Entry("00100101", Integer.valueOf(54)), - new Entry("01011000", Integer.valueOf(55)), - new Entry("01011001", Integer.valueOf(56)), - new Entry("01011010", Integer.valueOf(57)), - new Entry("01011011", Integer.valueOf(58)), - new Entry("01001010", Integer.valueOf(59)), - new Entry("01001011", Integer.valueOf(60)), - new Entry("00110010", Integer.valueOf(61)), - new Entry("00110011", Integer.valueOf(62)), - new Entry("00110100", Integer.valueOf(63)), - }; - + new Entry("00110101", Integer.valueOf(0)), + new Entry("000111", Integer.valueOf(1)), + new Entry("0111", Integer.valueOf(2)), + new Entry("1000", Integer.valueOf(3)), + new Entry("1011", Integer.valueOf(4)), + new Entry("1100", Integer.valueOf(5)), + new Entry("1110", Integer.valueOf(6)), + new Entry("1111", Integer.valueOf(7)), + new Entry("10011", Integer.valueOf(8)), + new Entry("10100", Integer.valueOf(9)), + new Entry("00111", Integer.valueOf(10)), + new Entry("01000", Integer.valueOf(11)), + new Entry("001000", Integer.valueOf(12)), + new Entry("000011", Integer.valueOf(13)), + new Entry("110100", Integer.valueOf(14)), + new Entry("110101", Integer.valueOf(15)), + new Entry("101010", Integer.valueOf(16)), + new Entry("101011", Integer.valueOf(17)), + new Entry("0100111", Integer.valueOf(18)), + new Entry("0001100", Integer.valueOf(19)), + new Entry("0001000", Integer.valueOf(20)), + new Entry("0010111", Integer.valueOf(21)), + new Entry("0000011", Integer.valueOf(22)), + new Entry("0000100", Integer.valueOf(23)), + new Entry("0101000", Integer.valueOf(24)), + new Entry("0101011", Integer.valueOf(25)), + new Entry("0010011", Integer.valueOf(26)), + new Entry("0100100", Integer.valueOf(27)), + new Entry("0011000", Integer.valueOf(28)), + new Entry("00000010", Integer.valueOf(29)), + new Entry("00000011", Integer.valueOf(30)), + new Entry("00011010", Integer.valueOf(31)), + new Entry("00011011", Integer.valueOf(32)), + new Entry("00010010", Integer.valueOf(33)), + new Entry("00010011", Integer.valueOf(34)), + new Entry("00010100", Integer.valueOf(35)), + new Entry("00010101", Integer.valueOf(36)), + new Entry("00010110", Integer.valueOf(37)), + new Entry("00010111", Integer.valueOf(38)), + new Entry("00101000", Integer.valueOf(39)), + new Entry("00101001", Integer.valueOf(40)), + new Entry("00101010", Integer.valueOf(41)), + new Entry("00101011", Integer.valueOf(42)), + new Entry("00101100", Integer.valueOf(43)), + new Entry("00101101", Integer.valueOf(44)), + new Entry("00000100", Integer.valueOf(45)), + new Entry("00000101", Integer.valueOf(46)), + new Entry("00001010", Integer.valueOf(47)), + new Entry("00001011", Integer.valueOf(48)), + new Entry("01010010", Integer.valueOf(49)), + new Entry("01010011", Integer.valueOf(50)), + new Entry("01010100", Integer.valueOf(51)), + new Entry("01010101", Integer.valueOf(52)), + new Entry("00100100", Integer.valueOf(53)), + new Entry("00100101", Integer.valueOf(54)), + new Entry("01011000", Integer.valueOf(55)), + new Entry("01011001", Integer.valueOf(56)), + new Entry("01011010", Integer.valueOf(57)), + new Entry("01011011", Integer.valueOf(58)), + new Entry("01001010", Integer.valueOf(59)), + new Entry("01001011", Integer.valueOf(60)), + new Entry("00110010", Integer.valueOf(61)), + new Entry("00110011", Integer.valueOf(62)), + new Entry("00110100", Integer.valueOf(63)), }; + public static final Entry[] blackTerminatingCodes = { - new Entry("0000110111", Integer.valueOf(0)), - new Entry("010", Integer.valueOf(1)), - new Entry("11", Integer.valueOf(2)), - new Entry("10", Integer.valueOf(3)), - new Entry("011", Integer.valueOf(4)), - new Entry("0011", Integer.valueOf(5)), - new Entry("0010", Integer.valueOf(6)), - new Entry("00011", Integer.valueOf(7)), - new Entry("000101", Integer.valueOf(8)), - new Entry("000100", Integer.valueOf(9)), - new Entry("0000100", Integer.valueOf(10)), - new Entry("0000101", Integer.valueOf(11)), - new Entry("0000111", Integer.valueOf(12)), - new Entry("00000100", Integer.valueOf(13)), - new Entry("00000111", Integer.valueOf(14)), - new Entry("000011000", Integer.valueOf(15)), - new Entry("0000010111", Integer.valueOf(16)), - new Entry("0000011000", Integer.valueOf(17)), - new Entry("0000001000", Integer.valueOf(18)), - new Entry("00001100111", Integer.valueOf(19)), - new Entry("00001101000", Integer.valueOf(20)), - new Entry("00001101100", Integer.valueOf(21)), - new Entry("00000110111", Integer.valueOf(22)), - new Entry("00000101000", Integer.valueOf(23)), - new Entry("00000010111", Integer.valueOf(24)), - new Entry("00000011000", Integer.valueOf(25)), - new Entry("000011001010", Integer.valueOf(26)), - new Entry("000011001011", Integer.valueOf(27)), - new Entry("000011001100", Integer.valueOf(28)), - new Entry("000011001101", Integer.valueOf(29)), - new Entry("000001101000", Integer.valueOf(30)), - new Entry("000001101001", Integer.valueOf(31)), - new Entry("000001101010", Integer.valueOf(32)), - new Entry("000001101011", Integer.valueOf(33)), - new Entry("000011010010", Integer.valueOf(34)), - new Entry("000011010011", Integer.valueOf(35)), - new Entry("000011010100", Integer.valueOf(36)), - new Entry("000011010101", Integer.valueOf(37)), - new Entry("000011010110", Integer.valueOf(38)), - new Entry("000011010111", Integer.valueOf(39)), - new Entry("000001101100", Integer.valueOf(40)), - new Entry("000001101101", Integer.valueOf(41)), - new Entry("000011011010", Integer.valueOf(42)), - new Entry("000011011011", Integer.valueOf(43)), - new Entry("000001010100", Integer.valueOf(44)), - new Entry("000001010101", Integer.valueOf(45)), - new Entry("000001010110", Integer.valueOf(46)), - new Entry("000001010111", Integer.valueOf(47)), - new Entry("000001100100", Integer.valueOf(48)), - new Entry("000001100101", Integer.valueOf(49)), - new Entry("000001010010", Integer.valueOf(50)), - new Entry("000001010011", Integer.valueOf(51)), - new Entry("000000100100", Integer.valueOf(52)), - new Entry("000000110111", Integer.valueOf(53)), - new Entry("000000111000", Integer.valueOf(54)), - new Entry("000000100111", Integer.valueOf(55)), - new Entry("000000101000", Integer.valueOf(56)), - new Entry("000001011000", Integer.valueOf(57)), - new Entry("000001011001", Integer.valueOf(58)), - new Entry("000000101011", Integer.valueOf(59)), - new Entry("000000101100", Integer.valueOf(60)), - new Entry("000001011010", Integer.valueOf(61)), - new Entry("000001100110", Integer.valueOf(62)), - new Entry("000001100111", Integer.valueOf(63)), - }; - + new Entry("0000110111", Integer.valueOf(0)), + new Entry("010", Integer.valueOf(1)), + new Entry("11", Integer.valueOf(2)), + new Entry("10", Integer.valueOf(3)), + new Entry("011", Integer.valueOf(4)), + new Entry("0011", Integer.valueOf(5)), + new Entry("0010", Integer.valueOf(6)), + new Entry("00011", Integer.valueOf(7)), + new Entry("000101", Integer.valueOf(8)), + new Entry("000100", Integer.valueOf(9)), + new Entry("0000100", Integer.valueOf(10)), + new Entry("0000101", Integer.valueOf(11)), + new Entry("0000111", Integer.valueOf(12)), + new Entry("00000100", Integer.valueOf(13)), + new Entry("00000111", Integer.valueOf(14)), + new Entry("000011000", Integer.valueOf(15)), + new Entry("0000010111", Integer.valueOf(16)), + new Entry("0000011000", Integer.valueOf(17)), + new Entry("0000001000", Integer.valueOf(18)), + new Entry("00001100111", Integer.valueOf(19)), + new Entry("00001101000", Integer.valueOf(20)), + new Entry("00001101100", Integer.valueOf(21)), + new Entry("00000110111", Integer.valueOf(22)), + new Entry("00000101000", Integer.valueOf(23)), + new Entry("00000010111", Integer.valueOf(24)), + new Entry("00000011000", Integer.valueOf(25)), + new Entry("000011001010", Integer.valueOf(26)), + new Entry("000011001011", Integer.valueOf(27)), + new Entry("000011001100", Integer.valueOf(28)), + new Entry("000011001101", Integer.valueOf(29)), + new Entry("000001101000", Integer.valueOf(30)), + new Entry("000001101001", Integer.valueOf(31)), + new Entry("000001101010", Integer.valueOf(32)), + new Entry("000001101011", Integer.valueOf(33)), + new Entry("000011010010", Integer.valueOf(34)), + new Entry("000011010011", Integer.valueOf(35)), + new Entry("000011010100", Integer.valueOf(36)), + new Entry("000011010101", Integer.valueOf(37)), + new Entry("000011010110", Integer.valueOf(38)), + new Entry("000011010111", Integer.valueOf(39)), + new Entry("000001101100", Integer.valueOf(40)), + new Entry("000001101101", Integer.valueOf(41)), + new Entry("000011011010", Integer.valueOf(42)), + new Entry("000011011011", Integer.valueOf(43)), + new Entry("000001010100", Integer.valueOf(44)), + new Entry("000001010101", Integer.valueOf(45)), + new Entry("000001010110", Integer.valueOf(46)), + new Entry("000001010111", Integer.valueOf(47)), + new Entry("000001100100", Integer.valueOf(48)), + new Entry("000001100101", Integer.valueOf(49)), + new Entry("000001010010", Integer.valueOf(50)), + new Entry("000001010011", Integer.valueOf(51)), + new Entry("000000100100", Integer.valueOf(52)), + new Entry("000000110111", Integer.valueOf(53)), + new Entry("000000111000", Integer.valueOf(54)), + new Entry("000000100111", Integer.valueOf(55)), + new Entry("000000101000", Integer.valueOf(56)), + new Entry("000001011000", Integer.valueOf(57)), + new Entry("000001011001", Integer.valueOf(58)), + new Entry("000000101011", Integer.valueOf(59)), + new Entry("000000101100", Integer.valueOf(60)), + new Entry("000001011010", Integer.valueOf(61)), + new Entry("000001100110", Integer.valueOf(62)), + new Entry("000001100111", Integer.valueOf(63)), }; + public static final Entry[] whiteMakeUpCodes = { - new Entry("11011", Integer.valueOf(64)), - new Entry("10010", Integer.valueOf(128)), - new Entry("010111", Integer.valueOf(192)), - new Entry("0110111", Integer.valueOf(256)), - new Entry("00110110", Integer.valueOf(320)), - new Entry("00110111", Integer.valueOf(384)), - new Entry("01100100", Integer.valueOf(448)), - new Entry("01100101", Integer.valueOf(512)), - new Entry("01101000", Integer.valueOf(576)), - new Entry("01100111", Integer.valueOf(640)), - new Entry("011001100", Integer.valueOf(704)), - new Entry("011001101", Integer.valueOf(768)), - new Entry("011010010", Integer.valueOf(832)), - new Entry("011010011", Integer.valueOf(896)), - new Entry("011010100", Integer.valueOf(960)), - new Entry("011010101", Integer.valueOf(1024)), - new Entry("011010110", Integer.valueOf(1088)), - new Entry("011010111", Integer.valueOf(1152)), - new Entry("011011000", Integer.valueOf(1216)), - new Entry("011011001", Integer.valueOf(1280)), - new Entry("011011010", Integer.valueOf(1344)), - new Entry("011011011", Integer.valueOf(1408)), - new Entry("010011000", Integer.valueOf(1472)), - new Entry("010011001", Integer.valueOf(1536)), - new Entry("010011010", Integer.valueOf(1600)), - new Entry("011000", Integer.valueOf(1664)), - new Entry("010011011", Integer.valueOf(1728)), - }; - + new Entry("11011", Integer.valueOf(64)), + new Entry("10010", Integer.valueOf(128)), + new Entry("010111", Integer.valueOf(192)), + new Entry("0110111", Integer.valueOf(256)), + new Entry("00110110", Integer.valueOf(320)), + new Entry("00110111", Integer.valueOf(384)), + new Entry("01100100", Integer.valueOf(448)), + new Entry("01100101", Integer.valueOf(512)), + new Entry("01101000", Integer.valueOf(576)), + new Entry("01100111", Integer.valueOf(640)), + new Entry("011001100", Integer.valueOf(704)), + new Entry("011001101", Integer.valueOf(768)), + new Entry("011010010", Integer.valueOf(832)), + new Entry("011010011", Integer.valueOf(896)), + new Entry("011010100", Integer.valueOf(960)), + new Entry("011010101", Integer.valueOf(1024)), + new Entry("011010110", Integer.valueOf(1088)), + new Entry("011010111", Integer.valueOf(1152)), + new Entry("011011000", Integer.valueOf(1216)), + new Entry("011011001", Integer.valueOf(1280)), + new Entry("011011010", Integer.valueOf(1344)), + new Entry("011011011", Integer.valueOf(1408)), + new Entry("010011000", Integer.valueOf(1472)), + new Entry("010011001", Integer.valueOf(1536)), + new Entry("010011010", Integer.valueOf(1600)), + new Entry("011000", Integer.valueOf(1664)), + new Entry("010011011", Integer.valueOf(1728)), }; + public static final Entry[] blackMakeUpCodes = { - new Entry("0000001111", Integer.valueOf(64)), - new Entry("000011001000", Integer.valueOf(128)), - new Entry("000011001001", Integer.valueOf(192)), - new Entry("000001011011", Integer.valueOf(256)), - new Entry("000000110011", Integer.valueOf(320)), - new Entry("000000110100", Integer.valueOf(384)), - new Entry("000000110101", Integer.valueOf(448)), - new Entry("0000001101100", Integer.valueOf(512)), - new Entry("0000001101101", Integer.valueOf(576)), - new Entry("0000001001010", Integer.valueOf(640)), - new Entry("0000001001011", Integer.valueOf(704)), - new Entry("0000001001100", Integer.valueOf(768)), - new Entry("0000001001101", Integer.valueOf(832)), - new Entry("0000001110010", Integer.valueOf(896)), - new Entry("0000001110011", Integer.valueOf(960)), - new Entry("0000001110100", Integer.valueOf(1024)), - new Entry("0000001110101", Integer.valueOf(1088)), - new Entry("0000001110110", Integer.valueOf(1152)), - new Entry("0000001110111", Integer.valueOf(1216)), - new Entry("0000001010010", Integer.valueOf(1280)), - new Entry("0000001010011", Integer.valueOf(1344)), - new Entry("0000001010100", Integer.valueOf(1408)), - new Entry("0000001010101", Integer.valueOf(1472)), - new Entry("0000001011010", Integer.valueOf(1536)), - new Entry("0000001011011", Integer.valueOf(1600)), - new Entry("0000001100100", Integer.valueOf(1664)), - new Entry("0000001100101", Integer.valueOf(1728)), - }; - + new Entry("0000001111", Integer.valueOf(64)), + new Entry("000011001000", Integer.valueOf(128)), + new Entry("000011001001", Integer.valueOf(192)), + new Entry("000001011011", Integer.valueOf(256)), + new Entry("000000110011", Integer.valueOf(320)), + new Entry("000000110100", Integer.valueOf(384)), + new Entry("000000110101", Integer.valueOf(448)), + new Entry("0000001101100", Integer.valueOf(512)), + new Entry("0000001101101", Integer.valueOf(576)), + new Entry("0000001001010", Integer.valueOf(640)), + new Entry("0000001001011", Integer.valueOf(704)), + new Entry("0000001001100", Integer.valueOf(768)), + new Entry("0000001001101", Integer.valueOf(832)), + new Entry("0000001110010", Integer.valueOf(896)), + new Entry("0000001110011", Integer.valueOf(960)), + new Entry("0000001110100", Integer.valueOf(1024)), + new Entry("0000001110101", Integer.valueOf(1088)), + new Entry("0000001110110", Integer.valueOf(1152)), + new Entry("0000001110111", Integer.valueOf(1216)), + new Entry("0000001010010", Integer.valueOf(1280)), + new Entry("0000001010011", Integer.valueOf(1344)), + new Entry("0000001010100", Integer.valueOf(1408)), + new Entry("0000001010101", Integer.valueOf(1472)), + new Entry("0000001011010", Integer.valueOf(1536)), + new Entry("0000001011011", Integer.valueOf(1600)), + new Entry("0000001100100", Integer.valueOf(1664)), + new Entry("0000001100101", Integer.valueOf(1728)), }; + public static final Entry[] additionalMakeUpCodes = { - new Entry("00000001000", Integer.valueOf(1792)), - new Entry("00000001100", Integer.valueOf(1856)), - new Entry("00000001101", Integer.valueOf(1920)), - new Entry("000000010010", Integer.valueOf(1984)), - new Entry("000000010011", Integer.valueOf(2048)), - new Entry("000000010100", Integer.valueOf(2112)), - new Entry("000000010101", Integer.valueOf(2176)), - new Entry("000000010110", Integer.valueOf(2240)), - new Entry("000000010111", Integer.valueOf(2304)), - new Entry("000000011100", Integer.valueOf(2368)), - new Entry("000000011101", Integer.valueOf(2432)), - new Entry("000000011110", Integer.valueOf(2496)), - new Entry("000000011111", Integer.valueOf(2560)), - }; - - public static final Entry EOL = new Entry("000000000001", Integer.valueOf(0)); - public static final Entry EOL13 = new Entry("0000000000001", Integer.valueOf(0)); - public static final Entry EOL14 = new Entry("00000000000001", Integer.valueOf(0)); - public static final Entry EOL15 = new Entry("000000000000001", Integer.valueOf(0)); - public static final Entry EOL16 = new Entry("0000000000000001", Integer.valueOf(0)); - public static final Entry EOL17 = new Entry("00000000000000001", Integer.valueOf(0)); - public static final Entry EOL18 = new Entry("000000000000000001", Integer.valueOf(0)); - public static final Entry EOL19 = new Entry("0000000000000000001", Integer.valueOf(0)); + new Entry("00000001000", Integer.valueOf(1792)), + new Entry("00000001100", Integer.valueOf(1856)), + new Entry("00000001101", Integer.valueOf(1920)), + new Entry("000000010010", Integer.valueOf(1984)), + new Entry("000000010011", Integer.valueOf(2048)), + new Entry("000000010100", Integer.valueOf(2112)), + new Entry("000000010101", Integer.valueOf(2176)), + new Entry("000000010110", Integer.valueOf(2240)), + new Entry("000000010111", Integer.valueOf(2304)), + new Entry("000000011100", Integer.valueOf(2368)), + new Entry("000000011101", Integer.valueOf(2432)), + new Entry("000000011110", Integer.valueOf(2496)), + new Entry("000000011111", Integer.valueOf(2560)), }; + + public static final Entry EOL = new Entry("000000000001", + Integer.valueOf(0)); + public static final Entry EOL13 = new Entry("0000000000001", + Integer.valueOf(0)); + public static final Entry EOL14 = new Entry("00000000000001", + Integer.valueOf(0)); + public static final Entry EOL15 = new Entry("000000000000001", + Integer.valueOf(0)); + public static final Entry EOL16 = new Entry("0000000000000001", + Integer.valueOf(0)); + public static final Entry EOL17 = new Entry("00000000000000001", + Integer.valueOf(0)); + public static final Entry EOL18 = new Entry("000000000000000001", + Integer.valueOf(0)); + public static final Entry EOL19 = new Entry("0000000000000000001", + Integer.valueOf(0)); public static final Entry P = new Entry("0001", Integer.valueOf(0)); public static final Entry H = new Entry("001", Integer.valueOf(0)); public static final Entry V0 = new Entry("1", Integer.valueOf(0)); Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/BitsToByteInputStream.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/BitsToByteInputStream.java?rev=1342914&r1=1342913&r2=1342914&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/BitsToByteInputStream.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/BitsToByteInputStream.java Sat May 26 15:35:04 2012 @@ -19,25 +19,21 @@ package org.apache.commons.imaging.commo import java.io.IOException; import java.io.InputStream; -public class BitsToByteInputStream extends InputStream -{ +public class BitsToByteInputStream extends InputStream { private final MyBitInputStream is; private final int desiredDepth; - public BitsToByteInputStream(MyBitInputStream is, int desiredDepth) - { + public BitsToByteInputStream(MyBitInputStream is, int desiredDepth) { this.is = is; this.desiredDepth = desiredDepth; } @Override - public int read() throws IOException - { + public int read() throws IOException { return readBits(8); } - public int readBits(int bitCount) throws IOException - { + public int readBits(int bitCount) throws IOException { int i = is.readBits(bitCount); if (bitCount < desiredDepth) i <<= (desiredDepth - bitCount); @@ -47,8 +43,7 @@ public class BitsToByteInputStream exten return i; } - public int[] readBitsArray(int sampleBits, int length) throws IOException - { + public int[] readBitsArray(int sampleBits, int length) throws IOException { int result[] = new int[length]; for (int i = 0; i < length; i++) @@ -56,4 +51,4 @@ public class BitsToByteInputStream exten return result; } -} \ No newline at end of file +} Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyBitInputStream.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyBitInputStream.java?rev=1342914&r1=1342913&r2=1342914&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyBitInputStream.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyBitInputStream.java Sat May 26 15:35:04 2012 @@ -21,21 +21,18 @@ import java.io.InputStream; import org.apache.commons.imaging.common.BinaryConstants; -public class MyBitInputStream extends InputStream implements BinaryConstants -{ +public class MyBitInputStream extends InputStream implements BinaryConstants { private final InputStream is; private final int byteOrder; private boolean tiffLZWMode = false; - public MyBitInputStream(InputStream is, int byteOrder) - { + public MyBitInputStream(InputStream is, int byteOrder) { this.byteOrder = byteOrder; this.is = is; } @Override - public int read() throws IOException - { + public int read() throws IOException { return readBits(8); } @@ -43,21 +40,16 @@ public class MyBitInputStream extends In private int bitsInCache = 0; private int bitCache = 0; - public void setTiffLZWMode() - { + public void setTiffLZWMode() { tiffLZWMode = true; } - public int readBits(int SampleBits) throws IOException - { - while (bitsInCache < SampleBits) - { + public int readBits(int SampleBits) throws IOException { + while (bitsInCache < SampleBits) { int next = is.read(); - if (next < 0) - { - if (tiffLZWMode) - { + if (next < 0) { + if (tiffLZWMode) { // pernicious special case! return 257; } @@ -83,13 +75,11 @@ public class MyBitInputStream extends In if (byteOrder == BYTE_ORDER_NETWORK) // MSB, so read from left { sample = sampleMask & (bitCache >> (bitsInCache - SampleBits)); - } - else if (byteOrder == BYTE_ORDER_INTEL) // LSB, so read from right + } else if (byteOrder == BYTE_ORDER_INTEL) // LSB, so read from right { sample = sampleMask & bitCache; bitCache >>= SampleBits; - } - else + } else throw new IOException("Unknown byte order: " + byteOrder); int result = sample; @@ -101,15 +91,13 @@ public class MyBitInputStream extends In return result; } - public void flushCache() - { + public void flushCache() { bitsInCache = 0; bitCache = 0; } - public long getBytesRead() - { + public long getBytesRead() { return bytesRead; } -} \ No newline at end of file +} Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyBitOutputStream.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyBitOutputStream.java?rev=1342914&r1=1342913&r2=1342914&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyBitOutputStream.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyBitOutputStream.java Sat May 26 15:35:04 2012 @@ -21,20 +21,17 @@ import java.io.OutputStream; import org.apache.commons.imaging.common.BinaryConstants; -public class MyBitOutputStream extends OutputStream implements BinaryConstants -{ +public class MyBitOutputStream extends OutputStream implements BinaryConstants { private final OutputStream os; private final int byteOrder; - public MyBitOutputStream(OutputStream os, int byteOrder) - { + public MyBitOutputStream(OutputStream os, int byteOrder) { this.byteOrder = byteOrder; this.os = os; } @Override - public void write(int value) throws IOException - { + public void write(int value) throws IOException { writeBits(value, 8); } @@ -42,34 +39,30 @@ public class MyBitOutputStream extends O private int bitCache = 0; // TODO: in and out streams CANNOT accurately read/write 32bits at a time, - // as int will overflow. should have used a long - public void writeBits(int value, int SampleBits) throws IOException - { + // as int will overflow. should have used a long + public void writeBits(int value, int SampleBits) throws IOException { int sampleMask = (1 << SampleBits) - 1; value &= sampleMask; if (byteOrder == BYTE_ORDER_NETWORK) // MSB, so add to right { bitCache = (bitCache << SampleBits) | value; - } - else if (byteOrder == BYTE_ORDER_INTEL) // LSB, so add to left + } else if (byteOrder == BYTE_ORDER_INTEL) // LSB, so add to left { bitCache = bitCache | (value << bitsInCache); - } - else + } else throw new IOException("Unknown byte order: " + byteOrder); bitsInCache += SampleBits; - while (bitsInCache >= 8) - { + while (bitsInCache >= 8) { if (byteOrder == BYTE_ORDER_NETWORK) // MSB, so write from left { int b = 0xff & (bitCache >> (bitsInCache - 8)); actualWrite(b); bitsInCache -= 8; - } - else if (byteOrder == BYTE_ORDER_INTEL) // LSB, so write from right + } else if (byteOrder == BYTE_ORDER_INTEL) // LSB, so write from + // right { int b = 0xff & bitCache; actualWrite(b); @@ -85,16 +78,13 @@ public class MyBitOutputStream extends O private int bytesWritten = 0; - private void actualWrite(int value) throws IOException - { + private void actualWrite(int value) throws IOException { os.write(value); bytesWritten++; } - public void flushCache() throws IOException - { - if (bitsInCache > 0) - { + public void flushCache() throws IOException { + if (bitsInCache > 0) { int bitMask = (1 << bitsInCache) - 1; int b = bitMask & bitCache; @@ -102,8 +92,8 @@ public class MyBitOutputStream extends O { b <<= 8 - bitsInCache; // left align fragment. os.write(b); - } - else if (byteOrder == BYTE_ORDER_INTEL) // LSB, so write from right + } else if (byteOrder == BYTE_ORDER_INTEL) // LSB, so write from + // right { os.write(b); } @@ -113,9 +103,8 @@ public class MyBitOutputStream extends O bitCache = 0; } - public int getBytesWritten() - { + public int getBytesWritten() { return bytesWritten + ((bitsInCache > 0) ? 1 : 0); } -} \ No newline at end of file +} Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyLzwCompressor.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyLzwCompressor.java?rev=1342914&r1=1342913&r2=1342914&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyLzwCompressor.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyLzwCompressor.java Sat May 26 15:35:04 2012 @@ -21,8 +21,7 @@ import java.io.IOException; import java.util.HashMap; import java.util.Map; -public class MyLzwCompressor -{ +public class MyLzwCompressor { // private static final int MAX_TABLE_SIZE = 1 << 12; @@ -37,14 +36,12 @@ public class MyLzwCompressor private final Listener listener; public MyLzwCompressor(int initialCodeSize, int byteOrder, - boolean earlyLimit) - { + boolean earlyLimit) { this(initialCodeSize, byteOrder, earlyLimit, null); } public MyLzwCompressor(int initialCodeSize, int byteOrder, - boolean earlyLimit, Listener listener) - { + boolean earlyLimit, Listener listener) { this.listener = listener; this.byteOrder = byteOrder; this.earlyLimit = earlyLimit; @@ -62,17 +59,14 @@ public class MyLzwCompressor private final Map map = new HashMap(); - private final void InitializeStringTable() - { + private final void InitializeStringTable() { codeSize = initialCodeSize; int intial_entries_count = (1 << codeSize) + 2; map.clear(); - for (codes = 0; codes < intial_entries_count; codes++) - { - if ((codes != clearCode) && (codes != eoiCode)) - { + for (codes = 0; codes < intial_entries_count; codes++) { + if ((codes != clearCode) && (codes != eoiCode)) { Object key = arrayToKey((byte) codes); map.put(key, codes); @@ -80,45 +74,38 @@ public class MyLzwCompressor } } - private final void clearTable() - { + private final void clearTable() { InitializeStringTable(); incrementCodeSize(); } - private final void incrementCodeSize() - { + private final void incrementCodeSize() { if (codeSize != 12) codeSize++; } - private final Object arrayToKey(byte b) - { + private final Object arrayToKey(byte b) { return arrayToKey(new byte[] { b, }, 0, 1); } - private final static class ByteArray - { + private final static class ByteArray { private final byte bytes[]; private final int start; private final int length; private final int hash; - public ByteArray(byte bytes[]) - { + public ByteArray(byte bytes[]) { this(bytes, 0, bytes.length); } - public ByteArray(byte bytes[], int start, int length) - { + public ByteArray(byte bytes[], int start, int length) { this.bytes = bytes; this.start = start; this.length = length; int tempHash = length; - for (int i = 0; i < length; i++) - { + for (int i = 0; i < length; i++) { int b = 0xff & bytes[i + start]; tempHash = tempHash + (tempHash << 8) ^ b ^ i; } @@ -127,14 +114,12 @@ public class MyLzwCompressor } @Override - public final int hashCode() - { + public final int hashCode() { return hash; } @Override - public final boolean equals(Object o) - { + public final boolean equals(Object o) { if (o instanceof ByteArray) { ByteArray other = (ByteArray) o; if (other.hash != hash) @@ -142,8 +127,7 @@ public class MyLzwCompressor if (other.length != length) return false; - for (int i = 0; i < length; i++) - { + for (int i = 0; i < length; i++) { if (other.bytes[i + other.start] != bytes[i + start]) return false; } @@ -154,50 +138,42 @@ public class MyLzwCompressor } } - private final Object arrayToKey(byte bytes[], int start, int length) - { + private final Object arrayToKey(byte bytes[], int start, int length) { return new ByteArray(bytes, start, length); } private final void writeDataCode(MyBitOutputStream bos, int code) - throws IOException - { + throws IOException { if (null != listener) listener.dataCode(code); writeCode(bos, code); } - - private final void writeClearCode(MyBitOutputStream bos) throws IOException - { + private final void writeClearCode(MyBitOutputStream bos) throws IOException { if (null != listener) listener.dataCode(clearCode); writeCode(bos, clearCode); } - private final void writeEoiCode(MyBitOutputStream bos) throws IOException - { + private final void writeEoiCode(MyBitOutputStream bos) throws IOException { if (null != listener) listener.eoiCode(eoiCode); writeCode(bos, eoiCode); } private final void writeCode(MyBitOutputStream bos, int code) - throws IOException - { + throws IOException { bos.writeBits(code, codeSize); } - private final boolean isInTable(byte bytes[], int start, int length) - { + private final boolean isInTable(byte bytes[], int start, int length) { Object key = arrayToKey(bytes, start, length); return map.containsKey(key); } private final int codeFromString(byte bytes[], int start, int length) - throws IOException - { + throws IOException { Object key = arrayToKey(bytes, start, length); Object o = map.get(key); if (o == null) @@ -206,15 +182,13 @@ public class MyLzwCompressor } private final boolean addTableEntry(MyBitOutputStream bos, byte bytes[], - int start, int length) throws IOException - { + int start, int length) throws IOException { Object key = arrayToKey(bytes, start, length); return addTableEntry(bos, key); } private final boolean addTableEntry(MyBitOutputStream bos, Object key) - throws IOException - { + throws IOException { boolean cleared = false; { @@ -222,12 +196,10 @@ public class MyLzwCompressor if (earlyLimit) limit--; - if (codes == limit) - { + if (codes == limit) { if (codeSize < 12) incrementCodeSize(); - else - { + else { writeClearCode(bos); clearTable(); cleared = true; @@ -235,8 +207,7 @@ public class MyLzwCompressor } } - if (!cleared) - { + if (!cleared) { map.put(key, codes); codes++; } @@ -244,8 +215,7 @@ public class MyLzwCompressor return cleared; } - public static interface Listener - { + public static interface Listener { public void dataCode(int code); public void eoiCode(int code); @@ -255,8 +225,7 @@ public class MyLzwCompressor public void init(int clearCode, int eoiCode); } - public byte[] compress(byte bytes[]) throws IOException - { + public byte[] compress(byte bytes[]) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(bytes.length); MyBitOutputStream bos = new MyBitOutputStream(baos, byteOrder); @@ -268,15 +237,12 @@ public class MyLzwCompressor int w_start = 0; int w_length = 0; - for (int i = 0; i < bytes.length; i++) - { - if (isInTable(bytes, w_start, w_length + 1)) - { + for (int i = 0; i < bytes.length; i++) { + if (isInTable(bytes, w_start, w_length + 1)) { w_length++; cleared = false; - } else - { + } else { int code = codeFromString(bytes, w_start, w_length); writeDataCode(bos, code); cleared = addTableEntry(bos, bytes, w_start, w_length + 1); @@ -295,4 +261,4 @@ public class MyLzwCompressor return baos.toByteArray(); } -} \ No newline at end of file +} Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyLzwDecompressor.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyLzwDecompressor.java?rev=1342914&r1=1342913&r2=1342914&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyLzwDecompressor.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyLzwDecompressor.java Sat May 26 15:35:04 2012 @@ -21,8 +21,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -public final class MyLzwDecompressor -{ +public final class MyLzwDecompressor { private static final int MAX_TABLE_SIZE = 1 << 12; private final byte[][] table; @@ -34,21 +33,18 @@ public final class MyLzwDecompressor private final Listener listener; - public static interface Listener - { + public static interface Listener { public void code(int code); public void init(int clearCode, int eoiCode); } - public MyLzwDecompressor(int initialCodeSize, int byteOrder) - { + public MyLzwDecompressor(int initialCodeSize, int byteOrder) { this(initialCodeSize, byteOrder, null); } public MyLzwDecompressor(int initialCodeSize, int byteOrder, - Listener listener) - { + Listener listener) { this.listener = listener; this.byteOrder = byteOrder; @@ -64,8 +60,7 @@ public final class MyLzwDecompressor InitializeTable(); } - private final void InitializeTable() - { + private final void InitializeTable() { codeSize = initialCodeSize; int intial_entries_count = 1 << codeSize + 2; @@ -74,8 +69,7 @@ public final class MyLzwDecompressor table[i] = new byte[] { (byte) i, }; } - private final void clearTable() - { + private final void clearTable() { codes = (1 << initialCodeSize) + 2; codeSize = initialCodeSize; incrementCodeSize(); @@ -84,8 +78,7 @@ public final class MyLzwDecompressor private final int clearCode; private final int eoiCode; - private final int getNextCode(MyBitInputStream is) throws IOException - { + private final int getNextCode(MyBitInputStream is) throws IOException { int code = is.readBits(codeSize); if (null != listener) @@ -93,8 +86,7 @@ public final class MyLzwDecompressor return code; } - private final byte[] stringFromCode(int code) throws IOException - { + private final byte[] stringFromCode(int code) throws IOException { if ((code >= codes) || (code < 0)) throw new IOException("Bad Code: " + code + " codes: " + codes + " code_size: " + codeSize + ", table: " + table.length); @@ -102,20 +94,16 @@ public final class MyLzwDecompressor return table[code]; } - private final boolean isInTable(int Code) - { + private final boolean isInTable(int Code) { return Code < codes; } - private final byte firstChar(byte bytes[]) - { + private final byte firstChar(byte bytes[]) { return bytes[0]; } - private final void addStringToTable(byte bytes[]) throws IOException - { - if (codes < (1 << codeSize)) - { + private final void addStringToTable(byte bytes[]) throws IOException { + if (codes < (1 << codeSize)) { table[codes] = bytes; codes++; } else @@ -125,8 +113,7 @@ public final class MyLzwDecompressor checkCodeSize(); } - private final byte[] appendBytes(byte bytes[], byte b) - { + private final byte[] appendBytes(byte bytes[], byte b) { byte result[] = new byte[bytes.length + 1]; System.arraycopy(bytes, 0, result, 0, bytes.length); @@ -137,22 +124,19 @@ public final class MyLzwDecompressor private int written = 0; private final void writeToResult(OutputStream os, byte bytes[]) - throws IOException - { + throws IOException { os.write(bytes); written += bytes.length; } private boolean tiffLZWMode = false; - public void setTiffLZWMode() - { + public void setTiffLZWMode() { tiffLZWMode = true; } public byte[] decompress(InputStream is, int expectedLength) - throws IOException - { + throws IOException { int code, oldCode = -1; MyBitInputStream mbis = new MyBitInputStream(is, byteOrder); if (tiffLZWMode) @@ -162,35 +146,29 @@ public final class MyLzwDecompressor clearTable(); - while ((code = getNextCode(mbis)) != eoiCode) - { - if (code == clearCode) - { + while ((code = getNextCode(mbis)) != eoiCode) { + if (code == clearCode) { clearTable(); if (written >= expectedLength) break; code = getNextCode(mbis); - if (code == eoiCode) - { + if (code == eoiCode) { break; } writeToResult(baos, stringFromCode(code)); oldCode = code; } // end of ClearCode case - else - { - if (isInTable(code)) - { + else { + if (isInTable(code)) { writeToResult(baos, stringFromCode(code)); addStringToTable(appendBytes(stringFromCode(oldCode), firstChar(stringFromCode(code)))); oldCode = code; - } else - { + } else { byte OutString[] = appendBytes(stringFromCode(oldCode), firstChar(stringFromCode(oldCode))); writeToResult(baos, OutString); @@ -223,4 +201,4 @@ public final class MyLzwDecompressor if (codeSize != 12) codeSize++; } -} \ No newline at end of file +}