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

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

?? gifencoder.java

?? 使用servlet開發的動態生成GIF圖像
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
// GifEncoder - write out an image as a GIF
//
// Transparency handling and variable bit size courtesy of Jack Palevich.
//
// Copyright (C)1996,1998 by Jef Poskanzer <jef@acme.com>. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
//    notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
//    notice, this list of conditions and the following disclaimer in the
//    documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
// SUCH DAMAGE.
//
// Visit the ACME Labs Java page for up-to-date versions of this and other
// fine Java utilities: http://www.acme.com/java/

package Acme.JPM.Encoders;

import java.util.*;
import java.io.*;
import java.awt.Image;
import java.awt.image.*;

/// Write out an image as a GIF.
// <P>
// <A HREF="/resources/classes/Acme/JPM/Encoders/GifEncoder.java">Fetch the software.</A><BR>
// <A HREF="/resources/classes/Acme.tar.gz">Fetch the entire Acme package.</A>
// <P>
// @see ToGif

public class GifEncoder extends ImageEncoder
    {

    private boolean interlace = false;

    /// Constructor from Image.
    // @param img The image to encode.
    // @param out The stream to write the GIF to.
    public GifEncoder( Image img, OutputStream out ) throws IOException
	{
	super( img, out );
	}

    /// Constructor from Image with interlace setting.
    // @param img The image to encode.
    // @param out The stream to write the GIF to.
    // @param interlace Whether to interlace.
    public GifEncoder( Image img, OutputStream out, boolean interlace ) throws IOException
	{
	super( img, out );
	this.interlace = interlace;
	}

    /// Constructor from ImageProducer.
    // @param prod The ImageProducer to encode.
    // @param out The stream to write the GIF to.
    public GifEncoder( ImageProducer prod, OutputStream out ) throws IOException
	{
	super( prod, out );
	}

    /// Constructor from ImageProducer with interlace setting.
    // @param prod The ImageProducer to encode.
    // @param out The stream to write the GIF to.
    public GifEncoder( ImageProducer prod, OutputStream out, boolean interlace ) throws IOException
	{
	super( prod, out );
	this.interlace = interlace;
	}


    int width, height;
    int[][] rgbPixels;

    void encodeStart( int width, int height ) throws IOException
	{
	this.width = width;
	this.height = height;
	rgbPixels = new int[height][width];
	}

    void encodePixels(
	int x, int y, int w, int h, int[] rgbPixels, int off, int scansize )
	throws IOException
	{
	// Save the pixels.
	for ( int row = 0; row < h; ++row )
	    System.arraycopy(
		rgbPixels, row * scansize + off,
		this.rgbPixels[y + row], x, w );

	}

    Acme.IntHashtable colorHash;

    void encodeDone() throws IOException
	{
	int transparentIndex = -1;
	int transparentRgb = -1;
        // Put all the pixels into a hash table.
        colorHash = new Acme.IntHashtable();
	int index = 0;
        for ( int row = 0; row < height; ++row )
            {
            int rowOffset = row * width;
            for ( int col = 0; col < width; ++col )
                {
                int rgb = rgbPixels[row][col];
		boolean isTransparent = ( ( rgb >>> 24 ) < 0x80 );
		if ( isTransparent )
		    {
		    if ( transparentIndex < 0 )
			{
			// First transparent color; remember it.
			transparentIndex = index;
			transparentRgb = rgb;
			}
		    else if ( rgb != transparentRgb )
			{
			// A second transparent color; replace it with
			// the first one.
			rgbPixels[row][col] = rgb = transparentRgb;
			}
		    }
                GifEncoderHashitem item =
		    (GifEncoderHashitem) colorHash.get( rgb );
                if ( item == null )
		    {
		    if ( index >= 256 )
			throw new IOException( "too many colors for a GIF" );
                    item = new GifEncoderHashitem(
			rgb, 1, index, isTransparent );
		    ++index;
		    colorHash.put( rgb, item );
		    }
                else
                    ++item.count;
                }
            }

	// Figure out how many bits to use.
	int logColors;
	if ( index <= 2 )
	    logColors = 1;
	else if ( index <= 4 )
	    logColors = 2;
	else if ( index <= 16 )
	    logColors = 4;
	else
	    logColors = 8;

	// Turn colors into colormap entries.
	int mapSize = 1 << logColors;
	byte[] reds = new byte[mapSize];
	byte[] grns = new byte[mapSize];
	byte[] blus = new byte[mapSize];
	for ( Enumeration e = colorHash.elements(); e.hasMoreElements(); )
	    {
	    GifEncoderHashitem item = (GifEncoderHashitem) e.nextElement();
	    reds[item.index] = (byte) ( ( item.rgb >> 16 ) & 0xff );
	    grns[item.index] = (byte) ( ( item.rgb >>  8 ) & 0xff );
	    blus[item.index] = (byte) (   item.rgb         & 0xff );
	    }

	GIFEncode(
	    out, width, height, interlace, (byte) 0, transparentIndex,
	    logColors, reds, grns, blus );
	}

    byte GetPixel( int x, int y ) throws IOException
	{
	GifEncoderHashitem item =
	    (GifEncoderHashitem) colorHash.get( rgbPixels[y][x] );
	if ( item == null )
	    throw new IOException( "color not found" );
	return (byte) item.index;
	}

    static void writeString( OutputStream out, String str ) throws IOException
        {
        byte[] buf = str.getBytes();
        out.write( buf );
        }

    // Adapted from ppmtogif, which is based on GIFENCOD by David
    // Rowley <mgardi@watdscu.waterloo.edu>.  Lempel-Zim compression
    // based on "compress".

    int Width, Height;
    boolean Interlace;
    int curx, cury;
    int CountDown;
    int Pass = 0;

    void GIFEncode(
	OutputStream outs, int Width, int Height, boolean Interlace, byte Background, int Transparent, int BitsPerPixel, byte[] Red, byte[] Green, byte[] Blue )
	throws IOException
	{
	byte B;
	int LeftOfs, TopOfs;
	int ColorMapSize;
	int InitCodeSize;
	int i;

	this.Width = Width;
	this.Height = Height;
	this.Interlace = Interlace;
	ColorMapSize = 1 << BitsPerPixel;
	LeftOfs = TopOfs = 0;

	// Calculate number of bits we are expecting
	CountDown = Width * Height;

	// Indicate which pass we are on (if interlace)
	Pass = 0;

	// The initial code size
	if ( BitsPerPixel <= 1 )
	    InitCodeSize = 2;
	else
	    InitCodeSize = BitsPerPixel;

	// Set up the current x and y position
	curx = 0;
	cury = 0;

	// Write the Magic header
	writeString( outs, "GIF89a" );

	// Write out the screen width and height
	Putword( Width, outs );
	Putword( Height, outs );

	// Indicate that there is a global colour map
	B = (byte) 0x80;		// Yes, there is a color map
	// OR in the resolution
	B |= (byte) ( ( 8 - 1 ) << 4 );
	// Not sorted
	// OR in the Bits per Pixel
	B |= (byte) ( ( BitsPerPixel - 1 ) );

	// Write it out
	Putbyte( B, outs );

	// Write out the Background colour
	Putbyte( Background, outs );

	// Pixel aspect ratio - 1:1.
	//Putbyte( (byte) 49, outs );
	// Java's GIF reader currently has a bug, if the aspect ratio byte is
	// not zero it throws an ImageFormatException.  It doesn't know that
	// 49 means a 1:1 aspect ratio.  Well, whatever, zero works with all
	// the other decoders I've tried so it probably doesn't hurt.
	Putbyte( (byte) 0, outs );

	// Write out the Global Colour Map
	for ( i = 0; i < ColorMapSize; ++i )
	    {
	    Putbyte( Red[i], outs );
	    Putbyte( Green[i], outs );
	    Putbyte( Blue[i], outs );
	    }

	// Write out extension for transparent colour index, if necessary.
	if ( Transparent != -1 )
	    {
	    Putbyte( (byte) '!', outs );
	    Putbyte( (byte) 0xf9, outs );
	    Putbyte( (byte) 4, outs );
	    Putbyte( (byte) 1, outs );
	    Putbyte( (byte) 0, outs );
	    Putbyte( (byte) 0, outs );
	    Putbyte( (byte) Transparent, outs );
	    Putbyte( (byte) 0, outs );
	    }

	// Write an Image separator
	Putbyte( (byte) ',', outs );

	// Write the Image header
	Putword( LeftOfs, outs );
	Putword( TopOfs, outs );
	Putword( Width, outs );
	Putword( Height, outs );

	// Write out whether or not the image is interlaced
	if ( Interlace )
	    Putbyte( (byte) 0x40, outs );
	else
	    Putbyte( (byte) 0x00, outs );

	// Write out the initial code size
	Putbyte( (byte) InitCodeSize, outs );

	// Go and actually compress the data
	compress( InitCodeSize+1, outs );

	// Write out a Zero-length packet (to end the series)
	Putbyte( (byte) 0, outs );

	// Write the GIF file terminator
	Putbyte( (byte) ';', outs );
	}

    // Bump the 'curx' and 'cury' to point to the next pixel
    void BumpPixel()
	{
	// Bump the current X position
	++curx;

	// If we are at the end of a scan line, set curx back to the beginning
	// If we are interlaced, bump the cury to the appropriate spot,
	// otherwise, just increment it.
	if ( curx == Width )
	    {
	    curx = 0;

	    if ( ! Interlace )
		++cury;
	    else
		{
		switch( Pass )
		    {
		    case 0:
		    cury += 8;
		    if ( cury >= Height )
			{
			++Pass;
			cury = 4;
			}
		    break;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
三级欧美韩日大片在线看| 亚洲国产成人av| 欧美一级欧美三级| 欧美区视频在线观看| 欧美在线播放高清精品| 91久久线看在观草草青青 | 中文字幕日韩精品一区| 欧美国产视频在线| 亚洲欧美日韩电影| 亚洲成人你懂的| 蜜桃av一区二区| 国产乱一区二区| 97久久精品人人爽人人爽蜜臀| 99精品久久只有精品| 91福利国产成人精品照片| 69av一区二区三区| 久久久久国产免费免费| 亚洲乱码国产乱码精品精小说 | 亚洲黄一区二区三区| 午夜视频在线观看一区| 美女网站在线免费欧美精品| 国产精品影音先锋| 欧美性色黄大片手机版| 日韩三级视频在线看| 国产日韩欧美a| 亚洲国产视频一区| 国产99久久久精品| 欧美日韩成人一区| 欧美激情中文不卡| 日韩国产在线一| 国产成人欧美日韩在线电影| 欧美亚洲禁片免费| 国产婷婷色一区二区三区四区 | 精品少妇一区二区| 亚洲色图在线播放| 激情综合一区二区三区| 色婷婷综合久久久中文一区二区| 日韩欧美亚洲另类制服综合在线| 国产精品私人自拍| 免费在线观看视频一区| 91麻豆精东视频| 国产日韩欧美亚洲| 人禽交欧美网站| 欧美日韩在线观看一区二区| 国产亚洲综合性久久久影院| 国产原创一区二区三区| 欧美日韩黄视频| 国产精品区一区二区三区| 日韩av高清在线观看| 91麻豆福利精品推荐| 久久久精品国产免大香伊| 三级不卡在线观看| 欧洲日韩一区二区三区| 国产精品二三区| 国产传媒一区在线| 日韩精品一区在线| 日本在线不卡视频一二三区| 91久久精品日日躁夜夜躁欧美| 国产视频911| 国产成人精品亚洲日本在线桃色| 日韩亚洲欧美在线观看| 午夜不卡在线视频| 欧美日韩综合在线| 亚洲午夜电影在线观看| 在线看日本不卡| 一区二区三区在线看| 色综合久久六月婷婷中文字幕| 国产精品乱人伦| 成人黄色在线网站| 中文字幕在线观看不卡视频| 成人精品电影在线观看| 国产精品久久久久久久第一福利 | 色菇凉天天综合网| **网站欧美大片在线观看| 成人一区二区三区视频在线观看| 久久久久97国产精华液好用吗| 国产一区二区三区不卡在线观看| 精品国产成人系列| 国产精品123区| 亚洲欧洲另类国产综合| 91官网在线免费观看| 亚洲一二三区在线观看| 91精品国产一区二区三区 | 亚洲私人黄色宅男| 91国产成人在线| 日本一不卡视频| 久久婷婷成人综合色| 国产成人av资源| 自拍偷拍亚洲激情| 欧美日韩一区小说| 久久99精品久久久久婷婷| 国产日韩精品一区二区三区| 91视视频在线观看入口直接观看www | 欧美视频一区在线| 日本成人在线不卡视频| 久久久精品综合| 日本精品视频一区二区三区| 日韩精品乱码免费| 国产丝袜欧美中文另类| 在线欧美日韩精品| 丁香六月久久综合狠狠色| 亚洲精品v日韩精品| 日韩一区二区三区视频| 成人v精品蜜桃久久一区| 亚洲va欧美va国产va天堂影院| 日韩一区二区免费高清| 成人av网在线| 丝袜美腿高跟呻吟高潮一区| 久久精品一二三| 在线观看国产91| 国产99久久久精品| 午夜精品久久久久久久久| 国产日韩欧美高清| 678五月天丁香亚洲综合网| 成人av午夜电影| 免费在线看成人av| 亚洲综合色噜噜狠狠| 26uuu成人网一区二区三区| 欧美天天综合网| 成人自拍视频在线观看| 麻豆成人免费电影| 亚洲线精品一区二区三区 | 色素色在线综合| 国产精品一级黄| 麻豆国产欧美日韩综合精品二区| 日韩一区中文字幕| 久久蜜桃av一区二区天堂| 在线免费观看日本欧美| 成人激情电影免费在线观看| 黄网站免费久久| 日本免费新一区视频| 亚洲男人都懂的| 中文字幕欧美区| 久久蜜桃av一区精品变态类天堂 | 国产精品久久久久aaaa樱花| 日韩欧美在线观看一区二区三区| 欧美少妇bbb| 91视频国产观看| 成人国产视频在线观看| 国产乱码精品一品二品| 激情综合五月婷婷| 九一九一国产精品| 琪琪久久久久日韩精品| 日韩va欧美va亚洲va久久| 香蕉久久夜色精品国产使用方法| 一区二区三区在线免费| 亚洲美女视频在线| 依依成人精品视频| 亚洲激情av在线| 亚洲国产精品久久不卡毛片| 一区二区三区精品视频在线| 亚洲欧美日韩精品久久久久| 亚洲三级电影网站| 一区二区三区在线视频观看58| 亚洲男人天堂av网| 亚洲福利视频一区| 免费高清成人在线| 国产一区二区三区久久悠悠色av | 色综合久久九月婷婷色综合| 色婷婷国产精品| 欧美日韩一本到| 欧美刺激脚交jootjob| 国产亚洲va综合人人澡精品| 国产欧美一区二区精品仙草咪| 国产精品免费久久| 亚洲影视在线播放| 蜜桃91丨九色丨蝌蚪91桃色| 精彩视频一区二区三区| 国产99精品在线观看| 91在线观看成人| 国产欧美一区二区三区在线老狼| 国产精品久久久久影院| 亚洲精品高清视频在线观看| 亚州成人在线电影| 国产一区二区在线影院| 91亚洲精品一区二区乱码| 欧美三日本三级三级在线播放| 日韩欧美一区电影| 日本一区二区三区四区| 亚洲成a天堂v人片| 狠狠色综合色综合网络| 色综合网色综合| 日韩亚洲欧美成人一区| 中文字幕亚洲综合久久菠萝蜜| 午夜欧美视频在线观看| 国产成人免费视频网站| 欧美日韩国产综合一区二区| 久久人人97超碰com| 亚洲自拍偷拍综合| 国产成人免费在线观看| 欧美日产国产精品| 国产精品久久久久三级| 日本亚洲欧美天堂免费| 91视频国产资源| 国产清纯美女被跳蛋高潮一区二区久久w | 色狠狠桃花综合| 久久久一区二区三区捆绑**| 亚洲第四色夜色| 成人av影视在线观看| 精品嫩草影院久久|