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

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

?? gifencoder.java

?? 著名IDAutomation公司的JAVA條碼控件源碼
?? 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 com.idautomation.barcode.encoder;

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 );

	}

    IntHashtable colorHash;

    void encodeDone() throws IOException
	{
	int transparentIndex = -1;
	int transparentRgb = -1;
        // Put all the pixels into a hash table.
        colorHash = new 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一区二区三区免费野_久草精品视频
亚洲情趣在线观看| 秋霞国产午夜精品免费视频| 国产麻豆成人传媒免费观看| 日韩免费视频线观看| 日本一道高清亚洲日美韩| 欧美乱熟臀69xxxxxx| 性久久久久久久久| 在线不卡中文字幕播放| 午夜精品在线视频一区| 欧美一区二区三区系列电影| 精品影院一区二区久久久| 久久久夜色精品亚洲| av在线播放一区二区三区| 亚洲乱码日产精品bd| 欧美三级蜜桃2在线观看| 日韩成人精品在线观看| 久久综合九色综合97婷婷| 国产精品1区2区| 亚洲丝袜自拍清纯另类| 欧美乱妇23p| 国产自产v一区二区三区c| 中文一区二区完整视频在线观看| 99久久婷婷国产综合精品| 亚洲一区二区中文在线| 日韩欧美国产综合一区| 成人a级免费电影| 午夜av一区二区| 国产日本欧美一区二区| 91福利资源站| 国产精品88888| 婷婷国产在线综合| 久久视频一区二区| 色婷婷精品久久二区二区蜜臀av | 亚洲免费在线观看视频| 欧美性一二三区| 国产精品123| 肉色丝袜一区二区| 国产欧美一区二区在线| 欧美色手机在线观看| 福利一区在线观看| 香蕉乱码成人久久天堂爱免费| 久久久久久久久久久电影| 欧美色窝79yyyycom| 国产毛片精品国产一区二区三区| 亚洲国产精品一区二区www| www欧美成人18+| 欧美二区三区的天堂| 国产宾馆实践打屁股91| 日韩av二区在线播放| 中文一区在线播放| 欧美成人午夜电影| 欧美另类久久久品| 色综合网色综合| 国产成人综合亚洲网站| 日韩av电影免费观看高清完整版在线观看| 国产精品伦理在线| 精品国产自在久精品国产| 欧美在线观看你懂的| gogo大胆日本视频一区| 国产成人av电影| 狠狠狠色丁香婷婷综合久久五月| 亚洲大片在线观看| 亚洲女人****多毛耸耸8| 国产午夜亚洲精品不卡| 欧美一区二区在线免费播放| 欧美性一区二区| 色94色欧美sute亚洲线路一ni| 成人黄页毛片网站| 国产一区二区在线电影| 蜜桃精品视频在线| 午夜久久久影院| 丝袜亚洲另类欧美| 亚洲一区在线看| 一区二区三区**美女毛片| 成人免费小视频| 国产精品免费看片| 国产精品久久久久9999吃药| 国产精品无圣光一区二区| 国产农村妇女精品| 国产免费成人在线视频| 国产日韩欧美不卡在线| 国产亚洲综合色| 国产精品女同互慰在线看| 久久精品视频免费| 国产女主播在线一区二区| 亚洲国产精品成人综合| 国产精品每日更新| 中文字幕制服丝袜成人av | 亚洲乱码中文字幕综合| 亚洲色图在线播放| 亚洲免费观看高清完整版在线 | 欧美在线免费观看视频| 欧美三级日本三级少妇99| 欧美日韩欧美一区二区| 欧美精品欧美精品系列| 日韩一级免费一区| 精品av综合导航| 中文字幕精品在线不卡| 亚洲天堂久久久久久久| 亚洲成人黄色小说| 麻豆精品在线视频| 国产成人亚洲综合a∨婷婷| 成人美女视频在线看| 色婷婷综合久久久久中文一区二区 | 天天影视涩香欲综合网| 日韩av一二三| 国产成人av一区二区三区在线观看| 不卡视频免费播放| 色狠狠一区二区| 精品国产一区二区三区不卡 | 欧美一区二区视频免费观看| 久久影视一区二区| 自拍偷拍亚洲激情| 日本vs亚洲vs韩国一区三区二区 | av中文一区二区三区| 色天天综合色天天久久| 欧美一区二区三区喷汁尤物| 日本一区二区视频在线观看| 一区二区在线观看免费视频播放 | 亚洲图片欧美综合| 另类欧美日韩国产在线| 97se狠狠狠综合亚洲狠狠| 制服丝袜av成人在线看| 国产欧美日韩卡一| 亚洲va国产天堂va久久en| 国产美女在线精品| 精品视频在线视频| 2021中文字幕一区亚洲| 一区二区在线电影| 国模娜娜一区二区三区| 在线观看欧美日本| 欧美精品一区二区不卡| 亚洲在线观看免费视频| 国产精品一区一区三区| 欧美日韩在线三区| 国产精品欧美一级免费| 精一区二区三区| 欧美日韩国产在线播放网站| 国产精品欧美精品| 激情综合网av| 制服丝袜亚洲精品中文字幕| 亚洲狠狠丁香婷婷综合久久久| 国产99久久久久| 欧美成人性战久久| 视频一区二区三区中文字幕| 色网站国产精品| 国产精品美女久久久久久| 久久99精品久久久| 欧美日韩国产综合一区二区三区| 中文字幕一区不卡| 国产一区二区在线观看视频| 日韩欧美中文字幕制服| 亚洲福利视频一区二区| 色爱区综合激月婷婷| 椎名由奈av一区二区三区| 成人在线综合网站| 欧美精品一区二区三区视频| 日本成人在线网站| 欧美视频精品在线观看| 亚洲精品精品亚洲| 99久久精品免费看国产免费软件| 国产人伦精品一区二区| 国产精品91xxx| 亚洲国产岛国毛片在线| 国产经典欧美精品| 久久久午夜电影| 久久99久久久久久久久久久| 日韩一区二区在线看片| 视频在线观看一区| 欧美日韩高清影院| 亚洲精品亚洲人成人网 | 亚洲国产欧美在线| 日本韩国欧美在线| 一区二区三区在线免费| 91成人网在线| 亚洲国产另类av| 欧美日韩一级大片网址| 亚洲在线中文字幕| 精品污污网站免费看| 日韩精品免费专区| 欧美一区二区三区公司| 久久精品国产亚洲高清剧情介绍| 日韩欧美国产一区二区三区| 韩国在线一区二区| 欧美国产成人精品| 懂色av中文字幕一区二区三区| 国产精品电影一区二区| 色综合久久天天| 爽好多水快深点欧美视频| 日韩情涩欧美日韩视频| 国产一区二区三区在线观看免费| 国产日韩欧美不卡在线| www.欧美色图| 性做久久久久久免费观看 | 欧美三级资源在线| 日韩电影在线一区二区三区| xfplay精品久久| 99久久亚洲一区二区三区青草| 午夜影院久久久| 久久一留热品黄|