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

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

?? pngencoderb.java

?? l系統 l系統 l系統 l系統 l系統 l系統 l系統 l系統
?? JAVA
字號:
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一区二区三区免费野_久草精品视频
国产日韩精品一区二区浪潮av | 中文字幕免费不卡| 国产精品青草综合久久久久99| 一区二区在线免费观看| 国产一二三精品| 欧美日韩精品一区二区三区蜜桃| 久久夜色精品一区| 图片区小说区国产精品视频| 成人免费视频视频在线观看免费| 欧美一级理论片| 亚洲午夜免费福利视频| fc2成人免费人成在线观看播放 | 成人av影院在线| 欧美大胆人体bbbb| 日韩二区三区四区| 欧美午夜一区二区三区免费大片| 国产精品嫩草99a| 国产一区二区三区日韩| 91精品国产一区二区| 亚洲国产欧美日韩另类综合| 99视频有精品| 国产精品毛片久久久久久久| 国产成人精品在线看| 精品国产免费人成在线观看| 美女脱光内衣内裤视频久久网站 | 紧缚奴在线一区二区三区| 欧美三级电影精品| 一区二区三区 在线观看视频 | 国产精品另类一区| 国产精品中文有码| 2024国产精品视频| 国产一区二区三区四| 久久精品一区八戒影视| 国产福利一区在线观看| 日本一区二区三区高清不卡| 国产91露脸合集magnet| 久久久不卡影院| 成人永久aaa| 国产精品久久久久久久午夜片| 国产成人高清视频| 久久精品视频免费| av亚洲精华国产精华精华| 国产精品的网站| 欧日韩精品视频| 亚洲丝袜制服诱惑| 色拍拍在线精品视频8848| 亚洲午夜久久久久久久久电影网| 欧美午夜精品久久久久久孕妇 | 欧美日韩免费观看一区二区三区| 一区二区欧美国产| 欧美一区2区视频在线观看| 精品写真视频在线观看| 国产午夜一区二区三区| 91美女在线视频| 日韩精品欧美精品| 国产日韩欧美在线一区| 色婷婷综合久久| 蜜臀久久99精品久久久久久9| 久久综合色之久久综合| 91亚洲男人天堂| 奇米亚洲午夜久久精品| 国产欧美日韩精品一区| 欧美日韩亚洲丝袜制服| 国产精品亚洲成人| 洋洋成人永久网站入口| 久久婷婷成人综合色| 欧美最新大片在线看| 国内成+人亚洲+欧美+综合在线| 中文一区在线播放| 欧美一区二区三区四区视频| 成人午夜电影久久影院| 婷婷激情综合网| 中文字幕一区二区三区在线观看| 欧美色区777第一页| 国产成都精品91一区二区三| 一区av在线播放| 国产三级欧美三级日产三级99| 欧美日韩激情一区二区| av在线综合网| 国产真实精品久久二三区| 亚洲欧美区自拍先锋| 26uuu亚洲| 欧美男生操女生| 99久久久无码国产精品| 激情综合五月婷婷| 爽爽淫人综合网网站| 国产精品久久久久久久久免费桃花| 91精品久久久久久久99蜜桃| 99国产精品久久久| 国产成人精品免费在线| 免费成人在线视频观看| 亚洲综合免费观看高清完整版在线| 久久久亚洲精品石原莉奈| 91精品国产品国语在线不卡| 99精品视频一区二区三区| 久久99精品视频| 日本亚洲最大的色成网站www| 一区二区三区日韩精品视频| 欧美激情一区二区三区| 精品盗摄一区二区三区| 欧美一区二区三区播放老司机| 欧美天堂一区二区三区| 97久久超碰国产精品| 国产经典欧美精品| 韩国成人在线视频| 精品亚洲国产成人av制服丝袜| 亚洲va中文字幕| 亚洲同性gay激情无套| 日韩理论在线观看| 国产精品美女久久久久久| 久久女同精品一区二区| 久久久久久久久久美女| 久久男人中文字幕资源站| 精品少妇一区二区三区日产乱码| 这里只有精品视频在线观看| 欧美日韩aaaaa| 欧美一区二区三区免费观看视频 | 精品少妇一区二区三区免费观看 | 亚洲激情图片小说视频| 一个色综合av| 亚洲一区二区三区三| 亚洲成a人v欧美综合天堂下载| 亚洲一区影音先锋| 无吗不卡中文字幕| 蜜臀久久久久久久| 麻豆精品视频在线| 国内精品免费**视频| 国产精品影视天天线| 成人性生交大片免费| 99re热这里只有精品免费视频| 91一区二区三区在线观看| 色婷婷av久久久久久久| 欧美日韩国产色站一区二区三区| 在线不卡欧美精品一区二区三区| 91精品欧美一区二区三区综合在| 日韩欧美在线123| 久久精品人人做人人爽97| 国产精品久久久久久久久免费相片| 亚洲欧美视频在线观看视频| 亚洲成在人线免费| 久久国产欧美日韩精品| 成人综合激情网| 日本道精品一区二区三区 | 日韩女优电影在线观看| 久久久久久久电影| 亚洲精品成人a在线观看| 日韩av电影免费观看高清完整版在线观看 | 精品久久久久久久久久久久包黑料| 日韩一级完整毛片| 久久久久国产免费免费| 亚洲精品国产一区二区精华液 | 成人高清在线视频| 欧美日韩高清影院| 国产午夜一区二区三区| 亚洲午夜精品网| 国产一区二区三区在线观看免费 | 2020国产精品久久精品美国| 国产精品嫩草99a| 日韩福利电影在线观看| 99视频在线精品| 日韩视频免费直播| 亚洲精品国产无天堂网2021| 久久国产精品免费| 欧美视频在线观看一区二区| 2024国产精品| 午夜影院久久久| 99久久99久久免费精品蜜臀| 欧美一区二区免费| 亚洲免费观看高清完整版在线观看| 麻豆成人久久精品二区三区小说| av电影在线不卡| 精品成人免费观看| 亚洲国产婷婷综合在线精品| 丰满白嫩尤物一区二区| 欧美一区二区网站| 亚洲国产aⅴ成人精品无吗| 国产成人精品一区二区三区四区 | 国内精品伊人久久久久av影院| 91黄色免费看| 国产精品另类一区| 国产一区在线观看麻豆| 7777精品伊人久久久大香线蕉的| 国产精品国模大尺度视频| 韩国三级在线一区| 欧美电视剧在线看免费| 石原莉奈一区二区三区在线观看| 91啪在线观看| 日本一区二区高清| 国产福利一区二区三区视频 | 奇米777欧美一区二区| 欧美性猛片aaaaaaa做受| 一区二区在线免费| av电影在线观看一区| 欧美激情一区在线| 不卡的电影网站| 国产精品污污网站在线观看| 国产精品12区| 国产拍揄自揄精品视频麻豆 | 欧美a级理论片| 制服丝袜在线91|