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

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

?? jpegdecoder.java

?? Free Software Foundation Inc.公司用java寫的jpeg解碼器。一個優秀的圖像解碼器面向對象模型。
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/* JPEGDecoder.java --
   Copyright (C)  2006  Free Software Foundation, Inc.

This file is part of GNU Classpath.

GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING.  If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.

Linking this library statically or dynamically with other modules is
making a combined work based on this library.  Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.

As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module.  An independent module is a module which is not derived from
or based on this library.  If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so.  If you do not wish to do so, delete this
exception statement from your version. */

package gnu.javax.imageio.jpeg;

import java.io.IOException;
import java.nio.ByteOrder;

import javax.imageio.*;
import javax.imageio.plugins.jpeg.JPEGHuffmanTable;
import javax.imageio.plugins.jpeg.JPEGQTable;
import javax.imageio.spi.*;
import javax.imageio.metadata.*;
import javax.imageio.stream.ImageInputStream;

import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;
import java.awt.Point;
import java.awt.Transparency;
import java.awt.color.ColorSpace;
import java.awt.image.BufferedImage;
import java.awt.image.ComponentColorModel;
import java.awt.image.DataBuffer;
import java.awt.image.Raster;
import java.awt.image.WritableRaster;

public class JPEGDecoder
{
  byte majorVersion;
  byte minorVersion;
  byte units;
  short Xdensity;
  short Ydensity;
  byte Xthumbnail;
  byte Ythumbnail;
  byte[] thumbnail;
  BufferedImage image;
  int width;
  int height;
  
  byte marker;

  /**
   * This decoder expects JFIF 1.02 encoding.
   */
  public static final byte MAJOR_VERSION = (byte) 1;
  public static final byte MINOR_VERSION = (byte) 2;

  /**
   * The length of the JFIF field not including thumbnail data.
   */
  public static final short JFIF_FIXED_LENGTH = 16;

  /**
   * The length of the JFIF extension field not including extension
   * data.
   */
  public static final short JFXX_FIXED_LENGTH = 8;

  private JPEGImageInputStream jpegStream;

  ArrayList jpegFrames = new ArrayList();

  JPEGHuffmanTable[] dcTables = new JPEGHuffmanTable[4];
  JPEGHuffmanTable[] acTables = new JPEGHuffmanTable[4];
  JPEGQTable[] qTables = new JPEGQTable[4];

    public int getHeight()
    {
      return height;
    }
    
    public int getWidth()
    {
        return width;
    }
  public JPEGDecoder(ImageInputStream in)
    throws IOException, JPEGException
  {
    jpegStream = new JPEGImageInputStream(in);
    jpegStream.setByteOrder(ByteOrder.LITTLE_ENDIAN);

    if (jpegStream.findNextMarker() != JPEGMarker.SOI)
      throw new JPEGException("Failed to find SOI marker.");

    if (jpegStream.findNextMarker() != JPEGMarker.APP0)
      throw new JPEGException("Failed to find APP0 marker.");

    int length = jpegStream.readShort();
    if (!(length >= JFIF_FIXED_LENGTH))
      throw new JPEGException("Failed to find JFIF field.");

    byte[] identifier = new byte[5];
    jpegStream.read(identifier);
    if (identifier[0] != JPEGMarker.JFIF_J
        || identifier[1] != JPEGMarker.JFIF_F
        || identifier[2] != JPEGMarker.JFIF_I
        || identifier[3] != JPEGMarker.JFIF_F
        || identifier[4] != JPEGMarker.X00)
      throw new JPEGException("Failed to read JFIF identifier.");

    majorVersion = jpegStream.readByte();
    minorVersion = jpegStream.readByte();
    if (majorVersion != MAJOR_VERSION
        || (majorVersion == MAJOR_VERSION
            && minorVersion < MINOR_VERSION))
      throw new JPEGException("Unsupported JFIF version.");

    units = jpegStream.readByte();
    if (units > (byte) 2)
      throw new JPEGException("Units field is out of range.");

    Xdensity = jpegStream.readShort();
    Ydensity = jpegStream.readShort();
    Xthumbnail = jpegStream.readByte();
    Ythumbnail = jpegStream.readByte();

    // 3 * for RGB data
    int thumbnailLength = 3 * Xthumbnail * Ythumbnail;
    if (length > JFIF_FIXED_LENGTH
        && thumbnailLength != length - JFIF_FIXED_LENGTH)
      throw new JPEGException("Invalid length, Xthumbnail"
                              + " or Ythumbnail field.");

    if (thumbnailLength > 0)
      {
        thumbnail = new byte[thumbnailLength];
        if (jpegStream.read(thumbnail) != thumbnailLength)
          throw new IOException("Failed to read thumbnail.");
      }
  }

  public void decode()
    throws IOException
  {
    System.out.println ("DECODE!!!");
    // The frames in this jpeg are loaded into a list. There is
    // usually just one frame except in heirarchial progression where
    // there are multiple frames.
    JPEGFrame frame = null;

    // The restart interval defines how many MCU's we should have
    // between the 8-modulo restart marker. The restart markers allow
    // us to tell whether or not our decoding process is working
    // correctly, also if there is corruption in the image we can
    // recover with these restart intervals. (See RSTm DRI).
    int resetInterval = 0;

    // The JPEGDecoder constructor parses the JFIF field.  At this
    // point jpegStream points to the first byte after the JFIF field.

    // Find the first marker after the JFIF field.
    byte marker = jpegStream.findNextMarker();

    // Check for a JFIF extension field directly following the JFIF
    // header and advance the current marker to the next marker in the
    // stream, if necessary.
    decodeJFIFExtension();

    // Loop through until there are no more markers to read in, at
    // that point everything is loaded into the jpegFrames array and
    // can be processed.
    while (true)
      {
        switch (marker)
          {
            // APPn Application Reserved Information - Just throw this
            // information away because we wont be using it.
          case JPEGMarker.APP0:
          case JPEGMarker.APP1:
          case JPEGMarker.APP2:
          case JPEGMarker.APP3:
          case JPEGMarker.APP4:
          case JPEGMarker.APP5:
          case JPEGMarker.APP6:
          case JPEGMarker.APP7:
          case JPEGMarker.APP8:
          case JPEGMarker.APP9:
          case JPEGMarker.APP10:
          case JPEGMarker.APP11:
          case JPEGMarker.APP12:
          case JPEGMarker.APP13:
          case JPEGMarker.APP14:
          case JPEGMarker.APP15:
            jpegStream.skipBytes(jpegStream.readShort() - 2);
            break;

          case JPEGMarker.SOF0:
            // SOFn Start of Frame Marker, Baseline DCT - This is the start
            // of the frame header that defines certain variables that will
            // be carried out through the rest of the encoding. Multiple
            // frames are used in a heirarchiel system, however most JPEG's
            // only contain a single frame.
            jpegFrames.add(new JPEGFrame());
            frame = (JPEGFrame) jpegFrames.get(jpegFrames.size() - 1);
            // Skip the frame length.
            jpegStream.readShort();
            // Bits percision, either 8 or 12.
            frame.setPrecision(jpegStream.readByte());
            // Scan lines = to the height of the frame.
            frame.setScanLines(jpegStream.readShort());
            // Scan samples per line = to the width of the frame.
            frame.setSamplesPerLine(jpegStream.readShort());
            // Number of Color Components (or channels).
            frame.setComponentCount(jpegStream.readByte());

            // Set the color mode for this frame, so far only 2 color
            // modes are supported.
            if (frame.getComponentCount() == 1)
              frame.setColorMode(JPEGFrame.JPEG_COLOR_GRAY);
            else
              frame.setColorMode(JPEGFrame.JPEG_COLOR_YCbCr);
            // Add all of the necessary components to the frame.
            for (int i = 0; i < frame.getComponentCount(); i++)
              frame.addComponent(jpegStream.readByte(), jpegStream.readByte(),
                                 jpegStream.readByte());
            break;

          case JPEGMarker.SOF2:
            jpegFrames.add(new JPEGFrame());
            frame = (JPEGFrame) jpegFrames.get(jpegFrames.size() - 1);
            // Skip the frame length.
            jpegStream.readShort();
            // Bits percision, either 8 or 12.
            frame.setPrecision(jpegStream.readByte());
            // Scan lines = to the height of the frame.
            frame.setScanLines(jpegStream.readShort());
            // Scan samples per line = to the width of the frame.
            frame.setSamplesPerLine(jpegStream.readShort());
            // Number of Color Components (or channels).
            frame.setComponentCount(jpegStream.readByte());

            // Set the color mode for this frame, so far only 2 color
            // modes are supported.
            if (frame.getComponentCount() == 1)
              frame.setColorMode(JPEGFrame.JPEG_COLOR_GRAY);
            else
              frame.setColorMode(JPEGFrame.JPEG_COLOR_YCbCr);

            // Add all of the necessary components to the frame.
            for (int i = 0; i < frame.getComponentCount(); i++)
              frame.addComponent(jpegStream.readByte(), jpegStream.readByte(),
                                 jpegStream.readByte());
            break;

          case JPEGMarker.DHT:
            // DHT non-SOF Marker - Huffman Table is required for decoding
            // the JPEG stream, when we receive a marker we load in first
            // the table length (16 bits), the table class (4 bits), table
            // identifier (4 bits), then we load in 16 bytes and each byte
            // represents the count of bytes to load in for each of the 16
            // bytes. We load this into an array to use later and move on 4
            // huffman tables can only be used in an image.
            int huffmanLength = (jpegStream.readShort() - 2);

            // Keep looping until we are out of length.
            int index = huffmanLength;

            // Multiple tables may be defined within a DHT marker. This
            // will keep reading until there are no tables left, most
            // of the time there are just one tables.
            while (index > 0)
              {
                // Read the identifier information and class
                // information about the Huffman table, then read the
                // 16 byte codelength in and read in the Huffman values
                // and put it into table info.
                byte huffmanInfo = jpegStream.readByte();
                byte tableClass = (byte) (huffmanInfo >> 4);
                byte huffmanIndex = (byte) (huffmanInfo & 0x0f);
                short[] codeLength = new short[16];
                jpegStream.readFully(codeLength, 0, codeLength.length);
                int huffmanValueLen = 0;
                for (int i = 0; i < 16; i++)
                  huffmanValueLen += codeLength[i];
                index -= (huffmanValueLen + 17);
                short[] huffmanVal = new short[huffmanValueLen];
                for (int i = 0; i < huffmanVal.length; i++)
                  huffmanVal[i] = jpegStream.readByte();
                // Assign DC Huffman Table.
                if (tableClass == HuffmanTable.JPEG_DC_TABLE)

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美午夜精品一区二区三区| 日韩国产一区二| 国产一区二区三区免费看| 久久先锋影音av鲁色资源| 成人午夜激情在线| 亚洲国产aⅴ成人精品无吗| 欧美tk—视频vk| 91浏览器打开| 国内精品久久久久影院一蜜桃| 国产精品丝袜91| 欧美美女视频在线观看| 成人夜色视频网站在线观看| 国产一区二区主播在线| 精品系列免费在线观看| 国产精品一区二区久久不卡| 日韩毛片高清在线播放| 欧美成人r级一区二区三区| 欧美一区二区不卡视频| 色诱视频网站一区| 从欧美一区二区三区| 不卡的看片网站| 国产精品18久久久久久久网站| 国产乱人伦精品一区二区在线观看| 国产精品一区二区黑丝| 成人在线综合网| 97精品国产露脸对白| 国产精品一区二区三区乱码| 成人黄色小视频在线观看| 97国产一区二区| 欧美一区二区三区的| 久久日一线二线三线suv| 中文字幕视频一区二区三区久| 久久这里只有精品首页| 亚洲图片欧美激情| 日本欧美加勒比视频| 91精品国产麻豆| 国产日产欧美一区二区视频| 欧美大片在线观看一区| 777亚洲妇女| 日韩一级片在线播放| 欧美一级日韩免费不卡| 国产日韩欧美麻豆| 亚洲二区在线观看| 成人综合婷婷国产精品久久蜜臀 | 91精品婷婷国产综合久久| 337p粉嫩大胆噜噜噜噜噜91av| 成人欧美一区二区三区小说| 美女www一区二区| 麻豆一区二区99久久久久| 成人av网站大全| 日韩欧美国产综合一区 | 99久久夜色精品国产网站| 欧美一区日韩一区| 伊人开心综合网| 午夜av一区二区三区| 蜜桃视频第一区免费观看| 91色视频在线| 欧美国产综合一区二区| 亚洲三级理论片| 国产精品18久久久久久vr| 久久av中文字幕片| 成人一区二区三区| 亚洲最色的网站| 日韩黄色免费电影| 国产精品亚洲一区二区三区妖精 | 国产一区二区三区免费| 欧美一级二级三级蜜桃| 亚洲一区中文日韩| 国产综合色在线视频区| 欧美精品久久一区| 婷婷久久综合九色综合伊人色| 91天堂素人约啪| 亚洲视频一区在线| 99re这里只有精品首页| 国产精品白丝在线| 毛片av中文字幕一区二区| 4438x亚洲最大成人网| 亚洲一二三区不卡| 欧美三级蜜桃2在线观看| 久久精品一区二区三区不卡牛牛| 一区二区三区不卡在线观看| 精品国产一区二区精华| 中文字幕欧美一区| 99久久婷婷国产| 一区二区三区在线影院| 色综合久久中文字幕| 亚洲麻豆国产自偷在线| 国产在线播放一区二区三区| 精品成人一区二区三区四区| 国产精品一区二区91| 欧美国产日韩一二三区| av电影在线观看完整版一区二区 | 久久99最新地址| 欧美成人激情免费网| 国产精品一线二线三线精华| 欧美国产日本视频| 色综合欧美在线| 日韩国产高清在线| 久久久不卡网国产精品一区| 石原莉奈在线亚洲三区| 久久综合九色综合欧美98| 成熟亚洲日本毛茸茸凸凹| 亚洲男人的天堂在线aⅴ视频| 在线亚洲一区二区| 26uuu精品一区二区| eeuss鲁一区二区三区| 亚洲成在人线在线播放| 色八戒一区二区三区| 日韩精品亚洲专区| 久久久精品天堂| 欧美羞羞免费网站| 国产麻豆精品95视频| 亚洲欧美韩国综合色| 精品日韩一区二区三区| 99re8在线精品视频免费播放| 亚洲午夜免费电影| 亚洲国产精品t66y| 7878成人国产在线观看| av在线播放不卡| 久久爱www久久做| 亚洲综合色网站| 中文一区一区三区高中清不卡| 欧美日韩中文另类| jvid福利写真一区二区三区| 日本怡春院一区二区| 亚洲天堂网中文字| 2020国产成人综合网| 欧美日韩国产一级片| 丝袜美腿成人在线| 亚洲三级久久久| 久久精品在线免费观看| 欧美一级理论性理论a| 91丨porny丨户外露出| 国产98色在线|日韩| 亚洲欧洲av一区二区三区久久| 日韩一区二区三| 欧美在线小视频| 91麻豆福利精品推荐| 懂色av一区二区三区免费观看 | 精品精品欲导航| 欧美少妇bbb| 一本大道av一区二区在线播放| 国产精品一区二区果冻传媒| 美女在线一区二区| 午夜精品久久久久久不卡8050| 亚洲欧美日韩中文字幕一区二区三区 | 欧美本精品男人aⅴ天堂| 91在线小视频| 久久午夜国产精品| 欧美色精品在线视频| 欧美伊人精品成人久久综合97| av激情综合网| 一本一道综合狠狠老| 一本久久a久久精品亚洲| 不卡的看片网站| 91美女视频网站| av亚洲产国偷v产偷v自拍| eeuss鲁片一区二区三区在线看| 成人综合婷婷国产精品久久蜜臀| 国产不卡视频一区| 国产.欧美.日韩| 成人爽a毛片一区二区免费| 懂色av一区二区三区蜜臀 | 国产精品成人免费精品自在线观看| xvideos.蜜桃一区二区| 久久久精品欧美丰满| 中文字幕不卡的av| 国产精品伦理在线| 亚洲精品视频自拍| 亚洲图片欧美色图| 日韩国产欧美在线视频| 精品一区二区在线播放| 国产91在线观看丝袜| 99久久久国产精品| 欧美三级视频在线观看| 日韩免费福利电影在线观看| 久久综合九色综合欧美亚洲| 欧美国产成人精品| 亚洲综合色丁香婷婷六月图片| 天天做天天摸天天爽国产一区 | 成人午夜激情视频| 在线观看日韩一区| 亚洲精品一区二区精华| 国产精品久久久久久久久晋中| 亚洲免费在线观看| 老司机精品视频在线| 粉嫩13p一区二区三区| 欧美日韩黄色一区二区| 久久久五月婷婷| 亚洲一二三四在线观看| 久久成人综合网| 色综合一区二区三区| 丁香激情综合国产| 欧美日韩免费在线视频| 国产偷v国产偷v亚洲高清| 伊人一区二区三区| 国产一区不卡在线| 欧美美女视频在线观看| 国产精品灌醉下药二区| 奇米精品一区二区三区在线观看一|