开发者

how to make transparent image in j2me

开发者 https://www.devze.com 2023-01-05 14:09 出处:网络
anybody know, how to make transparent image with full opaque image background?? help me plea开发者_如何学Gose...here it is

anybody know, how to make transparent image with full opaque image background??

help me plea开发者_如何学Gose...


here it is

Image transPNG=Image.createImage("/trans.png");  //load the tranparent image or opaque image
int rgbData[];
transPNG.getRGB(rgbData, 0,transPNG.getWidth(), 0, 0,transPNG.getWidth(), transPNG.getHeight());
Image tranparentImage==Image.createRGBImage(rgbData, width, height, true); //process alpha (true) for opaque false
transPNG=null;

hope it helps


I think this will be your solution!!!

Image image, semi;

public Design() {
    try {

        image = Image.createImage("asc.png");
        int w = image.getWidth();
        int h = image.getHeight();
        int rgb[] = new int[w * h];

        for (int i = 0; i < w * h; i++) {
            rgb[i] = 0x50999999;
        }

        semi = Image.createRGBImage(rgb, w, h, true);


    } catch (IOException ex) {
        ex.printStackTrace();
    }
}

protected void paint(Graphics g) {
        g.setGrayScale(255);
        g.setColor(0xFF0000);
        g.fillRect(0, 0, getWidth(), getHeight());
        g.drawImage(image, 50, 150, Graphics.TOP|Graphics.LEFT);
        g.drawImage(semi, 60, 160, Graphics.BOTTOM|Graphics.LEFT);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消