Java BufferedImage Merge mergeImage(BufferedImage origImage, Vector fadedImages)

Here you can find the source of mergeImage(BufferedImage origImage, Vector fadedImages)

Description

merge Image

License

Apache License

Declaration

public static BufferedImage mergeImage(BufferedImage origImage, Vector<BufferedImage> fadedImages) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.awt.Graphics;
import java.awt.Graphics2D;

import java.awt.image.BufferedImage;

import java.util.Vector;

public class Main {
    static int COLORTYPE = BufferedImage.TYPE_INT_ARGB;

    public static BufferedImage mergeImage(BufferedImage origImage, Vector<BufferedImage> fadedImages) {
        int ht = origImage.getHeight(), wd = origImage.getWidth();
        BufferedImage fadeImg = new BufferedImage(wd, ht, COLORTYPE), clipFadeImg = null;
        Graphics g = fadeImg.createGraphics();
        for (int i = 0; i < fadedImages.size(); i++) {
            clipFadeImg = fadedImages.elementAt(i);
            g.drawImage(clipFadeImg, 0, 0, wd, ht, null);
        }//from w w  w  .  java2s  .com
        g.dispose();
        // displayImage(fadeImg, "FadeImage");
        return fadeImg;
    }

    public static void drawImage(BufferedImage srcImg, BufferedImage img2Draw, int w, int h) {
        if (w == -1)
            w = (int) (srcImg.getWidth() / 2);
        if (h == -1)
            h = (int) (srcImg.getHeight() / 2);
        System.out.println("AWT Image Wt: " + w + " And Ht: " + h);
        Graphics2D g2 = srcImg.createGraphics();
        g2.drawImage(img2Draw, w, h, null);
        g2.dispose();
    }
}

Related

  1. mergeImage(BufferedImage a, BufferedImage b)
  2. mergeImages(List images, int space, Color bg)