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

📄 precinctsizespec.java

📁 jpeg2000算法实现
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                            errMsg = "'"+optName+"' option : could not "+                                "parse the precinct's width";                            throw new IllegalArgumentException(errMsg);                                                    }                        // Get precinct height                        h = new Integer(word);                        if (w.intValue() != (1<<MathUtil.log2(w.intValue()))                            || h.intValue() !=                            (1<<MathUtil.log2(h.intValue())) ) {                            errMsg = "Precinct dimensions must be powers of 2";                            throw new IllegalArgumentException(errMsg);                        }                    }                    catch( NumberFormatException e) {                        errMsg = "'"+optName+"' option : the argument '"+word+                            "' could not be parsed.";                        throw new IllegalArgumentException(errMsg);                    }                    // Store packet's dimensions in Vector arrays                    v[0].addElement(w);                    v[1].addElement(h);                                        // Try to get the next token                    if ( stk.hasMoreTokens() ) {                        word = stk.nextToken();                        if ( !Character.isDigit(word.charAt(0)) ) {                            // The next token does not start with a digit so                            // it is not a precinct's size argument. We set                            // the wasReadingPrecinctSize booleen such that we                            // know that we don't have to read another token                            // and check for the end of the parameters list.                            wasReadingPrecinctSize = true;                            if(curSpecType==SPEC_DEF){                                setDefault(v);                            }                            else if(curSpecType==SPEC_TILE_DEF){                                for(ti=tileSpec.length-1; ti>=0; ti--) {                                    if( tileSpec[ti] ){                                        setTileDef(ti,v);                                    }                                }                            }                            else if(curSpecType==SPEC_COMP_DEF){                                for(ci=compSpec.length-1; ci>=0; ci--) {                                    if( compSpec[ci] ){                                        setCompDef(ci,v);                                    }                                }                            }                            else{                                for(ti=tileSpec.length-1; ti>=0; ti--){                                    for(ci=compSpec.length-1; ci>=0 ; ci--){                                        if(tileSpec[ti] && compSpec[ci]){                                            setTileCompVal(ti,ci,v);                                        }                                    }                                }                            }                            // Re-initialize                            curSpecType = SPEC_DEF;                            tileSpec = null;                            compSpec = null;                                                        // Go back to 'normal' parsing                            break;                        }                        else {                            // Next token starts with a digit so read it                        }                    }                    else {                        // We have reached the end of the parameters list so                        // we store the last precinct's sizes and we stop                        if(curSpecType==SPEC_DEF){                            setDefault(v);                        }                        else if(curSpecType==SPEC_TILE_DEF){                            for(ti=tileSpec.length-1; ti>=0; ti--) {                                if( tileSpec[ti] ){                                    setTileDef(ti,v);                                }                            }                        }                        else if(curSpecType==SPEC_COMP_DEF){                            for(ci=compSpec.length-1; ci>=0; ci--) {                                if( compSpec[ci] ){                                    setCompDef(ci,v);                                }                            }                        }                        else{                            for(ti=tileSpec.length-1; ti>=0; ti--){                                for(ci=compSpec.length-1; ci>=0 ; ci--){                                    if( tileSpec[ti] && compSpec[ci] ){                                        setTileCompVal(ti,ci,v);                                    }                                }                            }                        }                        endOfParamList = true;                        break;                    }                } // while (true)                break;            } // switch        } // while    }        /**     * Returns the precinct partition width in component 'n' and tile 't' at     * resolution level 'rl'. If the tile index is equal to -1 or if the     * component index is equal to -1 it means that those should not be taken     * into account.     *     * @param t The tile index, in raster scan order. Specify -1 if it is not     * a specific tile.     *     * @param c The component index. Specify -1 if it is not a specific     * component.     *      * @param rl The resolution level     *     * @return The precinct partition width in component 'c' and tile 't' at     * resolution level 'rl'.     * */    public int getPPX(int t, int c, int rl) {        int mrl, idx;        Vector[] v=null;        boolean tileSpecified = (t!=-1 ? true : false);        boolean compSpecified = (c!=-1 ? true : false);                // Get the maximum number of decomposition levels and the object        // (Vector array) containing the precinct dimensions (width and        // height) for the specified (or not) tile/component        if ( tileSpecified && compSpecified ) {            mrl = ((Integer)dls.getTileCompVal(t, c)).intValue();            v = (Vector[])getTileCompVal(t, c);        }        else if ( tileSpecified && !compSpecified ) {            mrl = ((Integer)dls.getTileDef(t)).intValue();            v = (Vector[])getTileDef(t);        }        else if ( !tileSpecified && compSpecified ) {            mrl = ((Integer)dls.getCompDef(c)).intValue();            v = (Vector[])getCompDef(c);        }        else {            mrl = ((Integer)dls.getDefault()).intValue();            v = (Vector[])getDefault();        }        idx = mrl - rl;        if ( v[0].size() > idx ) {             return ((Integer)v[0].elementAt(idx)).intValue();        }        else {            return ((Integer)v[0].elementAt(v[0].size()-1)).intValue();        }    }        /**     * Returns the precinct partition height in component 'n' and tile 't' at     * resolution level 'rl'. If the tile index is equal to -1 or if the     * component index is equal to -1 it means that those should not be taken     * into account.     *     * @param t The tile index, in raster scan order. Specify -1 if it is not     * a specific tile.     *     * @param c The component index. Specify -1 if it is not a specific     * component.     *      * @param rl The resolution level.     *     * @return The precinct partition width in component 'n' and tile 't' at     * resolution level 'rl'.     * */    public int getPPY(int t, int c, int rl) {        int mrl, idx;        Vector[] v=null;        boolean tileSpecified = (t!=-1 ? true : false);        boolean compSpecified = (c!=-1 ? true : false);                // Get the maximum number of decomposition levels and the object        // (Vector array) containing the precinct dimensions (width and        // height) for the specified (or not) tile/component        if ( tileSpecified && compSpecified ) {            mrl = ((Integer)dls.getTileCompVal(t, c)).intValue();            v = (Vector[])getTileCompVal(t, c);        }        else if ( tileSpecified && !compSpecified ) {            mrl = ((Integer)dls.getTileDef(t)).intValue();            v = (Vector[])getTileDef(t);        }        else if ( !tileSpecified && compSpecified ) {            mrl = ((Integer)dls.getCompDef(c)).intValue();            v = (Vector[])getCompDef(c);        }        else {            mrl = ((Integer)dls.getDefault()).intValue();            v = (Vector[])getDefault();        }        idx = mrl - rl;        if ( v[1].size() > idx ) {            return ((Integer)v[1].elementAt(idx)).intValue();        }        else {            return ((Integer)v[1].elementAt(v[1].size()-1)).intValue();        }    }}

⌨️ 快捷键说明

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