Here you can find the source of makeBrighterRectangleOnImage(BufferedImage image, int leftPosition, int topPosition, int width, int height, double scaleFactor, Color borderColor, Stroke borderStroke)
static public void makeBrighterRectangleOnImage(BufferedImage image, int leftPosition, int topPosition, int width, int height, double scaleFactor, Color borderColor, Stroke borderStroke)
//package com.java2s; //License from project: Open Source License import java.awt.*; import java.awt.geom.RoundRectangle2D; import java.awt.image.BufferedImage; public class Main { static public void makeBrighterRectangleOnImage(BufferedImage image, int leftPosition, int topPosition, int width, int height, double scaleFactor, Color borderColor, Stroke borderStroke) { double invertedScaleFactor = 1. / scaleFactor; int scaledLeftPosition = (int) (invertedScaleFactor * leftPosition); int scaledTopPosition = (int) (invertedScaleFactor * topPosition); int scaledWidth = (int) (invertedScaleFactor * width); int scaledHeight = (int) (invertedScaleFactor * height); for (int iw = scaledLeftPosition; iw < scaledLeftPosition + scaledWidth; ++iw) { for (int ih = scaledTopPosition; ih < scaledTopPosition + scaledHeight; ++ih) { Color color = new Color(image.getRGB(iw, ih)); image.setRGB(iw, ih, new Color(Math.min(color.getRed() + 64, 255), Math.min(color.getGreen() + 64, 255), Math.min(color.getBlue() + 64, 255)).getRGB()); }//ww w . ja v a2s. c o m } Graphics2D graph = image.createGraphics(); Stroke oldStroke = graph.getStroke(); graph.setStroke(borderStroke); // graph.setColor(Color.BLACK); // graph.setColor(new Color(0, 240, 0)); graph.setColor(borderColor); Shape shape = new RoundRectangle2D.Double(scaledLeftPosition, scaledTopPosition, scaledWidth, scaledHeight, Math.min(scaledWidth / 3., 5.), Math.min(scaledHeight / 3., 5.)); graph.draw(shape); graph.setStroke(oldStroke); graph.dispose(); } }