draw Borders BufferedImage - Java 2D Graphics

Java examples for 2D Graphics:BufferedImage Paint

Description

draw Borders BufferedImage

Demo Code


//package com.java2s;
import java.awt.Color;
import java.awt.image.BufferedImage;

public class Main {
    public static void drawBorders(BufferedImage imageBorders,
            int[][] differentialIntMatrix, int width, int height,
            int threshold, Color borderColor) {
        for (int i = 0; i < width - 1; i++) {
            for (int j = 0; j < height - 1; j++) {

                boolean isBorder = differentialIntMatrix[i][j] > threshold ? true
                        : false;/*from   w w  w  .  j av a 2s . com*/
                if (isBorder) {
                    //System.out.println("\nBlue: "+borderColor.getBlue()+"\nGreen: "+borderColor.getGreen()+"\nRed: "+borderColor.getRed()+"\n");
                    imageBorders.setRGB(i, j, imageBorders.getRGB(i, j)
                            + borderColor.getRGB());
                }

            }
        }

    }
}

Related Tutorials