xtifffaxdecoder.java

来自「OpenMap是一个基于JavaBeansTM的开发工具包。利用OpenMap你」· Java 代码 · 共 1,426 行 · 第 1/4 页

JAVA
1,426
字号
package org.libtiff.jai.codecimpl;/* * XTIFF: eXtensible TIFF libraries for JAI. *  * The contents of this file are subject to the  JAVA ADVANCED IMAGING * SAMPLE INPUT-OUTPUT CODECS AND WIDGET HANDLING SOURCE CODE  License * Version 1.0 (the "License"); You may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.sun.com/software/imaging/JAI/index.html * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License.  * * The Original Code is JAVA ADVANCED IMAGING SAMPLE INPUT-OUTPUT CODECS * AND WIDGET HANDLING SOURCE CODE.  * The Initial Developer of the Original Code is: Sun Microsystems, Inc.. * Portions created by: Niles Ritter  * are Copyright (C): Niles Ritter, GeoTIFF.org, 1999,2000. * All Rights Reserved. * Contributor(s): Niles Ritter */import org.libtiff.jai.util.JaiI18N;// Expose the class (mistake in JAI?)public class XTIFFFaxDecoder {    private int bitPointer, bytePointer;    private byte[] data;    private int w, h;    private int fillOrder;    // Data structures needed to store changing elements for the previous    // and the current scanline    private int changingElemSize = 0;    private int prevChangingElems[];    private int currChangingElems[];    // Element at which to start search in getNextChangingElement    private int lastChangingElement = 0;    private int compression = 2;    // Variables set by T4Options    private int uncompressedMode = 0;    private int fillBits = 0;    private int oneD;    static int table1[] = { 0x00, // 0 bits are left in first byte - SHOULD                                    // NOT HAPPEN            0x01, // 1 bits are left in first byte            0x03, // 2 bits are left in first byte            0x07, // 3 bits are left in first byte            0x0f, // 4 bits are left in first byte            0x1f, // 5 bits are left in first byte            0x3f, // 6 bits are left in first byte            0x7f, // 7 bits are left in first byte            0xff // 8 bits are left in first byte    };    static int table2[] = { 0x00, // 0            0x80, // 1            0xc0, // 2            0xe0, // 3            0xf0, // 4            0xf8, // 5            0xfc, // 6            0xfe, // 7            0xff // 8    };    // Table to be used when fillOrder = 2, for flipping bytes.    static byte flipTable[] = { 0, -128, 64, -64, 32, -96, 96, -32, 16, -112,            80, -48, 48, -80, 112, -16, 8, -120, 72, -56, 40, -88, 104, -24,            24, -104, 88, -40, 56, -72, 120, -8, 4, -124, 68, -60, 36, -92,            100, -28, 20, -108, 84, -44, 52, -76, 116, -12, 12, -116, 76, -52,            44, -84, 108, -20, 28, -100, 92, -36, 60, -68, 124, -4, 2, -126,            66, -62, 34, -94, 98, -30, 18, -110, 82, -46, 50, -78, 114, -14,            10, -118, 74, -54, 42, -86, 106, -22, 26, -102, 90, -38, 58, -70,            122, -6, 6, -122, 70, -58, 38, -90, 102, -26, 22, -106, 86, -42,            54, -74, 118, -10, 14, -114, 78, -50, 46, -82, 110, -18, 30, -98,            94, -34, 62, -66, 126, -2, 1, -127, 65, -63, 33, -95, 97, -31, 17,            -111, 81, -47, 49, -79, 113, -15, 9, -119, 73, -55, 41, -87, 105,            -23, 25, -103, 89, -39, 57, -71, 121, -7, 5, -123, 69, -59, 37,            -91, 101, -27, 21, -107, 85, -43, 53, -75, 117, -11, 13, -115, 77,            -51, 45, -83, 109, -19, 29, -99, 93, -35, 61, -67, 125, -3, 3,            -125, 67, -61, 35, -93, 99, -29, 19, -109, 83, -45, 51, -77, 115,            -13, 11, -117, 75, -53, 43, -85, 107, -21, 27, -101, 91, -37, 59,            -69, 123, -5, 7, -121, 71, -57, 39, -89, 103, -25, 23, -105, 87,            -41, 55, -73, 119, -9, 15, -113, 79, -49, 47, -81, 111, -17, 31,            -97, 95, -33, 63, -65, 127, -1, };    // The main 10 bit white runs lookup table    static short white[] = {    // 0 - 7            6430, 6400, 6400, 6400, 3225, 3225, 3225, 3225,            // 8 - 15            944, 944, 944, 944, 976, 976, 976, 976,            // 16 - 23            1456, 1456, 1456, 1456, 1488, 1488, 1488, 1488,            // 24 - 31            718, 718, 718, 718, 718, 718, 718, 718,            // 32 - 39            750, 750, 750, 750, 750, 750, 750, 750,            // 40 - 47            1520, 1520, 1520, 1520, 1552, 1552, 1552, 1552,            // 48 - 55            428, 428, 428, 428, 428, 428, 428, 428,            // 56 - 63            428, 428, 428, 428, 428, 428, 428, 428,            // 64 - 71            654, 654, 654, 654, 654, 654, 654, 654,            // 72 - 79            1072, 1072, 1072, 1072, 1104, 1104, 1104, 1104,            // 80 - 87            1136, 1136, 1136, 1136, 1168, 1168, 1168, 1168,            // 88 - 95            1200, 1200, 1200, 1200, 1232, 1232, 1232, 1232,            // 96 - 103            622, 622, 622, 622, 622, 622, 622, 622,            // 104 - 111            1008, 1008, 1008, 1008, 1040, 1040, 1040, 1040,            // 112 - 119            44, 44, 44, 44, 44, 44, 44, 44,            // 120 - 127            44, 44, 44, 44, 44, 44, 44, 44,            // 128 - 135            396, 396, 396, 396, 396, 396, 396, 396,            // 136 - 143            396, 396, 396, 396, 396, 396, 396, 396,            // 144 - 151            1712, 1712, 1712, 1712, 1744, 1744, 1744, 1744,            // 152 - 159            846, 846, 846, 846, 846, 846, 846, 846,            // 160 - 167            1264, 1264, 1264, 1264, 1296, 1296, 1296, 1296,            // 168 - 175            1328, 1328, 1328, 1328, 1360, 1360, 1360, 1360,            // 176 - 183            1392, 1392, 1392, 1392, 1424, 1424, 1424, 1424,            // 184 - 191            686, 686, 686, 686, 686, 686, 686, 686,            // 192 - 199            910, 910, 910, 910, 910, 910, 910, 910,            // 200 - 207            1968, 1968, 1968, 1968, 2000, 2000, 2000, 2000,            // 208 - 215            2032, 2032, 2032, 2032, 16, 16, 16, 16,            // 216 - 223            10257, 10257, 10257, 10257, 12305, 12305, 12305, 12305,            // 224 - 231            330, 330, 330, 330, 330, 330, 330, 330,            // 232 - 239            330, 330, 330, 330, 330, 330, 330, 330,            // 240 - 247            330, 330, 330, 330, 330, 330, 330, 330,            // 248 - 255            330, 330, 330, 330, 330, 330, 330, 330,            // 256 - 263            362, 362, 362, 362, 362, 362, 362, 362,            // 264 - 271            362, 362, 362, 362, 362, 362, 362, 362,            // 272 - 279            362, 362, 362, 362, 362, 362, 362, 362,            // 280 - 287            362, 362, 362, 362, 362, 362, 362, 362,            // 288 - 295            878, 878, 878, 878, 878, 878, 878, 878,            // 296 - 303            1904, 1904, 1904, 1904, 1936, 1936, 1936, 1936,            // 304 - 311            -18413, -18413, -16365, -16365, -14317, -14317, -10221, -10221,            // 312 - 319            590, 590, 590, 590, 590, 590, 590, 590,            // 320 - 327            782, 782, 782, 782, 782, 782, 782, 782,            // 328 - 335            1584, 1584, 1584, 1584, 1616, 1616, 1616, 1616,            // 336 - 343            1648, 1648, 1648, 1648, 1680, 1680, 1680, 1680,            // 344 - 351            814, 814, 814, 814, 814, 814, 814, 814,            // 352 - 359            1776, 1776, 1776, 1776, 1808, 1808, 1808, 1808,            // 360 - 367            1840, 1840, 1840, 1840, 1872, 1872, 1872, 1872,            // 368 - 375            6157, 6157, 6157, 6157, 6157, 6157, 6157, 6157,            // 376 - 383            6157, 6157, 6157, 6157, 6157, 6157, 6157, 6157,            // 384 - 391            -12275, -12275, -12275, -12275, -12275, -12275, -12275, -12275,            // 392 - 399            -12275, -12275, -12275, -12275, -12275, -12275, -12275, -12275,            // 400 - 407            14353, 14353, 14353, 14353, 16401, 16401, 16401, 16401,            // 408 - 415            22547, 22547, 24595, 24595, 20497, 20497, 20497, 20497,            // 416 - 423            18449, 18449, 18449, 18449, 26643, 26643, 28691, 28691,            // 424 - 431            30739, 30739, -32749, -32749, -30701, -30701, -28653, -28653,            // 432 - 439            -26605, -26605, -24557, -24557, -22509, -22509, -20461, -20461,            // 440 - 447            8207, 8207, 8207, 8207, 8207, 8207, 8207, 8207,            // 448 - 455            72, 72, 72, 72, 72, 72, 72, 72,            // 456 - 463            72, 72, 72, 72, 72, 72, 72, 72,            // 464 - 471            72, 72, 72, 72, 72, 72, 72, 72,            // 472 - 479            72, 72, 72, 72, 72, 72, 72, 72,            // 480 - 487            72, 72, 72, 72, 72, 72, 72, 72,            // 488 - 495            72, 72, 72, 72, 72, 72, 72, 72,            // 496 - 503            72, 72, 72, 72, 72, 72, 72, 72,            // 504 - 511            72, 72, 72, 72, 72, 72, 72, 72,            // 512 - 519            104, 104, 104, 104, 104, 104, 104, 104,            // 520 - 527            104, 104, 104, 104, 104, 104, 104, 104,            // 528 - 535            104, 104, 104, 104, 104, 104, 104, 104,            // 536 - 543            104, 104, 104, 104, 104, 104, 104, 104,            // 544 - 551            104, 104, 104, 104, 104, 104, 104, 104,            // 552 - 559            104, 104, 104, 104, 104, 104, 104, 104,            // 560 - 567            104, 104, 104, 104, 104, 104, 104, 104,            // 568 - 575            104, 104, 104, 104, 104, 104, 104, 104,            // 576 - 583            4107, 4107, 4107, 4107, 4107, 4107, 4107, 4107,            // 584 - 591            4107, 4107, 4107, 4107, 4107, 4107, 4107, 4107,            // 592 - 599            4107, 4107, 4107, 4107, 4107, 4107, 4107, 4107,            // 600 - 607            4107, 4107, 4107, 4107, 4107, 4107, 4107, 4107,            // 608 - 615            266, 266, 266, 266, 266, 266, 266, 266,            // 616 - 623            266, 266, 266, 266, 266, 266, 266, 266,            // 624 - 631            266, 266, 266, 266, 266, 266, 266, 266,            // 632 - 639            266, 266, 266, 266, 266, 266, 266, 266,            // 640 - 647            298, 298, 298, 298, 298, 298, 298, 298,            // 648 - 655            298, 298, 298, 298, 298, 298, 298, 298,            // 656 - 663            298, 298, 298, 298, 298, 298, 298, 298,            // 664 - 671            298, 298, 298, 298, 298, 298, 298, 298,            // 672 - 679            524, 524, 524, 524, 524, 524, 524, 524,            // 680 - 687            524, 524, 524, 524, 524, 524, 524, 524,            // 688 - 695            556, 556, 556, 556, 556, 556, 556, 556,            // 696 - 703            556, 556, 556, 556, 556, 556, 556, 556,            // 704 - 711            136, 136, 136, 136, 136, 136, 136, 136,            // 712 - 719            136, 136, 136, 136, 136, 136, 136, 136,            // 720 - 727            136, 136, 136, 136, 136, 136, 136, 136,            // 728 - 735            136, 136, 136, 136, 136, 136, 136, 136,            // 736 - 743            136, 136, 136, 136, 136, 136, 136, 136,            // 744 - 751            136, 136, 136, 136, 136, 136, 136, 136,            // 752 - 759            136, 136, 136, 136, 136, 136, 136, 136,            // 760 - 767            136, 136, 136, 136, 136, 136, 136, 136,            // 768 - 775            168, 168, 168, 168, 168, 168, 168, 168,            // 776 - 783            168, 168, 168, 168, 168, 168, 168, 168,            // 784 - 791            168, 168, 168, 168, 168, 168, 168, 168,            // 792 - 799            168, 168, 168, 168, 168, 168, 168, 168,            // 800 - 807            168, 168, 168, 168, 168, 168, 168, 168,            // 808 - 815            168, 168, 168, 168, 168, 168, 168, 168,            // 816 - 823            168, 168, 168, 168, 168, 168, 168, 168,            // 824 - 831            168, 168, 168, 168, 168, 168, 168, 168,            // 832 - 839            460, 460, 460, 460, 460, 460, 460, 460,            // 840 - 847            460, 460, 460, 460, 460, 460, 460, 460,            // 848 - 855            492, 492, 492, 492, 492, 492, 492, 492,            // 856 - 863            492, 492, 492, 492, 492, 492, 492, 492,            // 864 - 871            2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059,            // 872 - 879            2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059,            // 880 - 887            2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059,            // 888 - 895            2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059,            // 896 - 903            200, 200, 200, 200, 200, 200, 200, 200,            // 904 - 911            200, 200, 200, 200, 200, 200, 200, 200,            // 912 - 919            200, 200, 200, 200, 200, 200, 200, 200,            // 920 - 927            200, 200, 200, 200, 200, 200, 200, 200,            // 928 - 935            200, 200, 200, 200, 200, 200, 200, 200,            // 936 - 943            200, 200, 200, 200, 200, 200, 200, 200,            // 944 - 951            200, 200, 200, 200, 200, 200, 200, 200,            // 952 - 959            200, 200, 200, 200, 200, 200, 200, 200,            // 960 - 967            232, 232, 232, 232, 232, 232, 232, 232,            // 968 - 975            232, 232, 232, 232, 232, 232, 232, 232,            // 976 - 983            232, 232, 232, 232, 232, 232, 232, 232,            // 984 - 991            232, 232, 232, 232, 232, 232, 232, 232,            // 992 - 999            232, 232, 232, 232, 232, 232, 232, 232,            // 1000 - 1007            232, 232, 232, 232, 232, 232, 232, 232,            // 1008 - 1015            232, 232, 232, 232, 232, 232, 232, 232,            // 1016 - 1023            232, 232, 232, 232, 232, 232, 232, 232, };    // Additional make up codes for both White and Black runs    static short additionalMakeup[] = { 28679, 28679, 31752, (short) 32777,

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?