Java ByteBuffer Size makeBrighterRectangleOnImage(BufferedImage image, int leftPosition, int topPosition, int width, int height, double scaleFactor, Color borderColor, Stroke borderStroke)

Here you can find the source of makeBrighterRectangleOnImage(BufferedImage image, int leftPosition, int topPosition, int width, int height, double scaleFactor, Color borderColor, Stroke borderStroke)

Description

make Brighter Rectangle On Image

License

Open Source License

Declaration

static public void makeBrighterRectangleOnImage(BufferedImage image, int leftPosition, int topPosition,
            int width, int height, double scaleFactor, Color borderColor, Stroke borderStroke) 

Method Source Code


//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();
    }
}

Related

  1. erodeImage(final BufferedImage img, int structElementWidth, int structElementHeight, final int rgbForegroundColor, final int rgbBackgroundColor)
  2. findNewHeight(BufferedImage origImage, double newWidth)
  3. FindResolution(BufferedImage img, double print_width, double print_height)
  4. fitToSize(BufferedImage source, int targetWidth, int targetHeight)
  5. generateScaledImage(final BufferedImage bufImg, @SuppressWarnings("unused") final Object hintsArg, final int size)
  6. makeOval(BufferedImage input, int width, int height)
  7. makeTarget(BufferedImage image, int x, int y, int width, int height)
  8. mapByteBuffer(File cachedFile, int cacheFileSize)
  9. markDifferencesWithAMarker(final BufferedImage image, final Point[] pixels, final int markingSizeX, final int markingSizeY)