1

I am trying to make an image editing software for my final semester project. I am stucked in finding out the method on how to duplicate or clone an Image. I have been looking for the algorithms used.. I searched the internet, also gone through few computer graphics books but could not get through.

Robert Harvey
  • 173,679
  • 45
  • 326
  • 490
Fulu
  • 23
  • 4

1 Answers1

0

You can try something like this:

public class ImageDuplicateHelper {

    public BufferedImage duplicate(BufferedImage bi) {
       ColorModel cm = bi.getColorModel();
       boolean isAlphaPremultiplied = cm.isAlphaPremultiplied();
       WritableRaster raster = bi.copyData(null);
       return new BufferedImage(cm, raster, isAlphaPremultiplied, null);
    }
}

// ...

BufferedImage img = ImageIO.read(...);
BufferedImage duplicatedImg = duplicate(img);
Stephan
  • 40,082
  • 60
  • 228
  • 319