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

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

?? gif89encoder.java

?? Gif89Encoder! JAVA環境下應用!
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
//******************************************************************************
// Gif89Encoder.java
//******************************************************************************
package net.jmge.gif;

import java.awt.*;
import java.io.*;
import java.util.Vector;

//==============================================================================
/** This is the central class of a JDK 1.1 compatible GIF encoder that, AFAIK,
 *  supports more features of the extended GIF spec than any other Java open
 *  source encoder.  Some sections of the source are lifted or adapted from Jef
 *  Poskanzer's <cite>Acme GifEncoder</cite> (so please see the
 *  <a href="../readme.txt">readme</a> containing his notice), but much of it,
 *  including nearly all of the present class, is original code.  My main
 *  motivation for writing a new encoder was to support animated GIFs, but the
 *  package also adds support for embedded textual comments.
 *  <p>
 *  There are still some limitations.  For instance, animations are limited to
 *  a single global color table.  But that is usually what you want anyway, so
 *  as to avoid irregularities on some displays.  (So this is not really a
 *  limitation, but a "disciplinary feature" :)  Another rather more serious
 *  restriction is that the total number of RGB colors in a given input-batch
 *  mustn't exceed 256.  Obviously, there is an opening here for someone who
 *  would like to add a color-reducing preprocessor.
 *  <p>
 *  The encoder, though very usable in its present form, is at bottom only a
 *  partial implementation skewed toward my own particular needs.  Hence a
 *  couple of caveats are in order.  (1) During development it was in the back
 *  of my mind that an encoder object should be reusable - i.e., you should be
 *  able to make multiple calls to encode() on the same object, with or without
 *  intervening frame additions or changes to options.  But I haven't reviewed
 *  the code with such usage in mind, much less tested it, so it's likely I
 *  overlooked something.  (2) The encoder classes aren't thread safe, so use
 *  caution in a context where access is shared by multiple threads.  (Better
 *  yet, finish the library and re-release it :)
 *  <p>
 *  There follow a couple of simple examples illustrating the most common way to
 *  use the encoder, i.e., to encode AWT Image objects created elsewhere in the
 *  program.  Use of some of the most popular format options is also shown,
 *  though you will want to peruse the API for additional features.
 *
 *  <p>
 *  <strong>Animated GIF Example</strong>
 *  <pre>
 *  import net.jmge.gif.Gif89Encoder;
 *  // ...
 *  void writeAnimatedGIF(Image[] still_images,
 *                        String annotation,
 *                        boolean looped,
 *                        double frames_per_second,
 *                        OutputStream out) throws IOException
 *  {
 *    Gif89Encoder gifenc = new Gif89Encoder();
 *    for (int i = 0; i < still_images.length; ++i)
 *      gifenc.addFrame(still_images[i]);
 *    gifenc.setComments(annotation);
 *    gifenc.setLoopCount(looped ? 0 : 1);
 *    gifenc.setUniformDelay((int) Math.round(100 / frames_per_second));
 *    gifenc.encode(out);
 *  }
 *  </pre>
 *
 *  <strong>Static GIF Example</strong>
 *  <pre>
 *  import net.jmge.gif.Gif89Encoder;
 *  // ...
 *  void writeNormalGIF(Image img,
 *                      String annotation,
 *                      int transparent_index,  // pass -1 for none
 *                      boolean interlaced,
 *                      OutputStream out) throws IOException
 *  {
 *    Gif89Encoder gifenc = new Gif89Encoder(img);
 *    gifenc.setComments(annotation);
 *    gifenc.setTransparentIndex(transparent_index);
 *    gifenc.getFrameAt(0).setInterlaced(interlaced);
 *    gifenc.encode(out);
 *  }
 *  </pre>
 *
 * @version 0.90 beta (15-Jul-2000)
 * @author J. M. G. Elliott (tep@jmge.net)
 * @see Gif89Frame
 * @see DirectGif89Frame
 * @see IndexGif89Frame
 */
public class Gif89Encoder {

  private Dimension     dispDim = new Dimension(0, 0);
  private GifColorTable colorTable;
  private int           bgIndex = 0;
  private int           loopCount = 1;
  private String        theComments;
  private Vector        vFrames = new Vector();

  //----------------------------------------------------------------------------
  /** Use this default constructor if you'll be adding multiple frames
   *  constructed from RGB data (i.e., AWT Image objects or ARGB-pixel arrays).
   */
  public Gif89Encoder()
  {
    // empty color table puts us into "palette autodetect" mode
    colorTable = new GifColorTable();  
  }
  
  //----------------------------------------------------------------------------
  /** Like the default except that it also adds a single frame, for conveniently
   *  encoding a static GIF from an image.
   *
   * @param static_image
   *   Any Image object that supports pixel-grabbing.
   * @exception IOException
   *   See the addFrame() methods.   
   */
  public Gif89Encoder(Image static_image) throws IOException
  {
    this();
    addFrame(static_image);
  }

  //----------------------------------------------------------------------------
  /** This constructor installs a user color table, overriding the detection of
   *  of a palette from ARBG pixels.
   *
   *  Use of this constructor imposes a couple of restrictions:
   *  (1) Frame objects can't be of type DirectGif89Frame
   *  (2) Transparency, if desired, must be set explicitly.
   *
   * @param colors
   *   Array of color values; no more than 256 colors will be read, since that's
   *   the limit for a GIF.
   */ 
  public Gif89Encoder(Color[] colors)
  {
    colorTable = new GifColorTable(colors); 
  }

  //----------------------------------------------------------------------------
  /** Convenience constructor for encoding a static GIF from index-model data.
   *  Adds a single frame as specified.
   *
   * @param colors
   *   Array of color values; no more than 256 colors will be read, since
   *   that's the limit for a GIF.
   * @param width
   *   Width of the GIF bitmap.
   * @param height
   *   Height of same.
   * @param ci_pixels
   *   Array of color-index pixels no less than width * height in length.
   * @exception IOException
   *   See the addFrame() methods.   
   */ 
  public Gif89Encoder(Color[] colors, int width, int height, byte ci_pixels[])
  throws IOException
  {
    this(colors);
    addFrame(width, height, ci_pixels);
  }  

  //----------------------------------------------------------------------------
  /** Get the number of frames that have been added so far.
   *
   * @return
   *  Number of frame items.
   */
  public int getFrameCount() { return vFrames.size(); }

  //----------------------------------------------------------------------------
  /** Get a reference back to a Gif89Frame object by position. 
   *
   * @param index
   *   Zero-based index of the frame in the sequence.
   * @return
   *   Gif89Frame object at the specified position (or null if no such frame).   
   */
  public Gif89Frame getFrameAt(int index)
  {
    return isOk(index) ? (Gif89Frame) vFrames.elementAt(index) : null;
  }
 
  //----------------------------------------------------------------------------
  /** Add a Gif89Frame frame to the end of the internal sequence.  Note that
   *  there are restrictions on the Gif89Frame type: if the encoder object was
   *  constructed with an explicit color table, an attempt to add a
   *  DirectGif89Frame will throw an exception.
   *
   * @param gf
   *   An externally constructed Gif89Frame.
   * @exception IOException
   *   If Gif89Frame can't be accommodated.  This could happen if either (1) the
   *   aggregate cross-frame RGB color count exceeds 256, or (2) the Gif89Frame
   *   subclass is incompatible with the present encoder object.
   */
  public void addFrame(Gif89Frame gf) throws IOException
  {
    accommodateFrame(gf);
    vFrames.addElement(gf);
  }

  //----------------------------------------------------------------------------
  /** Convenience version of addFrame() that takes a Java Image, internally
   *  constructing the requisite DirectGif89Frame.
   *
   * @param image
   *   Any Image object that supports pixel-grabbing.
   * @exception IOException
   *   If either (1) pixel-grabbing fails, (2) the aggregate cross-frame RGB
   *   color count exceeds 256, or (3) this encoder object was constructed with
   *   an explicit color table.  
   */
  public void addFrame(Image image) throws IOException
  {
    addFrame(new DirectGif89Frame(image));
  }

  //----------------------------------------------------------------------------
  /** The index-model convenience version of addFrame().
   *
   * @param width
   *   Width of the GIF bitmap.
   * @param height
   *   Height of same.
   * @param ci_pixels
   *   Array of color-index pixels no less than width * height in length.
   * @exception IOException
   *   Actually, in the present implementation, there aren't any unchecked
   *   exceptions that can be thrown when adding an IndexGif89Frame
   *   <i>per se</i>.  But I might add some pedantic check later, to justify the
   *   generality :)
   */ 
  public void addFrame(int width, int height, byte ci_pixels[])
  throws IOException
  {
    addFrame(new IndexGif89Frame(width, height, ci_pixels));
  }   

  //----------------------------------------------------------------------------
  /** Like addFrame() except that the frame is inserted at a specific point in
   *  the sequence rather than appended. 
   *
   * @param index
   *   Zero-based index at which to insert frame.
   * @param gf
   *   An externally constructed Gif89Frame.
   * @exception IOException
   *   If Gif89Frame can't be accommodated.  This could happen if either (1)
   *   the aggregate cross-frame RGB color count exceeds 256, or (2) the
   *   Gif89Frame subclass is incompatible with the present encoder object.
   */  
  public void insertFrame(int index, Gif89Frame gf) throws IOException
  {
    accommodateFrame(gf);
    vFrames.insertElementAt(gf, index);
  }

  //----------------------------------------------------------------------------
  /** Set the color table index for the transparent color, if any.
   *
   * @param index
   *   Index of the color that should be rendered as transparent, if any.
   *   A value of -1 turns off transparency.  (Default: -1)
   */  
  public void setTransparentIndex(int index)
  {
    colorTable.setTransparent(index);
  }
   
  //----------------------------------------------------------------------------
  /** Sets attributes of the multi-image display area, if applicable.
   *
   * @param dim
   *   Width/height of display.  (Default: largest detected frame size)
   * @param background
   *   Color table index of background color.  (Default: 0)
   * @see Gif89Frame#setPosition
   */
  public void setLogicalDisplay(Dimension dim, int background)   
  {
    dispDim = new Dimension(dim);
    bgIndex = background;
  }
 
  //----------------------------------------------------------------------------
  /** Set animation looping parameter, if applicable.
   *
   * @param count
   *   Number of times to play sequence.  Special value of 0 specifies
   *   indefinite looping.  (Default: 1)  
   */   
  public void setLoopCount(int count)
  {
    loopCount = count;
  }

  //----------------------------------------------------------------------------
  /** Specify some textual comments to be embedded in GIF.
   *
   * @param comments
   *   String containing ASCII comments.
   */ 
  public void setComments(String comments)
  {
    theComments = comments;
  }

  //----------------------------------------------------------------------------
  /** A convenience method for setting the "animation speed".  It simply sets
   *  the delay parameter for each frame in the sequence to the supplied value.
   *  Since this is actually frame-level rather than animation-level data, take
   *  care to add your frames before calling this method.
   *
   * @param interval
   *   Interframe interval in centiseconds.
   */
  public void setUniformDelay(int interval)
  {
    for (int i = 0; i < vFrames.size(); ++i)
      ((Gif89Frame) vFrames.elementAt(i)).setDelay(interval);  
  }    

  //----------------------------------------------------------------------------
  /** After adding your frame(s) and setting your options, simply call this
   * method to write the GIF to the passed stream.  Multiple calls are
   * permissible if for some reason that is useful to your application.  (The
   * method simply encodes the current state of the object with no thought
   * to previous calls.)
   *
   * @param out
   *   The stream you want the GIF written to.
   * @exception IOException
   *   If a write error is encountered.
   */
  public void encode(OutputStream out) throws IOException
  {
    int     nframes = getFrameCount();
    boolean is_sequence = nframes > 1;

    // N.B. must be called before writing screen descriptor
    colorTable.closePixelProcessing(); 

    // write GIF HEADER  
    Put.ascii("GIF89a", out);

    // write global blocks
    writeLogicalScreenDescriptor(out);  
    colorTable.encode(out);
    if (is_sequence && loopCount != 1)
      writeNetscapeExtension(out);
    if (theComments != null && theComments.length() > 0)  
      writeCommentExtension(out);

    // write out the control and rendering data for each frame
    for (int i = 0; i < nframes; ++i)
      ((Gif89Frame) vFrames.elementAt(i)).encode(
        out, is_sequence, colorTable.getDepth(), colorTable.getTransparent()
      );

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91精品国产手机| 国产精品99久久久久久似苏梦涵 | 亚洲综合久久久| 中文字幕乱码亚洲精品一区| 国产婷婷色一区二区三区四区| 日韩一区二区三区免费观看| 欧美岛国在线观看| 久久欧美一区二区| 日韩毛片精品高清免费| 亚洲综合色自拍一区| 麻豆精品在线播放| av一区二区三区在线| 色吊一区二区三区| 日韩亚洲电影在线| 国产精品久久久久久久久果冻传媒 | 欧美激情在线一区二区三区| 一区在线观看视频| 亚洲成av人片在线观看| 国产一区二区调教| 色婷婷综合五月| 337p粉嫩大胆噜噜噜噜噜91av| 精品sm在线观看| 亚洲不卡av一区二区三区| 国产高清不卡一区| 在线观看亚洲精品视频| 久久精品亚洲麻豆av一区二区| 亚洲人成精品久久久久| 精品在线免费观看| 欧美日韩一区二区三区高清| 国产亚洲一区字幕| 蜜臀久久99精品久久久画质超高清 | 麻豆成人久久精品二区三区红| 99久久精品99国产精品| 日韩欧美国产电影| 亚洲综合清纯丝袜自拍| 成人av资源在线观看| 国产精品理伦片| 麻豆91精品91久久久的内涵| 欧美中文字幕久久| 一区二区三区精品视频在线| www.成人网.com| 亚洲欧洲日产国码二区| 99精品久久久久久| 亚洲欧洲av另类| 91麻豆视频网站| 亚洲愉拍自拍另类高清精品| 欧美裸体bbwbbwbbw| 亚洲成av人片一区二区| 欧美一区二区黄色| 国产精华液一区二区三区| 久久老女人爱爱| 成人av动漫在线| 亚洲一区二区三区在线播放| 91麻豆精品91久久久久久清纯| 免费成人小视频| 中文字幕在线观看一区二区| 在线免费视频一区二区| 免费成人在线观看视频| 国产欧美日韩视频在线观看| 99久久精品国产观看| 日本亚洲天堂网| 亚洲免费看黄网站| 欧美成人性福生活免费看| 从欧美一区二区三区| 亚洲va欧美va国产va天堂影院| 久久精品水蜜桃av综合天堂| 欧美亚洲综合色| 国产·精品毛片| 国内精品伊人久久久久影院对白| 中文字幕一区二区三区精华液| 91精品国产aⅴ一区二区| 91麻豆精品久久久久蜜臀| 成人一区在线观看| 久久综合综合久久综合| 午夜久久久久久电影| 亚洲一区日韩精品中文字幕| 中文乱码免费一区二区| 国产亚洲精品bt天堂精选| 欧美一区中文字幕| 欧美日韩一级黄| 欧美日韩久久久久久| 欧美日韩一区二区三区视频| 色噜噜夜夜夜综合网| 在线观看av一区二区| 色婷婷激情综合| 欧美日韩日本视频| 欧美在线观看视频一区二区 | 亚洲色图视频免费播放| 国产精品久久一级| 国产精品蜜臀在线观看| 国产精品福利一区二区三区| 国产精品久久久久久久久晋中| 亚洲国产精华液网站w| 亚洲视频一区在线观看| 亚洲丝袜自拍清纯另类| 亚洲高清三级视频| 久久精品噜噜噜成人av农村| 国产精品77777| 欧美一区二区免费视频| 国产日韩欧美精品电影三级在线| 国产精品美女视频| 亚洲小说春色综合另类电影| 六月婷婷色综合| 91一区在线观看| 7777精品伊人久久久大香线蕉完整版| 欧美高清性hdvideosex| 久久精品视频在线看| 一区二区三区美女| 国产一区在线观看麻豆| 在线中文字幕一区| 国产欧美日韩综合精品一区二区| 国产精品久久久久久亚洲毛片 | 欧美成人国产一区二区| 国产精品二区一区二区aⅴ污介绍| 午夜视频在线观看一区二区三区 | 欧美不卡123| 亚洲成人激情自拍| www.在线欧美| 国产日产欧美精品一区二区三区| 香蕉成人啪国产精品视频综合网| 福利视频网站一区二区三区| 91精品在线免费| 亚洲mv在线观看| 色女孩综合影院| 中文字幕亚洲欧美在线不卡| 国产一区二区调教| 久久综合久久99| 国产一区二区伦理| 精品国产伦理网| 韩国三级中文字幕hd久久精品| 欧美日韩一区三区| 欧美aaaaaa午夜精品| 91精品国产综合久久香蕉麻豆| 亚洲美女精品一区| 欧美制服丝袜第一页| 亚洲国产一区视频| 欧美精品丝袜久久久中文字幕| 肉丝袜脚交视频一区二区| 91精品国产福利在线观看| 免费高清视频精品| www精品美女久久久tv| 国产夫妻精品视频| 国产精品女同一区二区三区| 色婷婷亚洲一区二区三区| 亚洲一区二区成人在线观看| 欧美一区二区国产| 国产精品99久久久久久久vr| 亚洲色图一区二区| 欧美夫妻性生活| 成人一区二区三区视频在线观看| 中文字幕不卡三区| 欧美午夜精品免费| 久久99热狠狠色一区二区| 亚洲成人av一区二区| 日韩欧美区一区二| 国产一区美女在线| 亚洲欧洲制服丝袜| 欧美mv日韩mv国产网站app| 国产精品一区免费视频| 亚洲欧美另类在线| 精品国产乱码久久久久久牛牛| 99视频热这里只有精品免费| 日本中文一区二区三区| 国产精品免费视频网站| 日韩欧美的一区| 色婷婷综合激情| 成人av电影在线播放| 九一九一国产精品| 日本欧美一区二区三区乱码| 亚洲欧美日韩国产综合在线| 久久精品在线观看| 久久免费偷拍视频| 久久久亚洲综合| 久久蜜臀精品av| 久久久三级国产网站| 日韩精品影音先锋| 久久综合久久鬼色中文字| 精品日本一线二线三线不卡| 日韩一区二区三区观看| 欧美日本在线观看| 欧美精品久久久久久久多人混战| 欧美性感一类影片在线播放| 一本色道a无线码一区v| 91国内精品野花午夜精品| 色综合久久综合网97色综合| 欧美午夜寂寞影院| 4438成人网| 国产网站一区二区三区| 中文字幕视频一区| 亚洲成人精品一区二区| 蜜桃精品视频在线| av影院午夜一区| 欧美久久一区二区| 国产亚洲午夜高清国产拍精品 | 日韩精品五月天| 韩国一区二区视频| 欧美专区日韩专区| www一区二区| 亚洲高清三级视频| 成人免费毛片app|