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

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

?? pngencoderb.java

?? 傳感器網絡中的嵌入式操作系統源代碼
?? JAVA
字號:
// $Id: PngEncoderB.java,v 1.1.4.1 2003/08/18 22:09:43 cssharp Exp $package net.tinyos.plot;//package com.keypoint;/** * PngEncoderB takes a Java BufferedImage object and creates a byte string which can be saved as a PNG file. * The encoder will accept BufferedImages with eight-bit samples * or 4-byte ARGB samples.  *  * There is also code to handle 4-byte samples returned as * one int per pixel, but that has not been tested. * * Thanks to Jay Denny at KeyPoint Software *    http://www.keypoint.com/ * who let me develop this code on company time. * * You may contact me with (probably very-much-needed) improvements, * comments, and bug fixes at: * *   david@catcode.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. *  * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * Lesser General Public License for more details. *  * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA * A copy of the GNU LGPL may be found at * http://www.gnu.org/copyleft/lesser.html, * * @author J. David Eisenberg * @version 1.4, 31 March 2000 */import java.awt.*;import java.awt.image.*;import java.util.*;import java.util.zip.*;import java.io.*;public class PngEncoderB extends PngEncoder {    protected BufferedImage image;    protected WritableRaster wRaster;    protected int tType;    /**     * Class constructor     *     */    public PngEncoderB()    {        this( null, false, FILTER_NONE, 0 );    }    /**     * Class constructor specifying BufferedImage to encode, with no alpha channel encoding.     *     * @param image A Java BufferedImage object     */    public PngEncoderB( BufferedImage image )    {        this(image, false, FILTER_NONE, 0);    }    /**     * Class constructor specifying BufferedImage to encode, and whether to encode alpha.     *     * @param image A Java BufferedImage object     * @param encodeAlpha Encode the alpha channel? false=no; true=yes     */    public PngEncoderB( BufferedImage image, boolean encodeAlpha )    {        this( image, encodeAlpha, FILTER_NONE, 0 );    }    /**     * Class constructor specifying BufferedImage to encode, whether to encode alpha, and filter to use.     *     * @param image A Java BufferedImage object     * @param encodeAlpha Encode the alpha channel? false=no; true=yes     * @param whichFilter 0=none, 1=sub, 2=up     */    public PngEncoderB( BufferedImage image, boolean encodeAlpha,       int whichFilter )    {        this( image, encodeAlpha, whichFilter, 0 );    }    /**     * Class constructor specifying BufferedImage source to encode, whether to encode alpha, filter to use, and compression level     *     * @param image A Java BufferedImage object     * @param encodeAlpha Encode the alpha channel? false=no; true=yes     * @param whichFilter 0=none, 1=sub, 2=up     * @param compLevel 0..9     */    public PngEncoderB( BufferedImage image, boolean encodeAlpha,      int whichFilter, int compLevel )    {        this.image = image;        this.encodeAlpha = encodeAlpha;        setFilter( whichFilter );        if (compLevel >=0 && compLevel <=9)        {            this.compressionLevel = compLevel;        }    }    /**     * Set the BufferedImage to be encoded     *     * @param BufferedImage A Java BufferedImage object     */    public void setImage( BufferedImage image )    {        this.image = image;        pngBytes = null;    }    /**     * Creates an array of bytes that is the PNG equivalent of the current image, specifying whether to encode alpha or not.     *     * @param encodeAlpha boolean false=no alpha, true=encode alpha     * @return an array of bytes, or null if there was a problem     */    public byte[] pngEncode( boolean encodeAlpha )    {        byte[]  pngIdBytes = { -119, 80, 78, 71, 13, 10, 26, 10 };        int     i;        if (image == null)        {            return null;        }        width = image.getWidth( null );        height = image.getHeight( null );        this.image = image;        if (!establishStorageInfo())        {            return null;        }                /*         * start with an array that is big enough to hold all the pixels         * (plus filter bytes), and an extra 200 bytes for header info         */        pngBytes = new byte[((width+1) * height * 3) + 200];        /*         * keep track of largest byte written to the array         */        maxPos = 0;        bytePos = writeBytes( pngIdBytes, 0 );        hdrPos = bytePos;        writeHeader();        dataPos = bytePos;        if (writeImageData())        {            writeEnd();            pngBytes = resizeByteArray( pngBytes, maxPos );        }        else        {            pngBytes = null;        }        return pngBytes;    }    /**     * Creates an array of bytes that is the PNG equivalent of the current image.     * Alpha encoding is determined by its setting in the constructor.     *     * @return an array of bytes, or null if there was a problem     */    public byte[] pngEncode()    {        return pngEncode( encodeAlpha );    }    /**     *      * Get and set variables that determine how picture is stored.     *     * Retrieves the writable raster of the buffered image,     * as well its transfer type.     *     * Sets number of output bytes per pixel, and, if only     * eight-bit bytes, turns off alpha encoding.     * @return true if 1-byte or 4-byte data, false otherwise     */    protected boolean establishStorageInfo()    {        int dataBytes;            wRaster = image.getRaster();        dataBytes = wRaster.getNumDataElements();        tType = wRaster.getTransferType();        if (((tType == DataBuffer.TYPE_BYTE) && (dataBytes == 4)) ||            ((tType == DataBuffer.TYPE_INT) && (dataBytes == 1)) )        {            bytesPerPixel = (encodeAlpha) ? 4 : 3;        }        else if ((tType == DataBuffer.TYPE_BYTE) && (dataBytes == 1))        {            bytesPerPixel = 1;            encodeAlpha = false;    // one-byte samples        }        else        {            return false;        }        return true;    }    /**     * Write a PNG "IHDR" chunk into the pngBytes array.     */    protected void writeHeader()    {        int startPos;        startPos = bytePos = writeInt4( 13, bytePos );        bytePos = writeString( "IHDR", bytePos );        width = image.getWidth( null );        height = image.getHeight( null );        bytePos = writeInt4( width, bytePos );        bytePos = writeInt4( height, bytePos );        bytePos = writeByte( 8, bytePos ); // bit depth        if (bytesPerPixel != 1)        {            bytePos = writeByte( (encodeAlpha) ? 6 : 2, bytePos ); // direct model        }        else        {            bytePos = writeByte( 3, bytePos ); // indexed        }        bytePos = writeByte( 0, bytePos ); // compression method        bytePos = writeByte( 0, bytePos ); // filter method        bytePos = writeByte( 0, bytePos ); // no interlace        crc.reset();        crc.update( pngBytes, startPos, bytePos-startPos );        crcValue = crc.getValue();        bytePos = writeInt4( (int) crcValue, bytePos );    }    protected void writePalette( IndexColorModel icm )    {        byte[] redPal = new byte[256];        byte[] greenPal = new byte[256];        byte[] bluePal = new byte[256];        byte[] allPal = new byte[768];        int i;        icm.getReds( redPal );        icm.getGreens( greenPal );        icm.getBlues( bluePal );        for (i=0; i<256; i++)        {            allPal[i*3  ] = redPal[i];            allPal[i*3+1] = greenPal[i];            allPal[i*3+2] = bluePal[i];        }        bytePos = writeInt4( 768, bytePos );        bytePos = writeString( "PLTE", bytePos );        crc.reset();        crc.update("PLTE".getBytes());        bytePos = writeBytes( allPal, bytePos );        crc.update( allPal );        crcValue = crc.getValue();        bytePos = writeInt4( (int) crcValue, bytePos );    }    /**     * Write the image data into the pngBytes array.     * This will write one or more PNG "IDAT" chunks. In order     * to conserve memory, this method grabs as many rows as will     * fit into 32K bytes, or the whole image; whichever is less.     *     *     * @return true if no errors; false if error grabbing pixels     */    protected boolean writeImageData()    {        int rowsLeft = height;  // number of rows remaining to write        int startRow = 0;       // starting row to process this time through        int nRows;              // how many rows to grab at a time        byte[] scanLines;       // the scan lines to be compressed        int scanPos;            // where we are in the scan lines        int startPos;           // where this line's actual pixels start (used for filtering)        int readPos;            // position from which source pixels are read        byte[] compressedLines; // the resultant compressed lines        int nCompressed;        // how big is the compressed area?        byte[] pixels;          // storage area for byte-sized pixels        int[] iPixels;          // storage area for int-sized pixels        Deflater scrunch = new Deflater( compressionLevel );        ByteArrayOutputStream outBytes =             new ByteArrayOutputStream(1024);                    DeflaterOutputStream compBytes =            new DeflaterOutputStream( outBytes, scrunch );        if (bytesPerPixel == 1)        {            writePalette( (IndexColorModel) image.getColorModel() );        }        try        {            while (rowsLeft > 0)            {                nRows = Math.min( 32767 / (width*(bytesPerPixel+1)), rowsLeft );                // nRows = rowsLeft;                /*                 * Create a data chunk. scanLines adds "nRows" for                 * the filter bytes.                 */                scanLines = new byte[width * nRows * bytesPerPixel +  nRows];                if (filter == FILTER_SUB)                {                    leftBytes = new byte[16];                }                if (filter == FILTER_UP)                {                    priorRow = new byte[width*bytesPerPixel];                }                if (tType == DataBuffer.TYPE_BYTE)                {                    pixels = (byte[]) wRaster.getDataElements(                        0, startRow, width, nRows, null );                    iPixels = null;                }                else                {                    iPixels = (int[]) wRaster.getDataElements(                        0, startRow, width, nRows, null );                    pixels = null;                }                scanPos = 0;                readPos = 0;                startPos = 1;                for (int i=0; i<width*nRows; i++)                {                    if (i % width == 0)                    {                        scanLines[scanPos++] = (byte) filter;                         startPos = scanPos;                    }                    if (bytesPerPixel == 1)                    {                        scanLines[scanPos++] = pixels[readPos++];                    }                    else if (tType == DataBuffer.TYPE_BYTE)                    {                        scanLines[scanPos++] = pixels[readPos++];                        scanLines[scanPos++] = pixels[readPos++];                        scanLines[scanPos++] = pixels[readPos++];                        if (encodeAlpha)                        {                            scanLines[scanPos++] = pixels[readPos++];                        }                        else                        {                            readPos++;                        }                    }                    else                    {                        scanLines[scanPos++] = (byte) ((iPixels[readPos] >> 16) & 0xff);                        scanLines[scanPos++] = (byte) ((iPixels[readPos] >>  8) & 0xff);                        scanLines[scanPos++] = (byte) ((iPixels[readPos]      ) & 0xff);                        if (encodeAlpha)						{                            scanLines[scanPos++] = (byte) ((iPixels[readPos] >> 24) & 0xff );                        }                        readPos++;                    }                    if ((i % width == width-1) && (filter != FILTER_NONE))                    {                        if (filter == FILTER_SUB)                        {                            filterSub( scanLines, startPos, width );                        }                        if (filter == FILTER_UP)                        {                            filterUp( scanLines, startPos, width );                        }                    }                }                /*                 * Write these lines to the output area                 */                compBytes.write( scanLines, 0, scanPos );                startRow += nRows;                rowsLeft -= nRows;            }            compBytes.close();            /*             * Write the compressed bytes             */            compressedLines = outBytes.toByteArray();            nCompressed = compressedLines.length;            crc.reset();            bytePos = writeInt4( nCompressed, bytePos );            bytePos = writeString("IDAT", bytePos );            crc.update("IDAT".getBytes());            bytePos = writeBytes( compressedLines, nCompressed, bytePos );            crc.update( compressedLines, 0, nCompressed );            crcValue = crc.getValue();            bytePos = writeInt4( (int) crcValue, bytePos );            scrunch.finish();            return true;        }        catch (IOException e)        {            System.err.println( e.toString());            return false;        }    }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品欧美一区二区久久| eeuss鲁一区二区三区| 亚洲图片欧美色图| 亚洲一级在线观看| 亚洲伊人色欲综合网| 亚洲国产一区二区三区青草影视| 亚洲日本乱码在线观看| 亚洲色图19p| 日韩精品一二三区| 激情小说欧美图片| 国产91综合一区在线观看| 97精品国产露脸对白| 在线免费观看日本一区| 91精品国产综合久久香蕉的特点| 日韩欧美一二三四区| 国产欧美一区二区精品忘忧草 | 亚洲一区二区av在线| 天天亚洲美女在线视频| 国产精品综合二区| 95精品视频在线| 69堂国产成人免费视频| 欧美精品一区二区三区在线播放 | 亚洲精品乱码久久久久久| 午夜精品视频一区| 国产一区二区三区电影在线观看| 久久成人久久爱| 国产成人小视频| 91国偷自产一区二区开放时间| 欧美日韩国产三级| 国产日韩欧美精品一区| 午夜欧美大尺度福利影院在线看| 麻豆精品久久精品色综合| 成人激情图片网| 51精品久久久久久久蜜臀| 国产精品乱人伦中文| 亚洲成人精品在线观看| 国产成人99久久亚洲综合精品| 欧美日韩一区二区三区在线| 久久亚洲影视婷婷| 亚洲国产精品人人做人人爽| 国产精品一区二区久久精品爱涩 | 91丨porny丨国产入口| 日韩午夜电影在线观看| 日韩美女啊v在线免费观看| 开心九九激情九九欧美日韩精美视频电影 | 免费在线观看不卡| 91日韩一区二区三区| www激情久久| 视频一区二区三区在线| 91亚洲资源网| 久久精品视频在线看| 免费在线观看精品| 欧美日免费三级在线| 中文久久乱码一区二区| 国产综合久久久久久久久久久久| 欧美体内she精高潮| 久久久久久久久99精品| 日本不卡的三区四区五区| 欧美性大战久久| 亚洲免费三区一区二区| 成人精品一区二区三区中文字幕| 日韩精品一区二区三区四区视频 | 日韩主播视频在线| 欧洲一区在线观看| 亚洲精品成人精品456| 国产很黄免费观看久久| 久久一区二区三区国产精品| 久久国产麻豆精品| 精品久久久影院| 激情欧美一区二区三区在线观看| 这里只有精品电影| 三级成人在线视频| 69av一区二区三区| 欧美a级理论片| 26uuu另类欧美| 国产精品一区二区果冻传媒| 久久久久国色av免费看影院| 国产精品夜夜嗨| 日本一区二区成人| 色综合天天做天天爱| 亚洲欧美另类在线| 欧美日韩亚洲另类| 日本欧美大码aⅴ在线播放| 51午夜精品国产| 麻豆视频一区二区| 精品盗摄一区二区三区| 成人一区在线观看| 一区av在线播放| 91精品久久久久久久99蜜桃| 国产在线精品免费av| 欧美mv日韩mv国产| 99久久99久久免费精品蜜臀| 亚洲午夜国产一区99re久久| 欧美一区二区三区视频| 国产精品一区二区三区四区| 亚洲婷婷综合久久一本伊一区| 在线亚洲人成电影网站色www| 亚洲午夜免费福利视频| 精品理论电影在线| 一本久道久久综合中文字幕| 亚洲aⅴ怡春院| 久久久精品黄色| 在线精品视频一区二区三四| 麻豆精品在线播放| 亚洲欧洲中文日韩久久av乱码| 91精品国产一区二区| 懂色av中文一区二区三区| 亚洲成人av免费| 欧美韩国日本一区| 欧美精品亚洲二区| 成人性生交大合| 午夜精品久久久久久久久| 国产日韩精品一区二区三区| 欧美欧美欧美欧美| a美女胸又www黄视频久久| 青娱乐精品在线视频| **网站欧美大片在线观看| 精品三级av在线| 欧美日韩1234| 99久久99久久精品免费看蜜桃| 蜜臀av一区二区| 亚洲一本大道在线| 中文字幕视频一区| 久久综合999| 8v天堂国产在线一区二区| 91亚洲男人天堂| 成人丝袜高跟foot| 国产呦萝稀缺另类资源| 秋霞电影一区二区| 亚洲一区在线播放| 亚洲免费在线视频| 国产精品乱子久久久久| 久久嫩草精品久久久久| 日韩欧美国产麻豆| 欧美日韩一区精品| 欧美在线999| 色综合久久久网| 成人高清在线视频| 不卡视频在线看| 成人久久久精品乱码一区二区三区| 看电视剧不卡顿的网站| 蜜桃一区二区三区四区| 日本一道高清亚洲日美韩| 亚洲午夜激情av| 香蕉乱码成人久久天堂爱免费| 美女在线视频一区| 丝袜亚洲另类欧美| 亚洲第一成人在线| 亚洲第一久久影院| 亚洲成a人在线观看| 偷拍一区二区三区四区| 三级影片在线观看欧美日韩一区二区| 亚洲欧美日韩人成在线播放| 自拍偷拍亚洲欧美日韩| 一区二区三区中文字幕在线观看| 亚洲免费av网站| 亚洲福利电影网| 久久精品国产澳门| 狠狠色综合色综合网络| 国产酒店精品激情| 成人v精品蜜桃久久一区| av在线不卡电影| 91成人在线观看喷潮| 538prom精品视频线放| 日韩欧美一区二区久久婷婷| 久久综合网色—综合色88| 日本一区二区动态图| 亚洲三级在线免费| 亚洲18女电影在线观看| 另类欧美日韩国产在线| 成人自拍视频在线观看| 91小视频免费看| 欧美人妖巨大在线| 久久久久久**毛片大全| 亚洲精品视频免费观看| 久久精品国产亚洲5555| 成人免费高清在线观看| 欧美日韩成人在线| 国产视频在线观看一区二区三区 | 国产在线精品一区二区夜色| 国产呦萝稀缺另类资源| 色综合天天在线| 日韩一区二区三区免费观看| 国产欧美日韩精品a在线观看| 一区二区不卡在线视频 午夜欧美不卡在 | 亚洲国产毛片aaaaa无费看| 麻豆久久久久久| 99综合影院在线| 日韩欧美一区在线观看| 国产精品二三区| 乱中年女人伦av一区二区| 成人精品一区二区三区四区| 777xxx欧美| 一区二区三区在线视频观看58 | 亚洲人妖av一区二区| 蜜臀av性久久久久蜜臀aⅴ四虎| 不卡的电视剧免费网站有什么| 欧美色精品在线视频| 中文字幕在线观看不卡视频| 久久精品国产99久久6|