⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rpfcolortable.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                        }                        //////////////////////////////                        /*                         * loc[1] is colormap subsection. Seek to                         * color/gray table.                         */                        binFile.seek(loc[1].componentLocation                                + colorOffset[i].colorTableOffset);                        /*                         * Read the color/gray records: 32 or 33, or                         * 16 or 17 color tables                         */                        for (j = 0; j < ncr; j++) { /*                                                     * 32 or 33, or 16                                                     * or 17                                                     */                            red = binFile.read() & 0x00ff; /*                                                            * read                                                            * byte                                                            * value                                                            */                            green = binFile.read() & 0x00ff; /*                                                              * read                                                              * byte                                                              * value                                                              */                            blue = binFile.read() & 0x00ff; /*                                                             * read                                                             * byte                                                             * value                                                             */                            alpha = binFile.read(); /* read byte value */                            alpha = opaqueness;                            /* DKS NEW TRANSP */                            if (ncr == 217 && rgb[(int) (ncr - 1)] == null) { /*                                                                               * transp                                                                               * exists                                                                               */                                alpha = opaqueness;                                red = 255;                                green = 255;                                blue = 255;                                rgb[(int) (ncr - 1)] = new Color(red, green, blue, alpha);                            } /* if */                            rgb[j] = new Color(red, green, blue, alpha);                            if (Debug.debugging("rpfcolortable")) {                                if (j == 0)                                    Debug.output("RpfColortable:\n\n---CCT color table---\n");                                Debug.output("RpfColortable: red:" + red                                        + ", green:" + green + ", blue:" + blue                                        + ", alpha: " + alpha);                            }                        } /* for j */                        /* go to start of color converter table */                        /* loc[2] is color converter subsection */                        binFile.seek(loc[2].componentLocation                                + cct[i].colorConvTableOffset);                        if (Debug.debugging("rpfdetail")) {                            Debug.output("RpfColortable: i:" + i                                    + ", colorConvTableOffset[i]:"                                    + cct[i].colorConvTableOffset);                            Debug.output("RpfColortable: Read cct values at file location:"                                    + binFile.getFilePointer());                        }                        for (j = 0; j < cct[i].colorConvNumRecs; j++) {                            colorConvTable[j] = binFile.readInteger();                            if (Debug.debugging("rpfcolortable"))                                Debug.output("RpfColortable: j:" + j                                        + ", colorConvTable[j]:"                                        + colorConvTable[j]);                        }                        break; /* for i */                    } /* if foundLUT */                } /* for i = numColorConvOffsetRecs */            } /* else CCT needed */            if (reducedColorTable == COLORS_216) { /*                                                    * 216 colors                                                    * chosen                                                    */                if (Debug.debugging("rpfdetail"))                    Debug.output("RpfColortable: WARNING - Full 216 colors being used\n");                for (j = 0; j < CADRG_COLORS; j++) { /* 216 */                    colorConvTable[j] = j;                } /* for j */            }            //  Since the CIB doesn't contain ccts, we need to fake            // it...            if (Cib && reducedColorTable != COLORS_216) {                int divisor, midoffset;                if (reducedColorTable == COLORS_32) {                    divisor = 8;                    midoffset = 4;                } else {                    divisor = 16;                    midoffset = 8;                }                for (j = 0; j < CADRG_COLORS; j++) { /* 216 */                    red = (int) (rgb[j].getRed() / divisor) * divisor                            + midoffset;                    green = (int) (rgb[j].getGreen() / divisor) * divisor                            + midoffset;                    blue = (int) (rgb[j].getBlue() / divisor) * divisor                            + midoffset;                    alpha = rgb[j].getAlpha();                    rgb[j] = new Color(red, green, blue, alpha);                    if (Debug.debugging("rpfcolortable")) {                        if (j == 0)                            Debug.output("RpfColortable:\n\n---Final color table CIB---\n");                        Debug.output("RpfColortable: Color " + j + " red: "                                + rgb[j].getRed() + ", green: "                                + rgb[j].getGreen() + ", blue: "                                + rgb[j].getBlue());                    }                }            } // if Cib            //  For CADRG that has a cct or also Cib that doesn't            /* DKS. cct added here instead of load_frame */            else if (reducedColorTable != COLORS_216) {                for (j = 0; j < CADRG_COLORS; j++) { /* 216 */                    red = rgb[colorConvTable[j]].getRed();                    green = rgb[colorConvTable[j]].getGreen();                    blue = rgb[colorConvTable[j]].getBlue();                    alpha = rgb[colorConvTable[j]].getAlpha();                    rgb[j] = new Color(red, green, blue, alpha);                    if (Debug.debugging("rpfcolortable")) {                        if (j == 0)                            Debug.output("RpfColortable:\n\n---Final color table---\n");                        Debug.output("RpfColortable: Color " + j + " red: "                                + rgb[j].getRed() + ", green: "                                + rgb[j].getGreen() + ", blue: "                                + rgb[j].getBlue());                    }                } /* for j */            }            if (Debug.debugging("rpfdetail")) {                Debug.output("RpfColortable: LEAVE PARSE Colortable");            }        } catch (IOException ioe) {            Debug.error("RpfTocHandler: IO ERROR parsing file!\n" + ioe);            return null;        } catch (FormatException fe) {            Debug.error("RpfTocHandler: Format ERROR parsing file!\n" + fe);            return null;        }        colors = rgb;        return rgb;    } /* parse_clut.c */    static public class ColorOffset {        public int tableId;        public long numColorRecords;        public int colorElementLength; // uchar        public int histogramRecordLength;        public long colorTableOffset;        public long histogramTableOffset;        public ColorOffset() {}        public String toString() {            StringBuffer s = new StringBuffer();            s.append("RpfColortable: tableId 2:CADRG; 3:CIB): " + tableId                    + "\n");            s.append("RpfColortable: numColorRecords: " + numColorRecords                    + "\n");            s.append("RpfColortable: colorElementLength: " + colorElementLength                    + "\n");            s.append("RpfColortable: histogramRecordLength: "                    + histogramRecordLength + "\n");            s.append("RpfColortable: colorTableOffset: " + colorTableOffset                    + "\n");            s.append("RpfColortable: histogramTableOffset: "                    + histogramTableOffset);            return s.toString();        }    }    static public class ColorConversionTable {        public int colorConvTableId; //ushort        public long colorConvNumRecs; // uint        public long colorConvTableOffset; //uint        public long colorConvSourceTableOffset; //uint        public long colorConvTargetTableOffset; //uint        public ColorConversionTable() {}        public String toString() {            StringBuffer s = new StringBuffer();            s.append("RpfColortable: colorConvTableId: " + colorConvTableId                    + "\n");            s.append("RpfColortable: colorConvNumRecs: " + colorConvNumRecs                    + "\n");            s.append("RpfColortable: colorConvTableOffset: "                    + colorConvTableOffset + "\n");            s.append("RpfColortable: colorConvSourceTableOffset: "                    + colorConvSourceTableOffset + "\n");            s.append("RpfColortable: colorConvTargetTableOffset: "                    + colorConvTargetTableOffset);            return s.toString();        }    }    public static void main(String[] args) {        Debug.init(System.getProperties());        if (args.length != 1) {            Debug.output("Usage: java RpfColortable <path to RPF frame>");            return;        }        File file = new File(args[0]);        BinaryFile binFile = null;        try {            binFile = new BinaryBufferedFile(file);        } catch (FileNotFoundException e) {            Debug.error("RpfHeader: file " + args[0] + " not found");            System.exit(1);        } catch (IOException ioe) {            Debug.error("RpfHeader: File IO Error while handling colortable:\n"                    + ioe);            System.exit(1);        }        RpfColortable tbl = new RpfColortable();        RpfFileSections rfs = new RpfFileSections();        RpfHeader head = new RpfHeader();        head.read(binFile);        rfs.parse(binFile);        Color[] colors = rfs.parseColorSection(binFile, tbl);        if (colors == null)            Debug.output("RpfColortable: NOT read sucessfully!");    }}

⌨️ 快捷键说明

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