⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jpeginfo.java

📁 一个完整的
💻 JAVA
字号:
// Decompiled by DJ v2.9.9.60 Copyright 2000 Atanas Neshkov  Date: 2002-12-05 9:38:01
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   JpegEncoder.java

package cn.com.fcsoft.chart.jpeg;

import java.awt.AWTException;
import java.awt.Image;
import java.awt.image.PixelGrabber;

class JpegInfo
{

    public JpegInfo(Image image)
    {
        Precision = 8;
        NumberOfComponents = 3;
        lastColumnIsDummy = new boolean[3];
        lastRowIsDummy = new boolean[3];
        Ss = 0;
        Se = 63;
        Ah = 0;
        Al = 0;
        Components = new Object[NumberOfComponents];
        compWidth = new int[NumberOfComponents];
        compHeight = new int[NumberOfComponents];
        BlockWidth = new int[NumberOfComponents];
        BlockHeight = new int[NumberOfComponents];
        imageobj = image;
        imageWidth = image.getWidth(null);
        imageHeight = image.getHeight(null);
        Comment = "JPEG Encoder Copyright 1998, James R. Weeks and BioElectroMech.  ";
        getYCCArray();
    }

    public void setComment(String s)
    {
        Comment.concat(s);
    }

    public String getComment()
    {
        return Comment;
    }

    private void getYCCArray()
    {
        int ai[] = new int[imageWidth * imageHeight];
        PixelGrabber pixelgrabber = new PixelGrabber(imageobj.getSource(), 0, 0, imageWidth, imageHeight, ai, 0, imageWidth);
        MaxHsampFactor = 1;
        MaxVsampFactor = 1;
        for(int l = 0; l < NumberOfComponents; l++)
        {
            MaxHsampFactor = Math.max(MaxHsampFactor, HsampFactor[l]);
            MaxVsampFactor = Math.max(MaxVsampFactor, VsampFactor[l]);
        }

        for(int i1 = 0; i1 < NumberOfComponents; i1++)
        {
            compWidth[i1] = ((imageWidth % 8 == 0 ? imageWidth : (int)Math.ceil((double)imageWidth / 8D) * 8) / MaxHsampFactor) * HsampFactor[i1];
            if(compWidth[i1] != (imageWidth / MaxHsampFactor) * HsampFactor[i1])
                lastColumnIsDummy[i1] = true;
            BlockWidth[i1] = (int)Math.ceil((double)compWidth[i1] / 8D);
            compHeight[i1] = ((imageHeight % 8 == 0 ? imageHeight : (int)Math.ceil((double)imageHeight / 8D) * 8) / MaxVsampFactor) * VsampFactor[i1];
            if(compHeight[i1] != (imageHeight / MaxVsampFactor) * VsampFactor[i1])
                lastRowIsDummy[i1] = true;
            BlockHeight[i1] = (int)Math.ceil((double)compHeight[i1] / 8D);
        }

        try
        {
            if(!pixelgrabber.grabPixels())
                try
                {
                    throw new AWTException("Grabber returned false: " + pixelgrabber.status());
                }
                catch(Exception _ex) { }
        }
        catch(InterruptedException _ex) { }
        float af[][] = new float[compHeight[0]][compWidth[0]];
        float af1[][] = new float[compHeight[0]][compWidth[0]];
        float af2[][] = new float[compHeight[0]][compWidth[0]];
        float[][] _tmp = new float[compHeight[1]][compWidth[1]];
        float[][] _tmp1 = new float[compHeight[2]][compWidth[2]];
        int l1 = 0;
        for(int j1 = 0; j1 < imageHeight; j1++)
        {
            for(int k1 = 0; k1 < imageWidth; k1++)
            {
                int i = ai[l1] >> 16 & 0xff;
                int j = ai[l1] >> 8 & 0xff;
                int k = ai[l1] & 0xff;
                af[j1][k1] = (float)(0.29899999999999999D * (double)(float)i + 0.58699999999999997D * (double)(float)j + 0.114D * (double)(float)k);
                af2[j1][k1] = 128F + (float)((-0.16874D * (double)(float)i - 0.33126D * (double)(float)j) + 0.5D * (double)(float)k);
                af1[j1][k1] = 128F + (float)(0.5D * (double)(float)i - 0.41869000000000001D * (double)(float)j - 0.081309999999999993D * (double)(float)k);
                l1++;
            }

        }

        Components[0] = af;
        Components[1] = af2;
        Components[2] = af1;
    }

    float[][] DownSample(float af[][], int i)
    {
        int j = 0;
        int k = 0;
        float af1[][] = new float[compHeight[i]][compWidth[i]];
        for(int l = 0; l < compHeight[i]; l++)
        {
            int j1 = 1;
            for(int i1 = 0; i1 < compWidth[i]; i1++)
            {
                af1[l][i1] = (af[j][k++] + af[j++][k--] + af[j][k++] + af[j--][k++] + (float)j1) / 4F;
                j1 ^= 3;
            }

            j += 2;
            k = 0;
        }

        return af1;
    }

    String Comment;
    public Image imageobj;
    public int imageHeight;
    public int imageWidth;
    public int BlockWidth[];
    public int BlockHeight[];
    public int Precision;
    public int NumberOfComponents;
    public Object Components[];
    public int CompID[] = {
        1, 2, 3
    };
    public int HsampFactor[] = {
        1, 1, 1
    };
    public int VsampFactor[] = {
        1, 1, 1
    };
    public int QtableNumber[] = {
        0, 1, 1
    };
    public int DCtableNumber[] = {
        0, 1, 1
    };
    public int ACtableNumber[] = {
        0, 1, 1
    };
    public boolean lastColumnIsDummy[];
    public boolean lastRowIsDummy[];
    public int Ss;
    public int Se;
    public int Ah;
    public int Al;
    public int compWidth[];
    public int compHeight[];
    public int MaxHsampFactor;
    public int MaxVsampFactor;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -