Sorry, This may be a redundant post, but I had not yet subscribed to the group when I sent my previous post, so I am resending. See below -thx
Hello,
I have written a method to take two images and overlay them on top of one
another; this works great. However, I am being asked if I can cause one
of the images to appear darker. Not sure how to accomplish this. Below is
my current logic:
private byte[] overlayImages(InputStream iis, InputStream iis2, int fmt,
boolean convertJPEG) throws Exception {
BufferedImage im = ImageIO.read(iis);
BufferedImage im2 = ImageIO.read(iis2);
Graphics2D g = im.createGraphics();
g.setComposite(AlphaComposite
.getInstance(AlphaComposite.SRC_OVER, 0.4f));
g.drawImage(im2, (im.getWidth() - im2.getWidth()) / 2,
(im.getHeight() - im2.getHeight()) / 2, null);
g.dispose();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(im, getFormatName(fmt), baos);
return baos.toByteArray();
}
I have written a method to take two images and overlay them on top of one
another; this works great. However, I am being asked if I can cause one
of the images to appear darker. Not sure how to accomplish this. Below is
my current logic:
private byte[] overlayImages(InputStream iis, InputStream iis2, int fmt,
boolean convertJPEG) throws Exception {
BufferedImage im = ImageIO.read(iis);
BufferedImage im2 = ImageIO.read(iis2);
Graphics2D g = im.createGraphics();
g.setComposite(AlphaComposite
.getInstance(AlphaComposite.SRC_OVER, 0.4f));
g.drawImage(im2, (im.getWidth() - im2.getWidth()) / 2,
(im.getHeight() - im2.getHeight()) / 2, null);
g.dispose();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(im, getFormatName(fmt), baos);
return baos.toByteArray();
}
