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

📄 flipfilter.java

📁 Sony Ericsson手机上的Facebook客户端全套代码
💻 JAVA
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   FlipFilter.java

package se.southend.drops.pixelfilter;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import se.southend.drops.math.Matrix3D;
import se.southend.drops.scene.Node;

// Referenced classes of package se.southend.drops.pixelfilter:
//            Filter

public class FlipFilter
    implements Filter
{

    public FlipFilter()
    {
        this(null);
    }

    public FlipFilter(Image fromImage)
    {
        this(fromImage, null);
    }

    public FlipFilter(Image fromImage, Image toImage)
    {
        objectTransform = Matrix3D.create();
        worldTransform = Matrix3D.create();
        setImage(fromImage);
        setBackImage(toImage);
        setOutputRGB(new int[(fromImage.getWidth() + 10) * (fromImage.getHeight() + 2)], fromImage.getWidth() + 10, fromImage.getHeight() + 2);
        points = new int[8];
        vertices = new double[4][];
        vertices[0] = (new double[] {
            (double)(-srcWidth / 2), (double)(srcHeight / 2), 0.0D
        });
        vertices[1] = (new double[] {
            (double)(srcWidth / 2), (double)(srcHeight / 2), 0.0D
        });
        vertices[2] = (new double[] {
            (double)(-srcWidth / 2), (double)(-srcHeight / 2), 0.0D
        });
        vertices[3] = (new double[] {
            (double)(srcWidth / 2), (double)(-srcHeight / 2), 0.0D
        });
        for(int i = 0; i < vertices.length; i++)
        {
            vertices[i][0] += 0.5D;
            vertices[i][1] += 0.5D;
        }

        transformed = new double[8][3];
    }

    public Image getImage()
    {
        return Image.createRGBImage(getRGB(), getWidth(), getHeight(), true);
    }

    public void setImage(Image fromImage)
    {
        if(fromImage == null)
        {
            return;
        } else
        {
            int width = fromImage.getWidth();
            int height = fromImage.getHeight();
            int fromRGB[] = new int[width * height];
            fromImage.getRGB(fromRGB, 0, width, 0, 0, width, height);
            setRGB(fromRGB, width, height);
            return;
        }
    }

    public void setRGB(int fromRGB[], int width, int height)
    {
        this.fromRGB = fromRGB;
        srcWidth = width;
        srcHeight = height;
        needsRender = true;
    }

    public void setBackImage(Image toImage)
    {
        if(toImage == null)
        {
            return;
        } else
        {
            int width = toImage.getWidth();
            int height = toImage.getHeight();
            int toRGB[] = new int[width * height];
            toImage.getRGB(toRGB, 0, width, 0, 0, width, height);
            setBackRGB(toRGB);
            return;
        }
    }

    public void setBackRGB(int toRGB[])
    {
        this.toRGB = toRGB;
        needsRender = true;
    }

    public int[] getBackRGB()
    {
        return toRGB;
    }

    public int[] getRGB()
    {
        return rgb;
    }

    public int getWidth()
    {
        return width;
    }

    public int getHeight()
    {
        return height;
    }

    public void setOutputRGB(int outRGB[], int width, int height)
    {
        rgb = outRGB;
        this.width = width;
        this.height = height;
    }

    public void setOrientation(double x, double y, double z)
    {
        Matrix3D.identity(objectTransform);
        if(x != 0.0D)
            Matrix3D.rotateX(objectTransform, x);
        if(y != 0.0D)
            Matrix3D.rotateY(objectTransform, y);
        if(z != 0.0D)
            Matrix3D.rotateZ(objectTransform, z);
        needsRender = true;
    }

    private void setAngle(double theta)
    {
        if(this.theta != theta)
            this.theta = theta;
    }

    public void render()
    {
        for(int i = vertices.length - 1; i >= 0; i--)
            Matrix3D.copy(vertices[i], transformed[i]);

        for(int i = transformed.length - 1; i >= 0; i--)
            Matrix3D.transform(transformed[i], objectTransform);

        Matrix3D.identity(worldTransform);
        Matrix3D.translate(worldTransform, 0.0D, 0.0D, 300D);
        for(int i = transformed.length - 1; i >= 0; i--)
            Matrix3D.transform(transformed[i], worldTransform);

        for(int i = transformed.length - 1; i >= 0; i--)
        {
            double zVert = transformed[i][2];
            transformed[i][0] = (300D * transformed[i][0]) / zVert + (double)Node.SCREEN_HALF_WIDTH;
            transformed[i][1] = (300D * transformed[i][1]) / zVert + (double)Node.SCREEN_HALF_HEIGHT;
        }

        double theta = objectTransform[5];
        if(transformed[0][0] < transformed[1][0])
        {
            points[0] = (int)transformed[0][0];
            points[1] = (int)transformed[0][1];
            points[2] = (int)transformed[1][0];
            points[3] = (int)transformed[1][1];
            points[4] = (int)transformed[2][0];
            points[5] = (int)transformed[2][1];
            points[6] = (int)transformed[3][0];
            points[7] = (int)transformed[3][1];
            setAngle(theta);
            if(transformed[0][1] > transformed[2][1] || toRGB == null)
                renderPoly(fromRGB, srcWidth, srcHeight);
            else
                renderPoly(toRGB, srcWidth, srcHeight);
        }
        needsRender = false;
    }

    public void paintAt(Graphics graphics, int x, int y)
    {
        if(needsRender)
            render();
        graphics.drawRGB(rgb, 0, width, x, y, width, height, true);
    }

    public void renderPoly(int src[], int srcWidth, int srcHeight)
    {
        for(int i = rgb.length - 1; i > 0; i--)
            rgb[i] = 0;

        int toplft;
        int btmlft;
        if(points[1] < points[5])
        {
            toplft = 0;
            btmlft = 4;
        } else
        {
            toplft = 4;
            btmlft = 0;
        }
        int toprgt;
        int btmrgt;
        if(points[3] < points[7])
        {
            toprgt = 2;
            btmrgt = 6;
        } else
        {
            toprgt = 6;
            btmrgt = 2;
        }
        int xAdjust = -Node.SCREEN_WIDTH + width >> 1;
        int yAdjust = -Node.SCREEN_HEIGHT + height >> 1;
        points[0] += xAdjust;
        points[2] += xAdjust;
        points[4] += xAdjust;
        points[6] += xAdjust;
        points[1] += yAdjust;
        points[3] += yAdjust;
        points[5] += yAdjust;
        points[7] += yAdjust;
        int top = points[toplft + 1];
        int bottom = points[btmrgt + 1];
        int polygonHeight = bottom - top;
        if(polygonHeight <= 0)
            return;
        int dy = (srcHeight << 16) / polygonHeight;
        int ySrc = dy >> 1;
        int shade = 64 + (int)(192D * (theta >= 0.0D ? theta : -theta));
        for(int y = 0; y < polygonHeight; y++)
        {
            int progress = (y << 16) / polygonHeight;
            int xLeft = (points[toplft] << 16) + 32768 + (points[btmlft] - points[toplft]) * progress >> 16;
            int xRight = (points[toprgt] << 16) + 32768 + (points[btmrgt] - points[toprgt]) * progress >> 16;
            int scanlineWidth = xRight - xLeft;
            int dx = (srcWidth << 16) / scanlineWidth;
            int xSrc = dx >> 1;
            int y_width = (y + top) * width;
            int ySrcInteger_srcWidth = (ySrc >> 16) * srcWidth;
            for(int x = xLeft; x < xRight; x++)
            {
                int xSrcInteger = xSrc >> 16;
                int fg = src[xSrcInteger + ySrcInteger_srcWidth];
                int r = (fg >>> 16 & 0xff) * shade >>> 8;
                int g = (fg >>> 8 & 0xff) * shade >>> 8;
                int b = (fg & 0xff) * shade >>> 8;
                rgb[x + y_width] = fg & 0xff000000 | r << 16 | g << 8 | b;
                xSrc += dx;
            }

            ySrc += dy;
        }

    }

    protected int fromRGB[];
    protected int toRGB[];
    protected int rgb[];
    protected int width;
    protected int height;
    protected int srcWidth;
    protected int srcHeight;
    private int points[];
    protected double theta;
    private boolean needsRender;
    private double vertices[][];
    private double transformed[][];
    private double objectTransform[];
    private double worldTransform[];
}

⌨️ 快捷键说明

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