Java Draw Image drawBorder(BufferedImage originalImage, Color borderColor, int borderWidth)

Here you can find the source of drawBorder(BufferedImage originalImage, Color borderColor, int borderWidth)

Description

draw Border

License

Open Source License

Declaration

public static BufferedImage drawBorder(BufferedImage originalImage, Color borderColor, int borderWidth) 

Method Source Code

//package com.java2s;
/** This file is part of Approach Avoidance Task.
 *
 * Approach Avoidance Task is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version./*w  w w  .jav a2s.c om*/
 *
 * Approach Avoidance Task is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Approach Avoidance Task.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

import java.awt.*;
import java.awt.image.BufferedImage;

public class Main {
    public static BufferedImage drawBorder(BufferedImage originalImage, Color borderColor, int borderWidth) {
        BufferedImage bi = new BufferedImage(originalImage.getWidth() + (2 * borderWidth),
                originalImage.getHeight() + (2 * borderWidth), BufferedImage.TYPE_INT_ARGB);
        Graphics2D g = bi.createGraphics();
        g.setColor(borderColor);
        g.drawImage(originalImage, borderWidth, borderWidth, null);
        BasicStroke stroke = new BasicStroke(borderWidth * 2);
        g.setStroke(stroke);
        g.drawRect(0, 0, bi.getWidth(), bi.getHeight());
        g.dispose();
        return bi;
    }
}

Related

  1. draw(BufferedImage image, Rectangle rectangle, BufferedImage backgroundImg)
  2. draw(final Image img, final int type)
  3. draw4on1(BufferedImage[] src, BufferedImage dst)
  4. draw9Patch(BufferedImage image, Integer[] patches, float ratio)
  5. drawBorder(BufferedImage buffImage)
  6. drawBorders(final BufferedImage image, final int currentX, final int currentY, final int width, final int height, final int subImageWidth, final int subImageHeight, final Color c)
  7. drawBoundingPolygon(BufferedImage canvas, Polygon p, Color fgColour)
  8. drawBubble(BufferedImage img, Graphics g, Component component)
  9. drawBytes(BufferedImage image, byte[] buf)