1

I want to blend two images together with a ratio of 4:1

the result should be something like this

enter image description here

So any ideas ? Thanks in advance

Hacker inside
  • 39
  • 1
  • 9
  • What have you tried so far? Can you post some of your code? You will get a faster answer if you ask about the specific part where you have a problem. – metacubed Nov 04 '14 at 23:12
  • well i dont know from where i start all i have done is to load both image :D – Hacker inside Nov 04 '14 at 23:17

1 Answers1

7

The question is vague, but you could use the 2D Graphics API

Take a look at 2D Graphics and Compositing Graphics in particular...

So using the following images (base on left, overlay on right)

BaseOverlay

try {
    BufferedImage base = ImageIO.read(new File("base.jpg"));
    BufferedImage overlay = ImageIO.read(new File("overlay.jpg"));

    Graphics2D g2d = base.createGraphics();
    g2d.setComposite(AlphaComposite.SrcOver.derive(0.5f));
    int x = (base.getWidth() - overlay.getWidth()) / 2;
    int y = (base.getHeight() - overlay.getHeight()) / 2;
    g2d.drawImage(overlay, x, y, null);
    g2d.dispose();

    ImageIO.write(base, "jpg", new File("Blended.jpg"));
} catch (IOException e) {
    e.printStackTrace();
}

Resulting in...

Blending

Take a look at...

for more details...

MadProgrammer
  • 343,457
  • 22
  • 230
  • 366