0

可能重复:
是否有用于隐写术的 Java 库?

public void  myfunction()
{
  try
  {

   BufferedImage image = ImageIO.read(new File("first.jpg"));//first image
   BufferedImage overlay = ImageIO.read(new File("second.jpg"));//second image

   int w = Math.max(image.getWidth(), overlay.getWidth());
   int h = Math.max(image.getHeight(), overlay.getHeight());
   BufferedImage combined = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);

   Graphics g = combined.getGraphics();
   g.drawImage(image, 0, 0, null);
   g.drawImage(overlay, 0, 0, null);

   //here i combined 2 images in combined.jpg
   ImageIO.write(combined, "jpg", new File("DestinationPath", "combined.jpg"));//combined image

  } 
 catch (Exception e) 
 {
 e.printStackTrace();
 }
}

//我想把这个 combine.jpg 提取到我之前的 first.jpg 和 second.jpg 中?// 如何提取我与此代码组合的 2 个图像?

4

1 回答 1

0

绘制第一张图像后,您可以在绘制叠加层时设置一些透明度。

float alpha = 0.75f;
int type = AlphaComposite.SRC_OVER; 
AlphaComposite composite = AlphaComposite.getInstance(type, alpha);
g.setComposite(composite);
于 2013-01-07T12:44:58.140 回答