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

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

?? pngencoderb.java

?? nesC寫的heed算法
?? 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一区二区三区免费野_久草精品视频
激情综合网激情| 精品精品国产高清a毛片牛牛 | 青青草精品视频| 粗大黑人巨茎大战欧美成人| 欧美日韩视频不卡| 国产精品视频麻豆| 国产麻豆欧美日韩一区| 欧美精品1区2区| 一区二区三区四区乱视频| 国产在线播放一区二区三区| 欧美精品乱码久久久久久| 国产精品看片你懂得| 国产在线一区观看| 日韩欧美国产小视频| 午夜久久久久久| 欧美日韩一区二区三区高清| 国产精品国产精品国产专区不蜜| 国产在线精品一区在线观看麻豆| 欧美精品自拍偷拍| 亚洲国产一区二区三区青草影视| 92国产精品观看| 亚洲视频免费看| 99视频超级精品| 国产精品视频九色porn| 成人精品一区二区三区四区| 国产欧美综合在线| 国产91富婆露脸刺激对白| 久久免费的精品国产v∧| 国产在线视频一区二区| 欧美精品一区二区三区四区| 激情综合五月婷婷| 久久久久国产成人精品亚洲午夜| 国产麻豆午夜三级精品| 精品国产伦一区二区三区免费| 蜜臀av一区二区在线观看| 日韩精品自拍偷拍| 国产美女精品在线| 国产精品乱人伦中文| 成人av在线播放网站| 最近日韩中文字幕| 91行情网站电视在线观看高清版| 亚洲在线观看免费| 日韩一级欧美一级| 国产精品77777竹菊影视小说| 中文字幕精品—区二区四季| 成人高清视频免费观看| 亚洲视频网在线直播| 欧美日韩视频在线观看一区二区三区| 午夜免费久久看| 欧美va亚洲va| av网站免费线看精品| 国产精品成人免费在线| 欧美中文字幕久久| 精品一区二区在线免费观看| 国产精品久久久久影院色老大| 色婷婷激情久久| 日本不卡高清视频| 国产精品色眯眯| 欧美日韩久久不卡| 国产福利精品一区| 亚洲精品午夜久久久| 日韩欧美中文字幕公布| 国产成人免费视频精品含羞草妖精| 国产精品成人在线观看| 制服丝袜av成人在线看| 国产成人一区在线| 一区二区欧美精品| 久久亚洲私人国产精品va媚药| 色婷婷久久久久swag精品| 精品制服美女久久| 亚洲综合色自拍一区| 久久久久久**毛片大全| 欧美日韩一区二区不卡| 国产不卡高清在线观看视频| 亚洲午夜在线观看视频在线| 久久久天堂av| 91精品中文字幕一区二区三区 | 亚洲成a人片在线不卡一二三区| 精品国产乱码久久久久久1区2区| 91麻豆免费看片| 国产成人日日夜夜| 麻豆91精品91久久久的内涵| 亚洲精品视频在线| 国产性做久久久久久| 日韩一区二区在线播放| 色一情一乱一乱一91av| 国产一区二区三区| 日韩高清在线不卡| 亚洲综合色丁香婷婷六月图片| 国产午夜亚洲精品不卡| 日本欧美一区二区三区乱码| 在线中文字幕不卡| 午夜av一区二区| 综合久久综合久久| 国产女人18毛片水真多成人如厕| 69久久99精品久久久久婷婷 | 国产精品色噜噜| 久久一夜天堂av一区二区三区| 欧美三级视频在线| 日本电影亚洲天堂一区| 99久久99久久久精品齐齐| 丁香婷婷综合色啪| 国产一区二区三区免费看| 久久精品999| 日本中文一区二区三区| 亚洲成人综合在线| 亚洲国产精品一区二区www在线| 亚洲日本在线观看| 亚洲精品成人精品456| 综合网在线视频| 亚洲精品国久久99热| 亚洲综合在线电影| 一区二区三区四区不卡视频| 一区二区三区小说| 亚洲成人黄色小说| 日韩专区一卡二卡| 日韩黄色小视频| 久久精品999| 黄色资源网久久资源365| 国产裸体歌舞团一区二区| 国产乱码精品一区二区三区五月婷| 男男视频亚洲欧美| 国内精品久久久久影院薰衣草| 韩国精品在线观看| 成人免费视频播放| 99精品久久只有精品| 欧美最猛黑人xxxxx猛交| 欧美色男人天堂| 精品卡一卡二卡三卡四在线| 国产午夜精品久久久久久免费视 | 久久只精品国产| 国产欧美一区二区三区沐欲| 自拍偷拍亚洲综合| 亚洲成人一区二区在线观看| 美女视频黄免费的久久 | 国产成人午夜精品影院观看视频 | 亚洲国产中文字幕在线视频综合| 午夜精品久久久久久久99樱桃 | 在线看日本不卡| 欧美一区二区三区视频在线观看| 欧美r级电影在线观看| 国产精品女主播av| 亚洲二区在线观看| 国模少妇一区二区三区| 99re热视频精品| 欧美一区二区三区免费大片| www国产精品av| 亚洲一区二区三区精品在线| 极品少妇一区二区三区精品视频| 91在线观看免费视频| 欧美丰满高潮xxxx喷水动漫| 久久精品网站免费观看| 亚洲成人激情社区| 成人午夜av在线| 7777女厕盗摄久久久| 国产精品网友自拍| 日韩精品福利网| av欧美精品.com| 日韩女优电影在线观看| 亚洲精品国产无套在线观| 国产在线视视频有精品| 欧美日韩精品一区视频| 国产精品无人区| 蜜乳av一区二区三区| 色女孩综合影院| 国产午夜精品美女毛片视频| 日韩国产高清在线| 一本久久综合亚洲鲁鲁五月天 | 日韩美女一区二区三区四区| 亚洲精品老司机| 粉嫩嫩av羞羞动漫久久久| 欧美一区二区三区视频在线| 亚洲私人黄色宅男| 成人永久免费视频| wwwwxxxxx欧美| 男人的天堂亚洲一区| 在线观看亚洲a| 亚洲欧美成人一区二区三区| 国产成人精品影院| 久久中文娱乐网| 精品一区二区三区免费视频| 欧美日韩黄视频| 亚洲午夜羞羞片| 色天使久久综合网天天| 国产精品三级av在线播放| 国产一区二区三区免费| 日韩欧美在线观看一区二区三区| 一区二区三区成人| 在线看国产日韩| 亚洲激情在线激情| 在线中文字幕一区| 亚洲综合区在线| 在线这里只有精品| 亚洲一二三四久久| 在线观看亚洲精品视频| 亚洲第一综合色| 3d动漫精品啪啪一区二区竹菊| 首页国产丝袜综合| 91精品国产91久久综合桃花| 丝袜诱惑亚洲看片|