亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
欧美又粗又大又爽| 成人黄色小视频在线观看| 亚洲欧洲一区二区在线播放| 国产欧美日韩视频一区二区| 久久久久久97三级| 久久精品视频一区| 中文字幕第一页久久| 国产精品三级电影| 亚洲婷婷在线视频| 亚洲精品乱码久久久久久日本蜜臀| 亚洲欧洲另类国产综合| 亚洲青青青在线视频| 亚洲一区二区三区四区五区中文 | 国产传媒日韩欧美成人| 欧美性高清videossexo| 欧美日韩美女一区二区| 欧美一区二区三区免费观看视频| 日韩精品综合一本久道在线视频| 精品国产电影一区二区| 中文字幕av免费专区久久| 亚洲美女区一区| 日韩精品免费专区| 国产成人亚洲精品青草天美| 色综合视频在线观看| 欧美日本在线观看| 久久精品人人做人人综合| 亚洲色图欧美在线| 美女任你摸久久| www.在线成人| 日韩欧美一卡二卡| 亚洲三级小视频| 美女一区二区在线观看| 成人短视频下载| 3atv在线一区二区三区| 欧美激情在线看| 日韩影院免费视频| 成人精品小蝌蚪| 91精品国产一区二区| 国产精品乱人伦一区二区| 五月天激情综合网| 成人网在线免费视频| 3atv一区二区三区| 亚洲欧美福利一区二区| 国产老妇另类xxxxx| 国产精品国产精品国产专区不片| 亚洲国产精品一区二区www在线| 国产伦精品一区二区三区在线观看| 日本精品视频一区二区| 国产精品视频线看| 精品制服美女久久| 91黄色免费网站| 亚洲国产精品成人综合| 精品综合免费视频观看| 欧美少妇性性性| 亚洲伦在线观看| 成人永久免费视频| 精品国产伦一区二区三区免费| 肉色丝袜一区二区| 欧美性猛交xxxxxx富婆| 亚洲欧美日韩小说| 99视频有精品| 国产免费成人在线视频| 久久66热偷产精品| 日韩一级在线观看| 免费成人性网站| 欧美一卡2卡三卡4卡5免费| 亚洲123区在线观看| 欧美日韩大陆在线| 亚洲福利一二三区| 欧美在线免费观看视频| 亚洲人成精品久久久久久| 99麻豆久久久国产精品免费 | 99久久免费精品高清特色大片| 日韩欧美一二三四区| 视频一区欧美精品| 欧美日韩二区三区| 一区二区三区精品在线观看| 99在线精品免费| 亚洲精品视频在线看| 欧美性大战久久久久久久蜜臀| 国产精品久久网站| 91亚洲精品久久久蜜桃网站| 亚洲裸体xxx| 欧美视频在线一区| 亚洲第一综合色| 欧美精品一二三区| 久久成人18免费观看| 欧美xfplay| 国产高清不卡一区| 最新日韩在线视频| 欧美羞羞免费网站| 亚洲r级在线视频| 日韩三级电影网址| 成人免费观看av| 亚洲一区二区不卡免费| 欧美一卡二卡三卡四卡| 国产不卡在线一区| 中文字幕综合网| 欧美一区二区视频观看视频| 精品一区二区av| 17c精品麻豆一区二区免费| 91在线小视频| 亚洲福利视频导航| 日韩视频永久免费| 99久久免费精品高清特色大片| 亚洲高清视频中文字幕| 久久久久综合网| 在线免费观看成人短视频| 麻豆成人免费电影| 久久99精品国产麻豆不卡| 1区2区3区欧美| 欧美mv日韩mv国产| 在线免费av一区| 国产在线不卡视频| 午夜视频在线观看一区二区| 久久久精品黄色| 6080国产精品一区二区| 成人动漫精品一区二区| 久久精品99国产精品| 亚洲福利视频三区| 一区免费观看视频| 久久久久久久久一| 欧美一级一区二区| 色婷婷av久久久久久久| 国产成人精品免费| 久久91精品国产91久久小草| 亚洲成人一区二区| 悠悠色在线精品| 国产精品国产三级国产aⅴ入口| 欧美精品一区二区三区蜜桃 | 五月天视频一区| 亚洲欧美韩国综合色| 国产午夜精品在线观看| 日韩欧美一级片| 在线电影一区二区三区| 欧美日韩一区不卡| 色诱亚洲精品久久久久久| 成人久久视频在线观看| 国产馆精品极品| 精品一区二区日韩| 久久精品av麻豆的观看方式| 五月婷婷综合网| 亚洲午夜一二三区视频| 亚洲午夜在线视频| 一区二区三区欧美在线观看| 亚洲三级在线免费观看| 亚洲人吸女人奶水| 亚洲人吸女人奶水| 亚洲一区二区三区中文字幕| 亚洲国产精品嫩草影院| 亚洲综合清纯丝袜自拍| 亚洲一区精品在线| 亚洲妇女屁股眼交7| 日韩电影免费在线观看网站| 免费久久精品视频| 国产伦精品一区二区三区视频青涩| 国产在线日韩欧美| 国产成人免费视频精品含羞草妖精| 激情国产一区二区 | 亚州成人在线电影| 三级不卡在线观看| 欧美三级日韩三级| 7878成人国产在线观看| 久久久亚洲欧洲日产国码αv| 亚洲国产成人私人影院tom| 亚洲美女一区二区三区| 亚洲成av人在线观看| 蜜桃视频一区二区三区 | 91麻豆蜜桃一区二区三区| 欧美在线观看你懂的| 欧美片在线播放| 久久精子c满五个校花| 综合电影一区二区三区| 亚洲福利一区二区三区| 精品一区二区三区欧美| 暴力调教一区二区三区| 欧美精品v日韩精品v韩国精品v| 欧美xxxxx牲另类人与| 亚洲欧美色综合| 日本午夜一区二区| 粉嫩一区二区三区性色av| 欧美性一二三区| 国产日韩欧美一区二区三区综合| 成人免费一区二区三区在线观看| 亚洲电影在线播放| 国产不卡一区视频| 欧美伦理电影网| 久久久久久免费| 五月激情综合色| www.亚洲色图| 日韩一区二区三免费高清| 国产精品久久久久久福利一牛影视| 一卡二卡欧美日韩| 韩国v欧美v日本v亚洲v| 欧美性受xxxx黑人xyx性爽| 国产日产欧美精品一区二区三区| 亚洲午夜一区二区| 99视频一区二区三区| 久久精品在线免费观看| 日本欧美肥老太交大片|