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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? gif89encoder.java

?? Gif89Encoder! JAVA環(huán)境下應(yīng)用!
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
    // write GIF TRAILER
    out.write((int) ';');
    
    out.flush();
  }

  //----------------------------------------------------------------------------
  /** A simple driver to test the installation and to demo usage.  Put the JAR
   * on your classpath and run ala
   * <blockquote>java net.jmge.gif.Gif89Encoder {filename}</blockquote>
   * The filename must be either (1) a JPEG file with extension 'jpg', for
   * conversion to a static GIF, or (2) a file containing a list of GIFs and/or
   * JPEGs, one per line, to be combined into an animated GIF.  The output will
   * appear in the current directory as 'gif89out.gif'.
   * <p>
   * (N.B. This test program will abort if the input file(s) exceed(s) 256 total
   * RGB colors, so in its present form it has no value as a generic JPEG to GIF
   * converter.  Also, when multiple files are input, you need to be wary of the
   * total color count, regardless of file type.)
   *
   * @param args
   *   Command-line arguments, only the first of which is used, as mentioned
   *   above. 
   */  
  public static void main(String[] args)
  {
    try {

      Toolkit      tk = Toolkit.getDefaultToolkit();
      OutputStream out = new BufferedOutputStream(
        new FileOutputStream("gif89out.gif")
      );
      
      if (args[0].toUpperCase().endsWith(".JPG"))
        new Gif89Encoder(tk.getImage(args[0])).encode(out);
      else
      {
        BufferedReader in = new BufferedReader(new FileReader(args[0]));   
        Gif89Encoder   ge = new Gif89Encoder();   

        String line;
        while ((line = in.readLine()) != null)
          ge.addFrame(tk.getImage(line.trim()));
        ge.setLoopCount(0);  // let's loop indefinitely 
        ge.encode(out);

        in.close();
      }   
      out.close();
      
    }
    catch (Exception e) { e.printStackTrace(); }
    finally { System.exit(0); } // must kill VM explicitly (Toolkit thread?)
  }

  //----------------------------------------------------------------------------
  private void accommodateFrame(Gif89Frame gf) throws IOException
  {
    dispDim.width = Math.max(dispDim.width, gf.getWidth());
    dispDim.height = Math.max(dispDim.height, gf.getHeight());
    colorTable.processPixels(gf);
  }  

  //----------------------------------------------------------------------------
  private void writeLogicalScreenDescriptor(OutputStream os) throws IOException
  {
    Put.leShort(dispDim.width, os);
    Put.leShort(dispDim.height, os);

    // write 4 fields, packed into a byte  (bitfieldsize:value)
    //   global color map present?         (1:1)
    //   bits per primary color less 1     (3:7)
    //   sorted color table?               (1:0)
    //   bits per pixel less 1             (3:varies)
    os.write(0xf0 | colorTable.getDepth() - 1);

    // write background color index 
    os.write(bgIndex);

    // Jef Poskanzer's notes on the next field, for our possible edification:
    // 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.

    // OK, if it's good enough for Jef, it's definitely good enough for us:
    os.write(0);
  }

  //----------------------------------------------------------------------------
  private void writeNetscapeExtension(OutputStream os) throws IOException
  {
    // n.b. most software seems to interpret the count as a repeat count
    // (i.e., interations beyond 1) rather than as an iteration count
    // (thus, to avoid repeating we have to omit the whole extension)
    
    os.write((int) '!');           // GIF Extension Introducer
    os.write(0xff);                // Application Extension Label
    
    os.write(11);                  // application ID block size
    Put.ascii("NETSCAPE2.0", os);  // application ID data
    
    os.write(3);                   // data sub-block size
    os.write(1);                   // a looping flag? dunno

    // we finally write the relevent data
    Put.leShort(loopCount > 1 ? loopCount - 1 : 0, os); 
    
    os.write(0);                   // block terminator
  }

  //----------------------------------------------------------------------------
  private void writeCommentExtension(OutputStream os) throws IOException
  {
    os.write((int) '!');     // GIF Extension Introducer
    os.write(0xfe);          // Comment Extension Label

    int remainder = theComments.length() % 255;
    int nsubblocks_full = theComments.length() / 255;
    int nsubblocks = nsubblocks_full + (remainder > 0 ? 1 : 0);
    int ibyte = 0;
    for (int isb = 0; isb < nsubblocks; ++isb)
    {
      int size = isb < nsubblocks_full ? 255 : remainder;
      
      os.write(size);
      Put.ascii(theComments.substring(ibyte, ibyte + size), os);
      ibyte += size;
    }

    os.write(0);    // block terminator
  }

  //----------------------------------------------------------------------------
  private boolean isOk(int frame_index)
  {
    return frame_index >= 0 && frame_index < vFrames.size(); 
  }
}

//==============================================================================
class GifColorTable {

  // the palette of ARGB colors, packed as returned by Color.getRGB()
  private int[] theColors = new int[256];
  
  // other basic attributes
  private int   colorDepth;
  private int   transparentIndex = -1;

  // these fields track color-index info across frames
  private int             ciCount = 0; // count of distinct color indices
  private ReverseColorMap ciLookup;    // cumulative rgb-to-ci lookup table

  //----------------------------------------------------------------------------
  GifColorTable()
  {
    ciLookup = new ReverseColorMap();  // puts us into "auto-detect mode"
  }
  
  //----------------------------------------------------------------------------
  GifColorTable(Color[] colors)
  {
    int n2copy = Math.min(theColors.length, colors.length);
    for (int i = 0; i < n2copy; ++i)
      theColors[i] = colors[i].getRGB();
  }

  //----------------------------------------------------------------------------
  int getDepth() { return colorDepth; }  

  //----------------------------------------------------------------------------
  int getTransparent() { return transparentIndex; }  
 
  //----------------------------------------------------------------------------
  // default: -1 (no transparency)
  void setTransparent(int color_index)
  {
    transparentIndex = color_index;
  }

  //----------------------------------------------------------------------------
  void processPixels(Gif89Frame gf) throws IOException
  {
    if (gf instanceof DirectGif89Frame)
      filterPixels((DirectGif89Frame) gf);
    else 
      trackPixelUsage((IndexGif89Frame) gf);
  }   
 
  //----------------------------------------------------------------------------
  void closePixelProcessing()  // must be called before encode()
  {
    colorDepth = computeColorDepth(ciCount);
  }

  //----------------------------------------------------------------------------
  void encode(OutputStream os) throws IOException
  {
    // size of palette written is the smallest power of 2 that can accomdate
    // the number of RGB colors detected (or largest color index, in case of
    // index pixels)
    int palette_size = 1 << colorDepth; 
    for (int i = 0; i < palette_size; ++i)
    {
      os.write(theColors[i] >> 16 & 0xff);
      os.write(theColors[i] >>  8 & 0xff);
      os.write(theColors[i] & 0xff);
    }
  }

  //----------------------------------------------------------------------------
  // This method accomplishes three things:
  // (1) converts the passed rgb pixels to indexes into our rgb lookup table
  // (2) fills the rgb table as new colors are encountered
  // (3) looks for transparent pixels so as to set the transparent index
  // The information is cumulative across multiple calls.
  //
  // (Note: some of the logic is borrowed from Jef Poskanzer's code.)
  //---------------------------------------------------------------------------- 
  private void filterPixels(DirectGif89Frame dgf) throws IOException
  {
    if (ciLookup == null)
      throw new IOException("RGB frames require palette autodetection");
    
    int[]  argb_pixels = (int[]) dgf.getPixelSource(); 
    byte[] ci_pixels = dgf.getPixelSink();   
    int    npixels = argb_pixels.length;
    for (int i = 0; i < npixels; ++i)
    {
      int argb = argb_pixels[i];

      // handle transparency
      if ((argb >>> 24) < 0x80)        // transparent pixel?
        if (transparentIndex == -1)    // first transparent color encountered?
          transparentIndex = ciCount;  // record its index
        else if (argb != theColors[transparentIndex]) // different pixel value?
        {
          // collapse all transparent pixels into one color index
          ci_pixels[i] = (byte) transparentIndex; 
          continue;  // CONTINUE - index already in table
        }  

      // try to look up the index in our "reverse" color table
      int color_index = ciLookup.getPaletteIndex(argb & 0xffffff);
    
      if (color_index == -1)  // if it isn't in there yet
      {
        if (ciCount == 256)
          throw new IOException("can't encode as GIF (> 256 colors)");

        // store color in our accumulating palette
        theColors[ciCount] = argb;  

        // store index in reverse color table  
        ciLookup.put(argb & 0xffffff, ciCount);

        // send color index to our output array
        ci_pixels[i] = (byte) ciCount;

        // increment count of distinct color indices
        ++ciCount;
      }
      else  // we've already snagged color into our palette
        ci_pixels[i] = (byte) color_index;  // just send filtered pixel   
    }
  }  

  //----------------------------------------------------------------------------
  private void trackPixelUsage(IndexGif89Frame igf) throws IOException
  {   
    byte[] ci_pixels = (byte[]) igf.getPixelSource(); 
    int    npixels = ci_pixels.length;   
    for (int i = 0; i < npixels; ++i)
      if (ci_pixels[i] >= ciCount)
        ciCount = ci_pixels[i] + 1;
  }

  //----------------------------------------------------------------------------
  private int computeColorDepth(int colorcount)
  {
    // color depth = log-base-2 of maximum number of simultaneous colors, i.e.
    // bits per color-index pixel    
    if (colorcount <= 2)
      return 1;      
    if (colorcount <= 4)
      return 2;      
    if (colorcount <= 16)
      return 4;
    return 8;    
  }    
}

//==============================================================================
// We're doing a very simple linear hashing thing here, which seems sufficient
// for our needs.  I make no claims for this approach other than that it seems
// an improvement over doing a brute linear search for each pixel on the one
// hand, and creating a Java object for each pixel (if we were to use a Java
// Hashtable) on the other.  Doubtless my little hash could be improved by
// tuning the capacity (at the very least).  Suggestions are welcome.
//==============================================================================
class ReverseColorMap {

  private static class ColorRecord {
    int rgb;
    int ipalette;
    ColorRecord(int rgb, int ipalette)
    {
      this.rgb = rgb;
      this.ipalette = ipalette;
    }
  }

  // I wouldn't really know what a good hashing capacity is, having missed out
  // on data structures and algorithms class :)  Alls I know is, we've got a lot
  // more space than we have time.  So let's try a sparse table with a maximum
  // load of about 1/8 capacity.
  private static final int HCAPACITY = 2053;  // a nice prime number

  // our hash table proper
  private ColorRecord[] hTable = new ColorRecord[HCAPACITY];

  //----------------------------------------------------------------------------
  // Assert: rgb is not negative (which is the same as saying, be sure the
  // alpha transparency byte - i.e., the high byte - has been masked out).
  //----------------------------------------------------------------------------
  int getPaletteIndex(int rgb) 
  {      
    ColorRecord rec;

    for ( int itable = rgb % hTable.length;    
          (rec = hTable[itable]) != null && rec.rgb != rgb;
          itable = ++itable % hTable.length
        ) 
      ;

    if (rec != null)
      return rec.ipalette;
      
    return -1;    
  }

  //----------------------------------------------------------------------------
  // Assert: (1) same as above; (2) rgb key not already present
  //----------------------------------------------------------------------------
  void put(int rgb, int ipalette) 
  {
    int itable;
    
    for ( itable = rgb % hTable.length;    
          hTable[itable] != null;
          itable = ++itable % hTable.length
        ) 
      ;    

    hTable[itable] = new ColorRecord(rgb, ipalette);   
  }
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲一二三四在线| 色偷偷一区二区三区| 99久久精品一区二区| 日韩视频免费观看高清完整版| 中文字幕一区日韩精品欧美| 久久国产精品无码网站| 欧美日韩精品一区二区三区蜜桃| 国产精品免费人成网站| 国产在线一区观看| 91精品国产乱码| 亚洲福中文字幕伊人影院| www.欧美.com| 中文无字幕一区二区三区| 国产一本一道久久香蕉| 日韩精品中文字幕一区| 日韩精品成人一区二区三区| 欧美伊人久久久久久久久影院| 日韩精品亚洲一区二区三区免费| 91丝袜国产在线播放| 欧美高清在线一区二区| 国产成人精品综合在线观看 | 亚洲国产精品欧美一二99| 国产成人高清在线| 久久久久久毛片| 国产成人小视频| 中文字幕的久久| 高清国产一区二区三区| 中文字幕 久热精品 视频在线 | 欧美国产1区2区| 国产99久久久精品| 亚洲国产成人一区二区三区| 懂色中文一区二区在线播放| 国产欧美日韩激情| 99精品视频在线播放观看| 国产精品国产成人国产三级| 成人中文字幕电影| 国产精品毛片大码女人| 色视频一区二区| 亚洲网友自拍偷拍| 日韩视频在线永久播放| 久久成人久久爱| 国产日本欧洲亚洲| aa级大片欧美| 午夜精品国产更新| 欧美电影免费观看高清完整版| 麻豆精品在线视频| 久久夜色精品国产欧美乱极品| 国产电影一区二区三区| 亚洲欧美日韩国产综合在线| 欧美美女视频在线观看| 精品一区二区在线视频| 国产精品免费av| 91成人在线观看喷潮| 美女在线一区二区| 日本一区二区三级电影在线观看| 色综合视频在线观看| 午夜欧美电影在线观看| 26uuu精品一区二区| 99久久久免费精品国产一区二区| 五月开心婷婷久久| 欧美激情综合五月色丁香小说| 在线视频国产一区| 国产一区二区女| 伊人一区二区三区| 久久亚洲一级片| 欧美日韩三级视频| 风间由美一区二区三区在线观看| 一区二区三区色| 国产欧美久久久精品影院| 欧美性受xxxx黑人xyx性爽| 国产一区二区伦理| 亚洲国产日韩a在线播放| 国产亚洲精品7777| 中文字幕欧美日本乱码一线二线| 欧美视频自拍偷拍| 成人开心网精品视频| 久久精品国产网站| 一区二区在线免费观看| 国产欧美日韩亚州综合| 日韩一区二区三区四区| 色狠狠色狠狠综合| 国产·精品毛片| 久久精品国产一区二区三 | 欧美日韩在线不卡| 成人黄色一级视频| 青青草国产成人av片免费| 日韩伦理免费电影| 国产免费成人在线视频| 欧美一区二区三区播放老司机| 色哟哟国产精品| 成人av资源在线| 国产一区二区三区黄视频 | 久久99精品国产麻豆不卡| 一区二区三区高清不卡| 国产精品麻豆久久久| 久久色.com| 欧美成人女星排行榜| 欧美二区三区的天堂| 91久久精品午夜一区二区| 91亚洲永久精品| 粉嫩av一区二区三区| 国产精品一区二区在线看| 激情图区综合网| 精品一区二区影视| 久久精品国产成人一区二区三区| 午夜精品一区在线观看| 亚洲综合区在线| 亚洲曰韩产成在线| 亚洲第一主播视频| 亚洲成a人v欧美综合天堂| 亚洲国产精品久久久久婷婷884| 亚洲六月丁香色婷婷综合久久| 一区精品在线播放| 成人免费在线视频观看| 亚洲三级小视频| 亚洲午夜久久久久久久久电影院 | 久久电影网电视剧免费观看| 美女被吸乳得到大胸91| 紧缚奴在线一区二区三区| 国产另类ts人妖一区二区| 国产suv一区二区三区88区| 丁香激情综合五月| eeuss影院一区二区三区| 91麻豆高清视频| 欧美日韩精品三区| 91精品福利在线一区二区三区| 日韩精品中文字幕在线不卡尤物| 久久久久久久精| 成人欧美一区二区三区1314| 亚洲国产视频在线| 美女视频网站黄色亚洲| 国产宾馆实践打屁股91| 色婷婷综合中文久久一本| 欧美日韩在线不卡| 久久青草欧美一区二区三区| 国产精品色噜噜| 五月天视频一区| 国产福利不卡视频| 在线免费观看不卡av| 欧美一区二区三区视频在线观看| 日韩欧美视频在线| 中文字幕欧美一| 日本一道高清亚洲日美韩| 高清在线观看日韩| 欧美性视频一区二区三区| 日韩精品一区国产麻豆| 中文字幕av一区 二区| 亚洲精品成人悠悠色影视| 麻豆国产精品一区二区三区| 成人av电影免费观看| 欧美一级淫片007| 中文字幕一区二区三区视频| 天堂va蜜桃一区二区三区漫画版 | 国产精品麻豆久久久| 亚洲va欧美va天堂v国产综合| 国产精品综合二区| 欧美日韩在线播放三区四区| 国产欧美一区二区三区沐欲| 婷婷综合久久一区二区三区| 丰满少妇在线播放bd日韩电影| 欧美另类videos死尸| 国产精品成人免费精品自在线观看 | 99久久伊人精品| 制服.丝袜.亚洲.中文.综合| 国产精品福利影院| 美女mm1313爽爽久久久蜜臀| 日本乱人伦aⅴ精品| 中文字幕av一区 二区| 精品在线观看视频| 欧美精品视频www在线观看| 亚洲欧美色一区| 岛国精品一区二区| 精品处破学生在线二十三| 亚洲一区二区3| 91麻豆国产自产在线观看| 国产欧美日本一区二区三区| 麻豆一区二区在线| 91精品国产综合久久久久久久久久 | 亚洲人亚洲人成电影网站色| 一本色道久久综合狠狠躁的推荐 | 国产精品福利影院| 奇米综合一区二区三区精品视频| 在线观看中文字幕不卡| 综合亚洲深深色噜噜狠狠网站| 国产麻豆成人传媒免费观看| 日韩欧美国产精品| 日本成人在线电影网| 欧美三级中文字幕| 亚洲妇熟xx妇色黄| 在线观看欧美黄色| 亚洲激情网站免费观看| 99久久综合国产精品| 国产精品乱码一区二三区小蝌蚪| 国产精品一二三四| 中文字幕免费不卡| 成人在线一区二区三区| 国产精品国产三级国产a| 91免费视频观看| 亚洲伊人伊色伊影伊综合网| 在线观看91视频|