So, I'm trying to create an application that can clip polling sections containing sensitive information. However, I ran into some problem.
What I want to do is draw the filled black rectangles above the BufferedImage given x, y, width and height of the desired area to darken, and then write this new image back to my file system. Here is my code.
File imageFile = new File("images/template.jpg"); BufferedImage img = ImageIO.read(imageFile); Graphics2D graph = img.createGraphics(); graph.setColor(Color.BLACK); graph.fill(new Rectangle(x, y, width, height)); graph.dispose(); ImageIO.write(img, "jpg", new File("images/template.jpg"));
For any reason, the image in the resource does not change after this code segment. Any ideas on what I'm doing wrong?
java bufferedimage graphics2d
John fox
source share