亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? imgwriterppm.java

?? jpeg2000算法實現
?? JAVA
字號:
/* * CVS identifier: * * $Id: ImgWriterPPM.java,v 1.11 2001/01/24 15:01:52 grosbois Exp $ * * Class:                   ImgWriterRawPPM * * Description:             Image writer for unsigned 8 bit data in *                          PPM file format. *  * * * COPYRIGHT: *  * This software module was originally developed by Rapha雔 Grosbois and * Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel * Askel鰂 (Ericsson Radio Systems AB); and Bertrand Berthelot, David * Bouchard, F閘ix Henry, Gerard Mozelle and Patrice Onno (Canon Research * Centre France S.A) in the course of development of the JPEG2000 * standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This * software module is an implementation of a part of the JPEG 2000 * Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio * Systems AB and Canon Research Centre France S.A (collectively JJ2000 * Partners) agree not to assert against ISO/IEC and users of the JPEG * 2000 Standard (Users) any of their rights under the copyright, not * including other intellectual property rights, for this software module * with respect to the usage by ISO/IEC and Users of this software module * or modifications thereof for use in hardware or software products * claiming conformance to the JPEG 2000 Standard. Those intending to use * this software module in hardware or software products are advised that * their use may infringe existing patents. The original developers of * this software module, JJ2000 Partners and ISO/IEC assume no liability * for use of this software module or modifications thereof. No license * or right to this software module is granted for non JPEG 2000 Standard * conforming products. JJ2000 Partners have full right to use this * software module for his/her own purpose, assign or donate this * software module to any third party and to inhibit third parties from * using this software module for non JPEG 2000 Standard conforming * products. This copyright notice must be included in all copies or * derivative works of this software module. *  * Copyright (c) 1999/2000 JJ2000 Partners. * */package jj2000.j2k.image.output;import jj2000.j2k.image.*;import jj2000.j2k.util.*;import jj2000.j2k.io.*;import java.io.*;/** * This class writes 3 components from an image in 8 bit unsigned data to a * binary PPM file. * * <P>The size of the image that is written is the size of the source * image. No component subsampling is allowed in any of the components that * are written to the file. * * <P>Before writing, all coefficients are inversly level-shifted and then * "saturated" (they are limited * to the nominal dynamic range).<br> * * <u>Ex:</u> if the nominal range is 0-255, the following algorithm is * applied:<br> * * <tt>if coeff<0, output=0<br> * * if coeff>255, output=255<br> * * else output=coeff</tt> * * The write() methods of an object of this class may not be called * concurrently from different threads. * * <P>NOTE: This class is not thread safe, for reasons of internal buffering. * */public class ImgWriterPPM extends ImgWriter {    /** Value used to inverse level shift. One for each component */    private int[] levShift = new int[3];    /** Where to write the data */    private RandomAccessFile out;    /** The array of indexes of the components from where to get the data */    private int cps[] = new int[3];    /** The array of the number of fractional bits in the components of the        source data */    private int fb[] = new int[3];    /** A DataBlk, just used to avoid allocating a new one each time        it is needed */    private DataBlkInt db = new DataBlkInt();    /** The offset of the raw pixel data in the PPM file */    private int offset;        /** The line buffer. */    // This makes the class not thrad safe    // (but it is not the only one making it so)    private byte buf[];    /**     * Creates a new writer to the specified File object, to write data from     * the specified component.     *     * <P>The three components that will be written as R, G and B must be     * specified through the b1, b2 and b3 arguments.     *     * @param out The file where to write the data     *     * @param imgSrc The source from where to get the image data to     * write.     *     * @param n1 The index of the first component from where to get the data,     * that will be written as the red channel.     *     * @param n2 The index of the second component from where to get the data,     * that will be written as the green channel.     *     * @param n3 The index of the third component from where to get the data,     * that will be written as the green channel.     *     * @see DataBlk     * */    public ImgWriterPPM(File out, 			BlkImgDataSrc imgSrc, 			int n1,int n2,int n3) throws IOException{        // Check that imgSrc is of the correct type        // Check that the component index is valid        if ((n1 < 0) || (n1 >= imgSrc.getNumComps()) ||            (n2 < 0) || (n2 >= imgSrc.getNumComps()) ||            (n3 < 0) || (n3 >= imgSrc.getNumComps()) ||            (imgSrc.getNomRangeBits(n1) > 8) ||             (imgSrc.getNomRangeBits(n2) > 8) ||            (imgSrc.getNomRangeBits(n3) > 8)) {            throw new IllegalArgumentException();        }        // Initialize        w = imgSrc.getCompImgWidth(n1);        h = imgSrc.getCompImgHeight(n1);        // Check that all components have same width and height        if (w != imgSrc.getCompImgWidth(n2) ||            w != imgSrc.getCompImgWidth(n3) ||            h != imgSrc.getCompImgHeight(n2) ||            h != imgSrc.getCompImgHeight(n3)) {            throw new IllegalArgumentException();        }        // Continue initialization        if (out.exists() && !out.delete()) {            throw new IOException("Could not reset file");        }        this.out = new RandomAccessFile(out,"rw");        src = imgSrc;        cps[0] = n1;        cps[1] = n2;        cps[2] = n3;        fb[0] = imgSrc.getFixedPoint(n1);        fb[1] = imgSrc.getFixedPoint(n2);        fb[2] = imgSrc.getFixedPoint(n3);                levShift[0] = 1<< (imgSrc.getNomRangeBits(n1)-1);        levShift[1] = 1<< (imgSrc.getNomRangeBits(n2)-1);        levShift[2] = 1<< (imgSrc.getNomRangeBits(n3)-1);                writeHeaderInfo();    }    /**     * Creates a new writer to the specified file, to write data from the     * specified component.     *     * <P>The three components that will be written as R, G and B must be     * specified through the b1, b2 and b3 arguments.     *     * @param fname The name of the file where to write the data     *     * @param imgSrc The source from where to get the image data to     * write.     *     * @param n1 The index of the first component from where to get the data,     * that will be written as the red channel.     *     * @param n2 The index of the second component from where to get the data,     * that will be written as the green channel.     *     * @param n3 The index of the third component from where to get the data,     * that will be written as the green channel.     *     * @see DataBlk     * */    public ImgWriterPPM(String fname, 			BlkImgDataSrc imgSrc, 			int n1,int n2,int n3) throws IOException {            this(new File(fname), imgSrc, n1, n2, n3);    }                  /**     * Closes the underlying file or netwrok connection to where the data is     * written. Any call to other methods of the class become illegal after a     * call to this one.     *     * @exception IOException If an I/O error occurs.     * */    public void close() throws IOException {        int i;        // Finish writing the file, writing 0s at the end if the data at end        // has not been written.        if (out.length() != 3*w*h+offset) {            // Goto end of file            out.seek(out.length());            // Fill with 0s n all the components            for (i = 3*w*h+offset-(int)out.length(); i >0; i--) {                out.writeByte(0);            }        }        out.close();        src = null;        out = null;        db = null;    }    /**     * Writes all buffered data to the file or resource.     *     * @exception IOException If an I/O error occurs.     * */    public void flush() throws IOException {        // No flush needed here since we are using a RandomAccessFile Get rid        // of line buffer (is this a good choice?)        buf = null;    }    /**     * Writes the data of the specified area to the file, coordinates are     * relative to the current tile of the source. Before writing, the     * coefficients are limited to the nominal range.     *     * <P>This method may not be called concurrently from different threads.     *     * <P>If the data returned from the BlkImgDataSrc source is progressive,     * then it is requested over and over until it is not progressive anymore.     *     * @param ulx The horizontal coordinate of the upper-left corner of the     * area to write, relative to the current tile.     *     * @param uly The vertical coordinate of the upper-left corner of the area     * to write, relative to the current tile.     *     * @param width The width of the area to write.     *     * @param height The height of the area to write.     *     * @exception IOException If an I/O error occurs.     * */    public void write(int ulx, int uly, int w, int h) throws IOException{        int k,j,i,c;        // In local variables for faster access        int fracbits;        // variables used during coeff saturation        int shift,tmp,maxVal;        int tOffx, tOffy;      // Active tile offset in the X and Y direction                // Active tiles in all components have same offset since they are at        // same resolution (PPM does not support anything else)        tOffx = src.getULX(cps[0])-            (src.getImgULX()+src.getCompSubsX(cps[0])-1)/            src.getCompSubsX(cps[0]);        tOffy = src.getULY(cps[0])-            (src.getImgULY()+src.getCompSubsY(cps[0])-1)/            src.getCompSubsY(cps[0]);        // Check the array size        if (db.data != null && db.data.length < w) {            // A new one will be allocated by getInternCompData()            db.data = null;        }                // Check the line buffer        if (buf == null || buf.length < 3*w) {            buf = new byte[3*w];        }        // Write the data to the file        // Write line by line        for (i = 0; i < h; i++) {            // Write into buffer first loop over the three components and            // write for each            for(c=0;c<3;c++){                maxVal= (1<<src.getNomRangeBits(cps[c]))-1;                shift = levShift[c];                            // Initialize db                db.ulx = ulx;                db.uly = uly+i;                db.w = w;                db.h = 1;                // Request the data and make sure it is not progressive                do {                    db = (DataBlkInt)src.getInternCompData(db,cps[c]);                } while (db.progressive);                // Get the fracbits value                fracbits = fb[c];                // Write all bytes in the line                if (fracbits == 0) {                    for (k = db.offset+w-1, j=3*w-1+c-2; j>=0; k--) {                        tmp = db.data[k]+shift;                        buf[j] = (byte)((tmp<0)? 0 : ((tmp>maxVal)?                                                      maxVal : tmp));                        j -= 3;                    }                }                else {                    for (k = db.offset+w-1, j=3*w-1+c-2; j>=0; k--) {                        tmp = (db.data[k]>>>fracbits)+shift;                        buf[j] = (byte)((tmp<0)? 0 : ((tmp>maxVal)?                                                      maxVal : tmp));                        j -= 3;                    }                }               }            // Write buffer into file            out.seek(offset+3*(this.w*(uly+tOffy+i)+ulx+tOffx));            out.write(buf,0,3*w);        }    }        /**     * Writes the source's current tile to the output. The requests of data     * issued to the source BlkImgDataSrc object are done by strips, in order     * to reduce memory usage.     *     * <P>If the data returned from the BlkImgDataSrc source is progressive,     * then it is requested over and over until it is not progressive any     * more.     *     * @exception IOException If an I/O error occurs.     * */    public void write() throws IOException {        int i;        int tw = src.getWidth();  // Tile width         int th = src.getHeight();  // Tile height        // Write in strips        for (i=0; i <th ; i+=DEF_STRIP_HEIGHT) {            write(0,i,tw,((th-i) < DEF_STRIP_HEIGHT) ? th-i : DEF_STRIP_HEIGHT);        }    }        /**     * Writes the header info of the PPM file :     *     * P6<br>     *     * width height<br>     *     * 255<br>     *     * @exception IOException If there is an I/O Error      * */     private void writeHeaderInfo() throws IOException{        byte[] byteVals;        int i;        String val;                // write 'P6' to file        out.seek(0);        out.write(80);        out.write(54);        out.write(10); // new line        offset=3;        // Write width in ASCII        val=String.valueOf(w);        byteVals=val.getBytes();        for(i=0;i<byteVals.length;i++){            out.write(byteVals[i]);            offset++;        }        out.write(32); // blank        offset++;        // Write height in ASCII        val=String.valueOf(h);        byteVals=val.getBytes();        for(i=0;i<byteVals.length;i++){            out.write(byteVals[i]);            offset++;        }                out.write(10); // newline        out.write(50); // '2'        out.write(53); // '5'        out.write(53); // '5'        out.write(10); // newline        offset+=5;     }         /**     * Returns a string of information about the object, more than 1 line     * long. The information string includes information from the underlying     * RandomAccessFile (its toString() method is called in turn).     *     * @return A string of information about the object.     * */    public String toString() {        return "ImgWriterPPM: WxH = " + w + "x" + h + ", Components = " +            cps[0]+","+cps[1]+","+cps[2]+ "\nUnderlying RandomAccessFile:\n" +             out.toString();    }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本欧美在线观看| 色哟哟日韩精品| 色激情天天射综合网| 国产日韩欧美麻豆| 色综合av在线| 久久久久国产精品麻豆ai换脸 | 亚洲午夜精品网| 在线免费观看成人短视频| 麻豆精品新av中文字幕| 不卡视频免费播放| 色成年激情久久综合| 日本一区二区三区dvd视频在线| 五月天视频一区| 欧美在线观看一区二区| 国产精品嫩草99a| 国产制服丝袜一区| 精品国产人成亚洲区| 亚洲一区二区欧美日韩| 色婷婷久久综合| 专区另类欧美日韩| 波波电影院一区二区三区| 久久在线观看免费| 美美哒免费高清在线观看视频一区二区 | 日韩电影在线免费| 在线观看亚洲专区| 国产精品热久久久久夜色精品三区 | 水蜜桃久久夜色精品一区的特点| 色综合天天狠狠| 最新高清无码专区| www.在线成人| 亚洲欧美偷拍卡通变态| 成人黄色网址在线观看| 久久精品欧美一区二区三区麻豆| 精品影院一区二区久久久| 日韩三级av在线播放| 日韩精品欧美成人高清一区二区| 精品视频在线视频| 亚洲成人黄色小说| 制服丝袜亚洲色图| 久久国产生活片100| 欧美大白屁股肥臀xxxxxx| 久久精品国产久精国产爱| 日韩欧美一卡二卡| 国产一级精品在线| 国产精品久久国产精麻豆99网站| 欧美日韩国产精品自在自线| 亚洲一区二区不卡免费| 欧美久久婷婷综合色| 日本不卡一二三区黄网| 精品久久国产老人久久综合| 国产99久久久国产精品潘金网站| 亚洲欧洲成人精品av97| 91精品办公室少妇高潮对白| 亚洲一区免费视频| 日韩欧美国产综合在线一区二区三区| 久久成人免费日本黄色| 国产色婷婷亚洲99精品小说| 91香蕉视频黄| 日韩av一区二区在线影视| 久久精品视频一区二区三区| 99re6这里只有精品视频在线观看 99re8在线精品视频免费播放 | 最新久久zyz资源站| 欧美视频在线观看一区二区| 琪琪久久久久日韩精品| 26uuu成人网一区二区三区| 不卡影院免费观看| 五月天激情综合网| 国产精品乱人伦中文| 在线播放欧美女士性生活| 国产激情视频一区二区在线观看 | 国产在线精品一区在线观看麻豆| 中文字幕一区二| 91精品在线观看入口| 成人丝袜视频网| 午夜精品福利在线| 欧美激情在线观看视频免费| 欧美高清hd18日本| 99精品国产91久久久久久| 蜜臀av一级做a爰片久久| 亚洲色欲色欲www在线观看| 日韩亚洲欧美一区二区三区| 91久久精品一区二区| 国产精品123| 首页亚洲欧美制服丝腿| 欧美国产精品一区| 国产欧美日韩亚州综合| 欧美精品第一页| 色婷婷av一区二区三区gif| 激情都市一区二区| 日韩国产精品久久久久久亚洲| 中文字幕一区二区三区蜜月| 久久免费电影网| 91精品国产综合久久久久久漫画| 一本到不卡精品视频在线观看| 国产乱码字幕精品高清av | 日韩亚洲欧美在线| 欧美欧美欧美欧美首页| 91一区二区三区在线播放| 激情综合色丁香一区二区| 婷婷中文字幕综合| 亚洲网友自拍偷拍| 一区二区三区在线观看国产 | 亚洲精品久久久久久国产精华液| 久久久久久久综合日本| 精品国产乱码久久| 日韩欧美精品三级| 欧美一级高清大全免费观看| 欧美人成免费网站| 欧美日韩一区高清| 欧美日韩高清在线播放| 欧美午夜影院一区| 欧美性色黄大片| 欧美无砖专区一中文字| 在线日韩一区二区| 欧美视频在线不卡| 欧美剧情片在线观看| 欧美高清精品3d| 日韩欧美国产三级电影视频| 日韩一区二区三| 日韩三级在线免费观看| 日韩欧美国产一区二区在线播放| 欧美一区二区三区免费视频 | 制服丝袜亚洲播放| 欧美一区日本一区韩国一区| 6080亚洲精品一区二区| 日韩一区二区三| 国产亚洲精品免费| 日韩和欧美一区二区| 欧美aaaaaa午夜精品| 国产一区激情在线| 成人av在线资源网站| 一本色道久久综合狠狠躁的推荐| 色播五月激情综合网| 4438x亚洲最大成人网| 欧美一二三区在线观看| 亚洲精品一区二区精华| 国产日韩欧美精品在线| 综合分类小说区另类春色亚洲小说欧美| 亚洲欧美一区二区三区久本道91| 亚洲高清一区二区三区| 久久成人免费网站| 成人av网站免费| 欧美日韩在线综合| 欧美成人精品1314www| 国产农村妇女精品| 亚洲亚洲人成综合网络| 精品一区二区三区在线观看| 成人性生交大片免费看中文网站| 99精品视频一区| 日韩一区二区三区免费观看| 国产免费成人在线视频| 亚洲欧美福利一区二区| 日韩影视精彩在线| 不卡欧美aaaaa| 日韩一区二区三区在线观看| 中文av一区特黄| 性久久久久久久| 国产成人精品综合在线观看| 欧美写真视频网站| 久久综合色8888| 亚洲综合丝袜美腿| 国产成人午夜99999| 欧美日韩国产美| 中文字幕日韩一区| 国产一区欧美日韩| 欧美三级电影网站| 国产精品女上位| 国产一区二区三区四| 欧洲av在线精品| 国产精品福利一区| 国产又粗又猛又爽又黄91精品| 欧美日本在线播放| 亚洲免费av观看| 成人精品电影在线观看| 欧美videos大乳护士334| 亚洲一二三区视频在线观看| 91一区二区三区在线观看| 国产亚洲综合性久久久影院| 日本一区中文字幕 | 欧美手机在线视频| 日日欢夜夜爽一区| 国产成人在线视频网址| 8x8x8国产精品| 一区二区三区日韩精品视频| 国产一区二区调教| 69堂成人精品免费视频| 99久久精品久久久久久清纯| 国产视频一区在线播放| 亚洲国产精品成人综合| 成人av电影在线| 亚洲高清免费视频| 日韩欧美综合一区| 国产激情一区二区三区四区| 亚洲欧美激情小说另类| 欧美人妇做爰xxxⅹ性高电影 | 精品国产sm最大网站免费看| 国产成人小视频| 国产91精品精华液一区二区三区| 亚洲欧洲国产专区| 欧美一区二区在线视频|