亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
国产成人av影院| 欧美老女人第四色| 欧美日韩日日摸| 精品福利av导航| 国产精品动漫网站| 久久精品国产第一区二区三区| 国产成人免费av在线| 欧美精选午夜久久久乱码6080| 国产女人水真多18毛片18精品视频| 亚洲6080在线| 色欧美乱欧美15图片| 久久久蜜桃精品| 蜜臂av日日欢夜夜爽一区| 91免费国产在线| 久久精品日产第一区二区三区高清版 | 免费在线观看视频一区| 波多野结衣精品在线| 欧美一级片免费看| 亚洲精品免费播放| 99九九99九九九视频精品| 久久精品视频网| 国产成人亚洲综合a∨婷婷 | 日韩 欧美一区二区三区| 99精品久久久久久| 国产精品丝袜91| 国产成人免费在线观看| 久久亚洲精华国产精华液| 日本女优在线视频一区二区 | 不卡电影免费在线播放一区| 日韩精品中文字幕一区二区三区 | 国产精品2024| 欧美精品一区二区三区一线天视频| 亚洲国产精品综合小说图片区| 99久久久国产精品免费蜜臀| 中文字幕av不卡| caoporn国产一区二区| 国产精品沙发午睡系列990531| 粉嫩蜜臀av国产精品网站| 久久综合给合久久狠狠狠97色69| 久久99久久久久久久久久久| 69精品人人人人| 热久久国产精品| 欧美精品一区视频| 国产大陆a不卡| 亚洲欧洲精品一区二区三区| 99久久精品国产毛片| 中文字幕免费观看一区| 播五月开心婷婷综合| 亚洲欧美一区二区三区孕妇| 91豆麻精品91久久久久久| 亚洲成人免费在线观看| 欧美另类一区二区三区| 麻豆国产精品一区二区三区| 久久色视频免费观看| 成人av资源在线| 亚洲国产成人高清精品| 日韩一区二区在线看| 国产精品888| 日韩伦理电影网| 在线播放一区二区三区| 极品少妇xxxx偷拍精品少妇| 国产午夜精品一区二区 | 久久成人免费日本黄色| 国产亚洲一区字幕| 色激情天天射综合网| 日韩精品欧美成人高清一区二区| 精品成人免费观看| 91色视频在线| 久久精品久久99精品久久| 中文幕一区二区三区久久蜜桃| 在线观看日韩毛片| 国产一区二区三区蝌蚪| 亚洲免费av高清| 精品人伦一区二区色婷婷| 国产成人免费在线观看| 日韩高清一级片| 日本一区二区三区免费乱视频 | 欧美日韩精品久久久| 美女在线一区二区| 最新欧美精品一区二区三区| 欧美久久免费观看| 97久久超碰精品国产| 精品一二线国产| 夜夜亚洲天天久久| 精品久久久久久久久久久院品网| av不卡一区二区三区| 男人的j进女人的j一区| 亚洲精品国产a久久久久久| 精品久久久久久久人人人人传媒| 欧洲另类一二三四区| 国产福利精品一区二区| 喷水一区二区三区| 亚洲一区二区三区国产| 中文字幕亚洲在| 久久综合中文字幕| 9191精品国产综合久久久久久| 国产a区久久久| 日韩一区精品字幕| 亚洲成人资源网| 中文字幕日韩精品一区| 欧美mv和日韩mv国产网站| 国产99一区视频免费| 国产精品久久久久久久久搜平片| 6080午夜不卡| 在线观看91视频| 成人av午夜电影| 国产不卡视频在线播放| 久久成人免费电影| 久草这里只有精品视频| 午夜久久久久久| 亚洲五码中文字幕| 亚洲图片自拍偷拍| 亚洲成人av电影在线| 亚洲欧美日韩国产一区二区三区| 国产精品成人一区二区三区夜夜夜| 国产亚洲欧美一区在线观看| 日韩午夜电影av| 欧美日韩国产系列| 8x8x8国产精品| 91精品久久久久久蜜臀| 欧美日韩成人激情| 56国语精品自产拍在线观看| 欧美丰满一区二区免费视频| 欧美美女bb生活片| 欧美不卡一区二区| 久久综合999| 国产精品女主播在线观看| 国产精品久久久久久久第一福利| 国产精品国产三级国产三级人妇| 中文字幕第一区| 亚洲欧美综合色| 夜夜精品浪潮av一区二区三区| 国产色爱av资源综合区| 中文字幕乱码亚洲精品一区| 亚洲三级在线观看| 亚洲va在线va天堂| 九色综合狠狠综合久久| 国产专区综合网| 91色九色蝌蚪| 欧美一卡二卡在线观看| 亚洲精品一区二区三区影院 | 久久免费偷拍视频| 国产农村妇女毛片精品久久麻豆| 亚洲国产精品成人综合色在线婷婷| 久久久久久免费毛片精品| 国产精品无遮挡| 亚洲国产精品一区二区久久 | 国产v日产∨综合v精品视频| 成人免费看的视频| 欧美日韩精品电影| 欧美一区二区黄| 中文字幕一区二区视频| 亚欧色一区w666天堂| 国产一区二区导航在线播放| 91麻豆视频网站| 日韩美女视频在线| 亚洲视频精选在线| 麻豆一区二区三区| 色婷婷激情一区二区三区| 日韩一区二区在线观看视频播放| 国产精品麻豆网站| 日韩 欧美一区二区三区| 99精品热视频| 欧美精品一区二区三区一线天视频 | 欧美成人高清电影在线| 国产欧美一区二区精品性色超碰| 亚洲一区二区三区美女| 国产不卡视频一区| 欧美一级日韩免费不卡| 亚洲卡通欧美制服中文| 黄色资源网久久资源365| 欧美三级韩国三级日本三斤| 国产亚洲精品超碰| 日本欧美一区二区三区乱码| 不卡的电视剧免费网站有什么| 91精品国产色综合久久不卡电影 | 午夜欧美在线一二页| 国产成都精品91一区二区三| 日韩欧美一区中文| 三级欧美在线一区| 在线精品视频免费观看| 国产欧美一区二区在线| 极品少妇xxxx精品少妇| 欧美熟乱第一页| 亚洲男女毛片无遮挡| 99久久综合精品| 中文字幕国产一区| 成人在线一区二区三区| 欧美成人欧美edvon| 五月激情综合色| 欧美日韩中文精品| 亚洲午夜一区二区| 欧美三级在线看| 亚洲国产精品尤物yw在线观看| 91久久精品一区二区| 亚洲女子a中天字幕| 成人av免费观看| 国产精品网站在线播放| 成人听书哪个软件好| 国产精品动漫网站|