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

📄 alphafilter.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:   AlphaFilter.java

package se.southend.drops.pixelfilter;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

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

public class AlphaFilter
    implements Filter
{

    public AlphaFilter()
    {
    }

    public AlphaFilter(Image rgbImage)
    {
        setImage(rgbImage);
    }

    public AlphaFilter(Image rgbImage, Image alphaImage)
    {
        setImage(rgbImage);
        setAlphaImage(alphaImage);
    }

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

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

    public int getWidth()
    {
        return width;
    }

    public int getHeight()
    {
        return height;
    }

    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;
        this.width = width;
        this.height = height;
        rgb = new int[width * height];
        needsRender = true;
    }

    public void setAlphaImage(Image alphaImage)
    {
        if(alphaImage == null)
            return;
        int width = alphaImage.getWidth();
        int height = alphaImage.getHeight();
        int fromAlpha[] = new int[width * height];
        alphaImage.getRGB(fromAlpha, 0, width, 0, 0, width, height);
        for(int i = 0; i < fromAlpha.length; i++)
            fromAlpha[i] <<= 24;

        setAlphaRGB(fromAlpha);
    }

    public void setAlphaRGB(int alphaRGB[])
    {
        fromAlpha = alphaRGB;
        needsRender = true;
    }

    public void render()
    {
        if(!needsRender)
        {
            return;
        } else
        {
            rgb = applyAlpha(fromRGB, fromAlpha, rgb);
            needsRender = false;
            return;
        }
    }

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

    public static final int[] applyAlpha(int src[], int alpha[], int dest[])
    {
        for(int i = 0; i < src.length; i++)
            dest[i] = src[i] & 0xffffff | alpha[i];

        return dest;
    }

    protected int fromRGB[];
    protected int fromAlpha[];
    protected int rgb[];
    protected int width;
    protected int height;
    private boolean needsRender;
}

⌨️ 快捷键说明

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