任何人都知道,如何使用完全不透明的图像背景制作透明图像?
请帮助我......答案 0 :(得分:0)
这里是
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;
希望有所帮助
答案 1 :(得分:0)
我认为这将是您的解决方案!
图像,半;
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);
}