我希望你能给我一些建议来解决我的问题。 我需要覆盖按钮上的许多图像。但问题是,这是基本图像(牙齿):(http://i.imgur.com/7tIcP.gif)java中覆盖图像
我的第一个图像是这个: http://i.imgur.com/FYuD8.gif 然后我把这个: http://i.imgur.com/mWz9c.gif 第一图像重叠的第二所以我就只能看到第二图像...
也许你会告诉我,一个选项是改变图像的顺序覆盖前,但用户将选择什么是第一个,也许只是想要第一个图像,但在其他情况下,用户会把第一个,然后第二个,反之亦然...
我的代码是这样的:
BufferedImage large=null;
large = ImageIO.read(new File("firstimage.gif"));
BufferedImage small=null;
small = ImageIO.read(new File("secondimage.gif"));
int w = Math.max(large.getWidth(), small.getWidth());
int h = Math.max(large.getHeight(), small.getHeight());
BufferedImage combined = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
// paint both images, preserving the alpha channels
Graphics g = combined.getGraphics();
g.drawImage(large, 0, 0, null);
g.drawImage(small, 0, 0, null);
ImageIO.write(combined, "PNG", new File("twoInOne.png"));
ImageIcon icon1 = new ImageIcon(combined);
jbutton1.setIcon(icon1);
也许是图像的问题,或者我的代码的格式,但我更希望你们能帮助我解决这个问题谢谢。
现在我上传了3张图片:我跳过基本图片(牙齿),因为我不认为它会是那里的问题。
为什么代码状态GIF而这两个图像都是JPG? –
当用户同时需要时,*应该发生什么?它应该是什么样子? –
Freezerburn了解目标...第一个图像需要覆盖第二个图像,而不会覆盖第一个图像... –