Java BufferedImage Operation findDifference(BufferedImage img2, BufferedImage img1)

Here you can find the source of findDifference(BufferedImage img2, BufferedImage img1)

Description

find Difference

License

Open Source License

Declaration

public static BufferedImage findDifference(BufferedImage img2, BufferedImage img1) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.Color;

import java.awt.Graphics2D;

import java.awt.image.BufferedImage;

import java.awt.image.Raster;

public class Main {
    public static BufferedImage findDifference(BufferedImage img2, BufferedImage img1) {
        BufferedImage img = new BufferedImage(img2.getWidth(), img2.getHeight(), img2.getType());
        Graphics2D g2d = img.createGraphics();
        Raster data = img.getData();
        for (int x = data.getMinX(); x < data.getWidth(); x++) {
            for (int y = data.getMinY(); y < data.getHeight(); y++) {
                if ((img2.getRGB(x, y) >> 24) == 0x00 && (img1.getRGB(x, y) >> 24) != 0x00) {
                    g2d.setColor(new Color(img1.getRGB(x, y)));
                    g2d.drawRect(x, y, 1, 1);
                }/*w w  w. j ava2 s .co  m*/
            }
        }
        g2d.dispose();
        return img;
    }
}

Related

  1. fadeImageByShape(BufferedImage bimg, Shape arbshape, double alpha, int rule)
  2. fadeImages(BufferedImage source1, BufferedImage source2, BufferedImage target, int relX, int targetX)
  3. fakeAOI(final BufferedImage pImage, final Rectangle pSourceRegion)
  4. findavg(BufferedImage bimg)
  5. findColor(BufferedImage image, int startX, int startY, int dirX, int dirY, int colorIndex)
  6. findDominantColor(BufferedImage paramBufferedImage)
  7. findLegacyColorModel(BufferedImage image)
  8. findLegendLH(BufferedImage bufferedImage)
  9. findTranslation(AffineTransform at, BufferedImage bi)