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

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

?? gifencoder.java

?? 在java中處理gif文件的編碼例子
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/**
 * Strictly speaking, it is against patent laws to produce unlicensed
 * GIF images.  See http://www.unisys.com for license agreements.
 * Without such a license, the use of a class similar to the following
 * would be prohibited.
 *
 * --
 * Greg Faron
 * Integre Technical Publishing Co.
 */

import java.awt.AWTException;
import java.awt.Image;
import java.awt.image.PixelGrabber;
import java.io.IOException;
import java.io.OutputStream;

/**
 * Class <CODE>GIFEncoder</CODE> takes an <CODE>Image</CODE> and
 * saves it to a file using the <CODE>GIF</CODE> file format
 * (<A HREF="http://www.dcs.ed.ac.uk/%7Emxr/gfx/">Graphics Interchange
 * Format</A>).
 * A <CODE>GIFEncoder</CODE> object is constructed with either an
 * <CODE>Image</CODE> object (which must be fully loaded), or a set of
 * three 2-dimensional <CODE>byte</CODE> arrays.  The image file can be
 * written out with a call to {@link #write(OutputStream) write()}.<p>
 * Three caveats:
 * <UL>
 * <LI>Class <CODE>GIFEncoder</CODE> will convert the image to
 * indexed color upon
 * construction.  This will take some time, depending on the size of
 * the image.
 * Also, the act of writing the image to disk will take some
 * time.</LI>
 * <LI>The image cannot have more than 256 colors, since GIF is an 8
 * bit format.  For a 24 bit to 8 bit quantization algorithm, see
 * Graphics Gems II III.2 by <A
 * HREF="http://www.csd.uwo.ca/faculty/wu/">Xialoin Wu</A>.
 * Or check out his <A HREF="http://www.csd.uwo.ca/faculty/wu/cq.c">C
 * source</A>.</LI>
 * <LI>Since the image must be completely loaded into memory,
 * <CODE>GIFEncoder</CODE>
 * may have problems with large images.  Attempting to encode an
 * image which will not
 * fit into memory will probably result in the following
 * exception:<BR>
 * <CODE>java.awt.AWTException: Grabber returned false:
 * 192</CODE></LI>
 * </UL>
 * <CODE>GIFEncoder</CODE> is based upon gifsave.c, which was written
 * and released by:<p>
 * <DIV ALIGN="CENTER">
 * Sverre H. Huseby<BR>
 * Bjoelsengt. 17<BR>
 * N-0468 Oslo<BR>
 * Norway<p>
 * Phone: +47 2 230539<BR>
 * <A HREF="mailto:sverrehu@ifi.uio.no">sverrehu@ifi.uio.no</A><BR>
 * </DIV>
 *
 * @author Adam Doppelt (dead link <A
 * @author Greg Faron - Integre Technical Publishing -
 * @version 0.90 21 Apr 1996
 */
public class GIFEncoder extends Object
   {
   /**
    * image height in pixels
    */
   short imageWidth, imageHeight;
   /**
    * number of different colours in image
    */
   int numberOfColors;
   /**
    * linear array of all pixels in row major order.
    */
   byte[] allPixels = null;
   /**
    * list of all colours used in the image.
    */
   byte[] allColors = null;

   /**
    * Convenience constructor for class <CODE>GIFEncoder</CODE>.  The
    * argument will
    * be converted to an indexed color array.
    * <B>This may take some time.</B>
    *
    * @param image  The image to encode. The image <B>must</B> be
    *               completely loaded.
    * @exception AWTException
    *                   Will be thrown if the pixel grab fails.
    *                   This can happen
    *                   if Java runs out of memory.  It may also
    *                   indicate that the
    *                   image contains more than 256 colors.
    */
   public GIFEncoder( Image image )
   throws AWTException
   {
      this.imageWidth = (short )image.getWidth( null );
      this.imageHeight = (short )image.getHeight( null );

      int values[] = new int[this.imageWidth * this.imageHeight];
      PixelGrabber grabber = new PixelGrabber( image,
                                               0, 0,
                                               this.imageWidth,
                                               this.imageHeight,
                                               values, 0, this.imageWidth );

      try
         {
         if ( grabber.grabPixels( ) != true )
            throw new AWTException( "Grabber returned false: " +
                                    grabber.status( ) );
         } // ends try

      catch ( InterruptedException ie )
         {
         }

      byte[][] r = new byte[this.imageWidth][this.imageHeight];
      byte[][] g = new byte[this.imageWidth][this.imageHeight];
      byte[][] b = new byte[this.imageWidth][this.imageHeight];
      int index = 0;

      for ( int y=0; y<this.imageHeight; y++ )
         {
         for ( int x=0; x<this.imageWidth; x++, index++ )
            {
            r[x][y] = (byte)( ( values[index] >> 16 ) & 0xFF );
            g[x][y] = (byte)( ( values[index] >> 8 ) & 0xFF );
            b[x][y] = (byte)( ( values[index] ) & 0xFF );
            } // ends for

         } // ends for

      this.toIndexColor( r, g, b );
   } // ends constructor GIFEncoder(Image )

   /** Standard constructor for class <CODE>GIFEncoder</CODE>.
     * Each array stores intensity
     * values for the image.  In other words,
     * <NOBR><CODE>r[x][y]</CODE></NOBR> refers to
     * the red intensity of the pixel at column <CODE>x</CODE>, row
     * <CODE>y</CODE>.
     * @param r A 2-dimensional array containing the red intensity values.
     * @param g A 2-dimensional array containing the green intensity
     * values.
     * @param b A 2-dimensional array containing the blue intensity values.
     * @exception AWTException Thrown if the image contains more than 256
     * colors.
     */
   public GIFEncoder( byte[][] r, byte[][] g, byte[][] b )
   throws AWTException
   {
      this.imageWidth = (short )( r.length );
      this.imageHeight = (short )( r[0].length );

      this.toIndexColor( r, g, b );
   } // ends constructor GIFEncoder(byte[][], byte[][], byte[][] )

   /** Writes the image out to a stream in the <CODE>GIF</CODE> file
     * format.
     * This will be a single GIF87a image, non-interlaced, with no
     * background color.
     * <B>This may take some time.</B>
     * @param output The stream to which to output. This should probably be
     * a buffered stream.
     * @exception IOException Thrown if a write operation fails.
     */
   public void write( OutputStream output )
   throws IOException
   {
      BitUtils.writeString( output, "GIF87a" );
      ScreenDescriptor sd = new ScreenDescriptor( this.imageWidth,
                                                  this.imageHeight, this.numberOfColors );
      sd.write( output );

      output.write( this.allColors, 0, this.allColors.length) ;

      ImageDescriptor id = new ImageDescriptor( this.imageWidth, this.imageHeight, ',' );
      id.write( output );

      byte codesize = BitUtils.BitsNeeded(this.numberOfColors);
      if ( codesize == 1 )
         {
         codesize ++;
         }
      output.write( codesize );

      LZWCompressor.LZWCompress( output, codesize, this.allPixels );
      output.write( 0 );

      id = new ImageDescriptor( (byte)0, (byte)0, ';' );
      id.write( output );
      output.flush();
   } // ends write( OutputStream )

   /**
    * Converts rgb desrcription of image to colour
    * number description used by GIF.
    *
    * @param r      red array of pixels
    * @param g      green array of pixels
    * @param b      blue array of pixels
    * @exception AWTException
    *                   Thrown if
    *                   too many different colours in image.
    */
   void toIndexColor( byte[][] r, byte[][] g, byte[][] b )
   throws AWTException
   {
      this.allPixels = new byte[this.imageWidth * this.imageHeight];
      this.allColors = new byte[256 * 3];
      int colornum = 0;
      for ( int x=0; x<this.imageWidth; x++ )
         {
         for ( int y=0; y<this.imageHeight; y++ )
            {
            int search;
            for ( search=0; search < colornum; search++ )
               {
               if ( this.allColors[search * 3] == r[x][y] &&
                    this.allColors[search * 3 + 1] == g[x][y] &&
                    this.allColors[search * 3 + 2] == b[x][y] )
                  {
                  break;
                  } // ends if

               } // ends for

            if ( search > 255 )
               throw new AWTException( "Too many colors." );
            // row major order y=row x=col
            this.allPixels[y * this.imageWidth + x] = (byte)search;

            if ( search == colornum )
               {
               this.allColors[search * 3] = r[x][y]; // [col][row]
               this.allColors[search * 3 + 1] = g[x][y];
               this.allColors[search * 3 + 2] = b[x][y];
               colornum++;
               } // ends if

            } // ends for

         } // ends for

      this.numberOfColors = 1 << BitUtils.BitsNeeded( colornum );
      byte copy[] = new byte[this.numberOfColors * 3];
      System.arraycopy( this.allColors, 0, copy, 0, this.numberOfColors * 3 );
      this.allColors = copy;
   } // ends toIndexColor(byte[][], byte[][], byte[][] )

   } // ends class GIFEncoder

/**
 * Used to write the bits composing the GIF image.
 */
class BitFile extends Object
   {
   /**
    * The outputstream where the data is written.
    */
   OutputStream output = null;
   /**
    * buffer for bits to write.
    */
   byte[] buffer;
   /**
    */
   int indexIntoOutputStream, bitsLeft;

   /**
    * constructor
    *
    * @param output Where image will be written
    */
   public BitFile( OutputStream output )
      {
      this.output = output;
      this.buffer = new byte[256];
      this.indexIntoOutputStream = 0;
      this.bitsLeft = 8;
      } // ends constructor BitFile(OutputStream )

   /**
    * Ensures image in ram gets to disk.
    *
    * @exception IOException
    */
   public void flush( )
   throws IOException
   {
      int numBytes = this.indexIntoOutputStream + ( (this.bitsLeft == 8 ) ? 0 : 1 );
      if ( numBytes > 0 )
         {
         this.output.write( numBytes );
         this.output.write( this.buffer, 0, numBytes );
         this.buffer[0] = 0;
         this.indexIntoOutputStream = 0;
         this.bitsLeft = 8;
         } // ends if

   } // ends flush( void )

   /**
    * Write bits to stream.
    *
    * @param bits    source of bits, low/high order?
    * @param numbits how many bits to write.
    *
    * @exception IOException
    */
   public void writeBits( int bits, int numbits )
   throws IOException
   {
      int bitsWritten = 0;
      int numBytes = 255;
      do
         {
         if ( (this.indexIntoOutputStream == 254 && this.bitsLeft == 0 ) ||
              this.indexIntoOutputStream > 254 )
            {
            this.output.write( numBytes );
            this.output.write( this.buffer, 0, numBytes );

            this.buffer[0] = 0;
            this.indexIntoOutputStream = 0;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩欧美一级片| 一区二区三区波多野结衣在线观看| 日韩一卡二卡三卡| 国产精品不卡在线| 国内成+人亚洲+欧美+综合在线| 色狠狠一区二区| 欧美精品一区在线观看| 亚洲国产精品视频| 91视视频在线直接观看在线看网页在线看| 欧美一区二区三区在线视频| 亚洲女人小视频在线观看| 国产成人免费视频一区| 在线成人av网站| 亚洲国产精品影院| 91美女精品福利| 国产精品久久毛片av大全日韩| 久久国产福利国产秒拍| 欧美一区二区成人| 日韩精品三区四区| 欧美日本韩国一区| 亚洲成年人影院| 欧美性受xxxx| 亚洲国产日韩a在线播放性色| 色综合久久久久久久久| 亚洲欧洲三级电影| av在线一区二区| 中文字幕日韩一区| a美女胸又www黄视频久久| 中文字幕免费不卡在线| 国产69精品久久久久毛片| 久久久不卡网国产精品二区 | 亚洲色欲色欲www在线观看| 国产成人综合亚洲91猫咪| xf在线a精品一区二区视频网站| 免费精品视频在线| 337p粉嫩大胆噜噜噜噜噜91av| 另类的小说在线视频另类成人小视频在线| 欧美二区在线观看| 美国三级日本三级久久99| 日韩免费视频一区| 国产精品影音先锋| 国产精品久久久一区麻豆最新章节| 福利一区在线观看| 17c精品麻豆一区二区免费| 91麻豆免费在线观看| 亚洲精品videosex极品| 久久综合丝袜日本网| 精彩视频一区二区| 中文字幕欧美一| 欧洲色大大久久| 麻豆精品一区二区三区| 欧美激情综合五月色丁香| 91丨九色丨国产丨porny| 亚洲尤物在线视频观看| 日韩女同互慰一区二区| 成人免费高清在线| 亚洲国产精品一区二区久久| 欧美一级理论片| 成人亚洲精品久久久久软件| 亚洲免费在线看| 欧美tickle裸体挠脚心vk| 粉嫩aⅴ一区二区三区四区五区| 亚洲日本一区二区| 日韩欧美中文字幕制服| 大桥未久av一区二区三区中文| 亚洲人午夜精品天堂一二香蕉| 欧美日韩国产一级| 国产成人日日夜夜| 亚洲国产毛片aaaaa无费看| 精品国产91乱码一区二区三区| 不卡的看片网站| 麻豆精品新av中文字幕| 国产精品第13页| 欧美岛国在线观看| 色综合久久久久综合体| 久久 天天综合| 亚洲永久精品国产| 国产欧美一区二区精品性色超碰| 欧美色图免费看| 国产传媒久久文化传媒| 日韩电影免费一区| 亚洲欧美国产毛片在线| 26uuu亚洲| 欧美日韩午夜在线| av一区二区三区四区| 久久精品国产精品亚洲精品| 亚洲精品成人天堂一二三| 国产欧美日韩另类视频免费观看| 欧美日本在线观看| 色婷婷国产精品| 菠萝蜜视频在线观看一区| 狠狠色伊人亚洲综合成人| 亚洲 欧美综合在线网络| 国产精品传媒在线| 欧美激情一区在线观看| 欧美xxxxx牲另类人与| 欧美人牲a欧美精品| 色琪琪一区二区三区亚洲区| 成人免费黄色大片| 国产不卡一区视频| 国产伦精品一区二区三区视频青涩 | 肉色丝袜一区二区| 一区二区激情视频| 亚洲黄色av一区| 中文字幕一区二区三区av| 国产三级三级三级精品8ⅰ区| 欧美成人精品3d动漫h| 日韩欧美一卡二卡| 欧美一区二区私人影院日本| 欧美精品色综合| 欧美久久婷婷综合色| 欧美日韩视频专区在线播放| 欧美中文字幕一区二区三区| 在线亚洲一区观看| 色综合久久久久久久久| 91精品1区2区| 欧美日韩在线电影| 91.麻豆视频| 欧美一级二级三级蜜桃| 日韩免费高清av| 一区二区国产视频| 亚洲一区在线电影| 日韩中文字幕91| 精品一区二区三区的国产在线播放 | 国产精品国产a级| 亚洲男人的天堂av| 亚洲成人午夜影院| 毛片av一区二区三区| 狠狠色伊人亚洲综合成人| 国产成人免费视频精品含羞草妖精| 国产精品影视在线| 91片在线免费观看| 欧美日韩国产高清一区二区| 欧美一区二区三区影视| 精品国产乱码久久久久久免费| 久久人人97超碰com| 中文字幕在线一区免费| 亚洲图片一区二区| 久久精品久久久精品美女| 国v精品久久久网| 欧美性猛片xxxx免费看久爱| 日韩欧美在线影院| 国产精品久久久久影院| 欧美韩国日本一区| 日日欢夜夜爽一区| 久久国产乱子精品免费女| 国产精品一区在线| 91婷婷韩国欧美一区二区| 欧美日韩在线电影| 国产午夜亚洲精品羞羞网站| 亚洲摸摸操操av| 久久66热偷产精品| 91福利在线观看| 久久综合九色欧美综合狠狠| 国产精品理伦片| 男女男精品视频| 成人av免费网站| 欧美大片在线观看一区| 18欧美乱大交hd1984| 久久精品国产在热久久| 色综合夜色一区| 精品国产髙清在线看国产毛片 | 欧美日韩一区成人| 国产亚洲欧美一级| 日韩精彩视频在线观看| 暴力调教一区二区三区| 久久综合视频网| 偷窥国产亚洲免费视频| 99re亚洲国产精品| 久久久亚洲国产美女国产盗摄 | 综合欧美亚洲日本| 国产一区二区调教| 制服丝袜中文字幕一区| 亚洲柠檬福利资源导航| 国产91高潮流白浆在线麻豆| 欧美一级精品大片| 亚洲妇熟xx妇色黄| www.成人在线| 欧美国产在线观看| 国产一区二区中文字幕| 日韩一区二区三区四区| 亚洲成人一二三| 一道本成人在线| 一区在线中文字幕| 成人动漫中文字幕| 日本一区二区三区视频视频| 老司机精品视频导航| 91精品蜜臀在线一区尤物| 亚洲电影第三页| 欧美在线视频日韩| 一区二区三区日韩在线观看| 91蜜桃网址入口| 综合久久国产九一剧情麻豆| 成人精品视频一区二区三区尤物| 久久久天堂av| 国产成人免费视频一区| 国产精品理伦片| 成人一区二区三区视频| 中文字幕国产精品一区二区| 懂色av一区二区三区蜜臀|