0

我想将几张图像合成在一起。每个图像都有一些透明度。我正在尝试为此使用 BufferedImage 但似乎没有任何方法可以为此目的使用它?

我们只得到 BufferedImage.setRGB() 方法。相反,我需要透明像素不会覆盖它们下面的像素值的东西。我该怎么做呢?

谢谢

4

1 回答 1

0
/* imageType should be one of the variants that includes alpha  */
final BufferedImage composited = new BufferedImage(width, height, imageType);
final Graphics graphics = composited.getGraphics();
for (final Image layer : layers) {
  /* draw the image at 0,0 */
  graphics.drawImage(layer, 0, 0, null);
}
graphics.dispose();
于 2012-08-30T22:30:23.830 回答