Here you can find the source of bordersNonTransparentPixel(BufferedImage data, int wid, int hei, boolean[] traced, int x, int y)
protected static boolean bordersNonTransparentPixel(BufferedImage data, int wid, int hei, boolean[] traced, int x, int y)
//package com.java2s; // under the terms of the GNU Lesser General Public License as published import java.awt.image.BufferedImage; public class Main { /** Used when seeking fully transparent pixels for outlining. */ protected static final int TRANS_MASK = (0xFF << 24); /**/*from w w w .j a va 2 s. c o m*/ * Returns whether the given pixel is bordered by any non-transparent * pixel. */ protected static boolean bordersNonTransparentPixel(BufferedImage data, int wid, int hei, boolean[] traced, int x, int y) { // check the three-pixel row above the pixel if (y > 0) { for (int rxx = x - 1; rxx <= x + 1; rxx++) { if (rxx < 0 || rxx >= wid || traced[((y - 1) * wid) + rxx]) { continue; } if ((data.getRGB(rxx, y - 1) & TRANS_MASK) != 0) { return true; } } } // check the pixel to the left if (x > 0 && !traced[(y * wid) + (x - 1)]) { if ((data.getRGB(x - 1, y) & TRANS_MASK) != 0) { return true; } } // check the pixel to the right if (x < wid - 1 && !traced[(y * wid) + (x + 1)]) { if ((data.getRGB(x + 1, y) & TRANS_MASK) != 0) { return true; } } // check the three-pixel row below the pixel if (y < hei - 1) { for (int rxx = x - 1; rxx <= x + 1; rxx++) { if (rxx < 0 || rxx >= wid || traced[((y + 1) * wid) + rxx]) { continue; } if ((data.getRGB(rxx, y + 1) & TRANS_MASK) != 0) { return true; } } } return false; } }