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

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

?? jpegencoder.java

?? java servlet著名論壇源代碼
?? JAVA
?? 第 1 頁 / 共 4 頁
字號:
package net.myvietnam.mvncore.thirdparty;
// Version 1.0a
// Copyright (C) 1998, James R. Weeks and BioElectroMech.
// Visit BioElectroMech at www.obrador.com.  Email James@obrador.com.

// See license.txt for details about the allowed used of this software.
// This software is based in part on the work of the Independent JPEG Group.
// See IJGreadme.txt for details about the Independent JPEG Group's license.

// This encoder is inspired by the Java Jpeg encoder by Florian Raemy,
// studwww.eurecom.fr/~raemy.
// It borrows a great deal of code and structure from the Independent
// Jpeg Group's Jpeg 6a library, Copyright Thomas G. Lane.
// See license.txt for details.

import java.awt.AWTException;
import java.awt.Frame;
import java.awt.Image;
import java.awt.MediaTracker;
import java.awt.image.PixelGrabber;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Vector;

/*
* JpegEncoder - The JPEG main program which performs a jpeg compression of
* an image.
*/

public class JpegEncoder extends Frame
{
    Thread runner;
    BufferedOutputStream outStream;
    Image image;
    JpegInfo JpegObj;
    Huffman Huf;
    DCT dct;
    int imageHeight, imageWidth;
    int Quality;
    int code;
    public static int[] jpegNaturalOrder = {
          0,  1,  8, 16,  9,  2,  3, 10,
         17, 24, 32, 25, 18, 11,  4,  5,
         12, 19, 26, 33, 40, 48, 41, 34,
         27, 20, 13,  6,  7, 14, 21, 28,
         35, 42, 49, 56, 57, 50, 43, 36,
         29, 22, 15, 23, 30, 37, 44, 51,
         58, 59, 52, 45, 38, 31, 39, 46,
         53, 60, 61, 54, 47, 55, 62, 63,
        };

    public JpegEncoder(Image image, int quality, OutputStream out)
    {
                MediaTracker tracker = new MediaTracker(this);
                tracker.addImage(image, 0);
                try {
                        tracker.waitForID(0);
                }
                catch (InterruptedException e) {
                    //TODO
                }
        /*
        * Quality of the image.
        * 0 to 100 and from bad image quality, high compression to good
        * image quality low compression
        */
        Quality=quality;

        /*
        * Getting picture information
        * It takes the Width, Height and RGB scans of the image.
        */
        JpegObj = new JpegInfo(image);

        imageHeight=JpegObj.imageHeight;
        imageWidth=JpegObj.imageWidth;
        outStream = new BufferedOutputStream(out);
        dct = new DCT(Quality);
        Huf=new Huffman(imageWidth,imageHeight);
    }

    public void setQuality(int quality) {
        dct = new DCT(quality);
    }

    public int getQuality() {
        return Quality;
    }

    public void Compress() {
        WriteHeaders(outStream);
        WriteCompressedData(outStream);
        WriteEOI(outStream);
        try {
                outStream.flush();
        } catch (IOException e) {
            //TODO
                System.out.println("IO Error: " + e.getMessage());
        }
    }

    public void WriteCompressedData(BufferedOutputStream outStream) {
        int i, j, r, c,a ,b;
        int comp, xpos, ypos, xblockoffset, yblockoffset;
        float inputArray[][];
        float dctArray1[][] = new float[8][8];
        double dctArray2[][] = new double[8][8];
        int dctArray3[] = new int[8*8];

        /*
         * This method controls the compression of the image.
         * Starting at the upper left of the image, it compresses 8x8 blocks
         * of data until the entire image has been compressed.
         */

        int lastDCvalue[] = new int[JpegObj.NumberOfComponents];
        //int zeroArray[] = new int[64]; // initialized to hold all zeros
        //int Width = 0, Height = 0;
        //int nothing = 0, not;
        int MinBlockWidth, MinBlockHeight;
// This initial setting of MinBlockWidth and MinBlockHeight is done to
// ensure they start with values larger than will actually be the case.
        MinBlockWidth = ((imageWidth%8 != 0) ? (int) (Math.floor(imageWidth/8d) + 1)*8 : imageWidth);
        MinBlockHeight = ((imageHeight%8 != 0) ? (int) (Math.floor(imageHeight/8d) + 1)*8: imageHeight);
        for (comp = 0; comp < JpegObj.NumberOfComponents; comp++) {
                MinBlockWidth = Math.min(MinBlockWidth, JpegObj.BlockWidth[comp]);
                MinBlockHeight = Math.min(MinBlockHeight, JpegObj.BlockHeight[comp]);
        }
        xpos = 0;
        for (r = 0; r < MinBlockHeight; r++) {
           for (c = 0; c < MinBlockWidth; c++) {
               xpos = c*8;
               ypos = r*8;
               for (comp = 0; comp < JpegObj.NumberOfComponents; comp++) {
                  //Width = JpegObj.BlockWidth[comp];
                  //Height = JpegObj.BlockHeight[comp];
                  inputArray = JpegObj.Components[comp];

                  for(i = 0; i < JpegObj.VsampFactor[comp]; i++) {
                     for(j = 0; j < JpegObj.HsampFactor[comp]; j++) {
                        xblockoffset = j * 8;
                        yblockoffset = i * 8;
                        for (a = 0; a < 8; a++) {
                           for (b = 0; b < 8; b++) {

// I believe this is where the dirty line at the bottom of the image is
// coming from.  I need to do a check here to make sure I'm not reading past
// image data.
// This seems to not be a big issue right now. (04/04/98)

                              dctArray1[a][b] = inputArray[ypos + yblockoffset + a][xpos + xblockoffset + b];
                           }
                        }
// The following code commented out because on some images this technique
// results in poor right and bottom borders.
//                        if ((!JpegObj.lastColumnIsDummy[comp] || c < Width - 1) && (!JpegObj.lastRowIsDummy[comp] || r < Height - 1)) {
                           dctArray2 = dct.forwardDCT(dctArray1);
                           dctArray3 = dct.quantizeBlock(dctArray2, JpegObj.QtableNumber[comp]);
//                        }
//                        else {
//                           zeroArray[0] = dctArray3[0];
//                           zeroArray[0] = lastDCvalue[comp];
//                           dctArray3 = zeroArray;
//                        }
                        Huf.HuffmanBlockEncoder(outStream, dctArray3, lastDCvalue[comp], JpegObj.DCtableNumber[comp], JpegObj.ACtableNumber[comp]);
                        lastDCvalue[comp] = dctArray3[0];
                     }
                  }
               }
            }
        }
        Huf.flushBuffer(outStream);
    }

    public void WriteEOI(BufferedOutputStream out) {
        byte[] EOI = {(byte) 0xFF, (byte) 0xD9};
        WriteMarker(EOI, out);
    }

    public void WriteHeaders(BufferedOutputStream out) {
        int i, j, index, offset, length;
        int tempArray[];

// the SOI marker
        byte[] SOI = {(byte) 0xFF, (byte) 0xD8};
        WriteMarker(SOI, out);

// The order of the following headers is quiet inconsequential.
// the JFIF header
        byte JFIF[] = new byte[18];
        JFIF[0] = (byte) 0xff;
        JFIF[1] = (byte) 0xe0;
        JFIF[2] = (byte) 0x00;
        JFIF[3] = (byte) 0x10;
        JFIF[4] = (byte) 0x4a;
        JFIF[5] = (byte) 0x46;
        JFIF[6] = (byte) 0x49;
        JFIF[7] = (byte) 0x46;
        JFIF[8] = (byte) 0x00;
        JFIF[9] = (byte) 0x01;
        JFIF[10] = (byte) 0x00;
        JFIF[11] = (byte) 0x00;
        JFIF[12] = (byte) 0x00;
        JFIF[13] = (byte) 0x01;
        JFIF[14] = (byte) 0x00;
        JFIF[15] = (byte) 0x01;
        JFIF[16] = (byte) 0x00;
        JFIF[17] = (byte) 0x00;
        WriteArray(JFIF, out);

// Comment Header
        String comment = new String();
        comment = JpegObj.getComment();
        length = comment.length();
        byte COM[] = new byte[length + 4];
        COM[0] = (byte) 0xFF;
        COM[1] = (byte) 0xFE;
        COM[2] = (byte) ((length >> 8) & 0xFF);
        COM[3] = (byte) (length & 0xFF);
        java.lang.System.arraycopy(JpegObj.Comment.getBytes(), 0, COM, 4, JpegObj.Comment.length());
        WriteArray(COM, out);

// The DQT header
// 0 is the luminance index and 1 is the chrominance index
        byte DQT[] = new byte[134];
        DQT[0] = (byte) 0xFF;
        DQT[1] = (byte) 0xDB;
        DQT[2] = (byte) 0x00;
        DQT[3] = (byte) 0x84;
        offset = 4;
        for (i = 0; i < 2; i++) {
                DQT[offset++] = (byte) ((0 << 4) + i);
                tempArray = dct.quantum[i];
                for (j = 0; j < 64; j++) {
                        DQT[offset++] = (byte) tempArray[jpegNaturalOrder[j]];
                }
        }
        WriteArray(DQT, out);

// Start of Frame Header
        byte SOF[] = new byte[19];
        SOF[0] = (byte) 0xFF;
        SOF[1] = (byte) 0xC0;
        SOF[2] = (byte) 0x00;
        SOF[3] = (byte) 17;
        SOF[4] = (byte) JpegObj.Precision;
        SOF[5] = (byte) ((JpegObj.imageHeight >> 8) & 0xFF);
        SOF[6] = (byte) ((JpegObj.imageHeight) & 0xFF);
        SOF[7] = (byte) ((JpegObj.imageWidth >> 8) & 0xFF);
        SOF[8] = (byte) ((JpegObj.imageWidth) & 0xFF);
        SOF[9] = (byte) JpegObj.NumberOfComponents;
        index = 10;
        for (i = 0; i < SOF[9]; i++) {
                SOF[index++] = (byte) JpegObj.CompID[i];
                SOF[index++] = (byte) ((JpegObj.HsampFactor[i] << 4) + JpegObj.VsampFactor[i]);
                SOF[index++] = (byte) JpegObj.QtableNumber[i];
        }
        WriteArray(SOF, out);

// The DHT Header
        byte DHT1[], DHT2[], DHT3[], DHT4[];
        int bytes, temp, oldindex, intermediateindex;
        length = 2;
        index = 4;
        oldindex = 4;
        DHT1 = new byte[17];
        DHT4 = new byte[4];
        DHT4[0] = (byte) 0xFF;
        DHT4[1] = (byte) 0xC4;
        for (i = 0; i < 4; i++ ) {
                bytes = 0;
                DHT1[index++ - oldindex] = (byte) ((int[]) Huf.bits.elementAt(i))[0];
                for (j = 1; j < 17; j++) {
                        temp = ((int[]) Huf.bits.elementAt(i))[j];
                        DHT1[index++ - oldindex] =(byte) temp;
                        bytes += temp;
                }
                intermediateindex = index;
                DHT2 = new byte[bytes];
                for (j = 0; j < bytes; j++) {
                        DHT2[index++ - intermediateindex] = (byte) ((int[]) Huf.val.elementAt(i))[j];
                }
                DHT3 = new byte[index];
                java.lang.System.arraycopy(DHT4, 0, DHT3, 0, oldindex);
                java.lang.System.arraycopy(DHT1, 0, DHT3, oldindex, 17);
                java.lang.System.arraycopy(DHT2, 0, DHT3, oldindex + 17, bytes);
                DHT4 = DHT3;
                oldindex = index;
        }
        DHT4[2] = (byte) (((index - 2) >> 8)& 0xFF);
        DHT4[3] = (byte) ((index -2) & 0xFF);
        WriteArray(DHT4, out);


// Start of Scan Header
        byte SOS[] = new byte[14];
        SOS[0] = (byte) 0xFF;
        SOS[1] = (byte) 0xDA;
        SOS[2] = (byte) 0x00;
        SOS[3] = (byte) 12;
        SOS[4] = (byte) JpegObj.NumberOfComponents;
        index = 5;
        for (i = 0; i < SOS[4]; i++) {
                SOS[index++] = (byte) JpegObj.CompID[i];
                SOS[index++] = (byte) ((JpegObj.DCtableNumber[i] << 4) + JpegObj.ACtableNumber[i]);
        }
        SOS[index++] = (byte) JpegObj.Ss;
        SOS[index++] = (byte) JpegObj.Se;
        SOS[index++] = (byte) ((JpegObj.Ah << 4) + JpegObj.Al);
        WriteArray(SOS, out);

    }

    void WriteMarker(byte[] data, BufferedOutputStream out) {
        try {
                out.write(data, 0, 2);
        } catch (IOException e) {
            //TODO
                System.out.println("IO Error: " + e.getMessage());
        }
    }

    void WriteArray(byte[] data, BufferedOutputStream out) {
        int length;
        try {
                length = ((data[2] & 0xFF) << 8) + (data[3] & 0xFF) + 2;
                out.write(data, 0, length);
        } catch (IOException e) {
            //TODO
                System.out.println("IO Error: " + e.getMessage());
        }
    }
}

// This class incorporates quality scaling as implemented in the JPEG-6a
// library.

 /*
 * DCT - A Java implementation of the Discreet Cosine Transform
 */

class DCT
{

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91美女蜜桃在线| 国产精一区二区三区| 欧美在线免费播放| 亚洲大片在线观看| 欧美一区二区成人| 国产乱码精品1区2区3区| 国产日韩欧美一区二区三区乱码 | 亚洲国产精品一区二区久久恐怖片 | 日本成人中文字幕| 精品国产免费人成在线观看| 国产精品一区在线观看乱码 | 2024国产精品| 99久久精品费精品国产一区二区| 一区二区三区在线免费播放| 欧美日韩高清一区二区不卡| 久久精品噜噜噜成人88aⅴ| 日本一区二区三区dvd视频在线 | 欧美日韩免费电影| 美女视频一区在线观看| 亚洲国产精品精华液ab| 色欧美片视频在线观看| 日本91福利区| 国产精品国产自产拍高清av王其| 欧美亚洲高清一区| 久久99深爱久久99精品| 中文字幕一区三区| 欧美精品在线视频| 粉嫩av一区二区三区| 亚洲电影一区二区| 国产三区在线成人av| 色av成人天堂桃色av| 久久不见久久见中文字幕免费| 成人免费在线播放视频| 91精品国产一区二区三区蜜臀| 国产91精品一区二区麻豆网站| 亚洲一区在线观看免费| 久久久综合精品| 欧美三区在线视频| 岛国一区二区三区| 青椒成人免费视频| 亚洲伦理在线精品| 欧美激情一区二区三区全黄| 欧美欧美午夜aⅴ在线观看| 高清shemale亚洲人妖| 青青草97国产精品免费观看无弹窗版| 国产精品国产三级国产普通话蜜臀 | 国产精品一区在线| 香蕉成人啪国产精品视频综合网 | 亚洲欧美日韩电影| 国产婷婷色一区二区三区在线| 欧美午夜在线观看| 99re视频这里只有精品| 精品一区二区精品| 日本最新不卡在线| 亚洲国产sm捆绑调教视频| 中文字幕在线观看不卡| 欧美va在线播放| 91麻豆精品91久久久久同性| 91在线porny国产在线看| 国产精品一二三四区| 美女视频网站久久| 天天影视涩香欲综合网| 亚洲精品免费在线播放| 18成人在线观看| 中文字幕亚洲一区二区av在线| 久久久久久亚洲综合影院红桃 | 精品久久久影院| 5858s免费视频成人| 色激情天天射综合网| 99久久综合狠狠综合久久| 国产成人av福利| 国产东北露脸精品视频| 国产乱人伦精品一区二区在线观看| 麻豆freexxxx性91精品| 看片的网站亚洲| 蜜桃精品视频在线观看| 日本视频一区二区三区| 免费观看久久久4p| 精品一区二区三区欧美| 久久国产三级精品| 国产综合一区二区| 国产乱码精品一区二区三区av| 国产麻豆一精品一av一免费| 国产一区二区三区久久久| 国产精品自拍三区| 成人午夜激情视频| av电影一区二区| 一本色道久久加勒比精品 | 91麻豆精品国产综合久久久久久| 欧美午夜宅男影院| 91精品麻豆日日躁夜夜躁| 日韩免费一区二区| 久久精品视频免费| 日本一二三不卡| 一区二区三区国产豹纹内裤在线| 亚洲第一搞黄网站| 久久99精品国产91久久来源| 国产真实乱子伦精品视频| 粉嫩av亚洲一区二区图片| 91日韩在线专区| 欧美巨大另类极品videosbest | www国产精品av| 国产精品视频观看| 亚洲地区一二三色| 老汉av免费一区二区三区| 成人免费的视频| 欧洲一区二区av| 日韩三级伦理片妻子的秘密按摩| 国产亚洲精品7777| 亚洲香蕉伊在人在线观| 激情综合五月婷婷| 99re成人精品视频| 欧美久久久一区| 国产精品午夜在线观看| 亚洲1区2区3区视频| 国产老肥熟一区二区三区| 色综合久久久久综合| 欧美va在线播放| 洋洋av久久久久久久一区| 国产美女精品在线| 欧美色手机在线观看| 国产亚洲欧美激情| 水野朝阳av一区二区三区| 成人少妇影院yyyy| 91精品欧美一区二区三区综合在 | 全部av―极品视觉盛宴亚洲| 国产成人综合在线观看| 在线看国产日韩| 中文字幕欧美国产| 裸体歌舞表演一区二区| 97成人超碰视| 久久久久国产一区二区三区四区 | 欧美做爰猛烈大尺度电影无法无天| 欧美一区二区网站| 一区二区国产视频| 成人午夜电影久久影院| 日韩欧美区一区二| 天堂蜜桃91精品| 色94色欧美sute亚洲线路一ni| 久久久精品国产99久久精品芒果| 日韩精品成人一区二区在线| 在线视频欧美精品| 国产精品二三区| 国产成人在线影院| 久久久久久久久久久久电影| 青青国产91久久久久久| 欧美区视频在线观看| 亚洲图片欧美视频| aaa国产一区| 国产欧美久久久精品影院| 久久99久久久欧美国产| 欧美日韩国产经典色站一区二区三区| 国产精品久久久99| 福利电影一区二区| 国产欧美一区二区精品性色| 精品一区二区精品| 日韩女优av电影在线观看| 日本不卡在线视频| 欧美情侣在线播放| 日韩国产欧美三级| 欧美日韩国产精选| 天涯成人国产亚洲精品一区av| 欧美日韩一级视频| 午夜精品久久久久久久99樱桃| 欧美中文一区二区三区| 亚洲一区电影777| 欧美性色黄大片手机版| 亚洲影院免费观看| 69堂国产成人免费视频| 青青草97国产精品免费观看无弹窗版| 在线播放91灌醉迷j高跟美女| 亚洲成人免费影院| 5858s免费视频成人| 蜜臀av性久久久久蜜臀aⅴ| 日韩精品一区二区三区中文精品| 美女诱惑一区二区| 欧美精品一区二区三区四区| 精品在线你懂的| 国产日韩欧美精品电影三级在线| 国产一区二区在线影院| 国产亚洲精品超碰| 99re8在线精品视频免费播放| 亚洲综合精品自拍| 欧美精品乱码久久久久久按摩| 蜜臀av一区二区在线观看| 精品av综合导航| 不卡的电视剧免费网站有什么| 中文字幕综合网| 在线观看国产精品网站| 日本中文字幕不卡| 国产亚洲va综合人人澡精品| www.日本不卡| 日日摸夜夜添夜夜添亚洲女人| 欧美成人一区二区三区| 成人一级片在线观看| 亚洲高清视频中文字幕| 精品精品欲导航| 91蜜桃传媒精品久久久一区二区| 亚洲国产另类av| 国产亚洲视频系列|