List of utility methods to do BufferedImage Operation
BufferedImage | fadeImageByShape(BufferedImage bimg, Shape arbshape, double alpha, int rule) fade Image By Shape int ht = bimg.getHeight(), wd = bimg.getWidth(); BufferedImage bimgnew = new BufferedImage(wd, ht, COLORTYPE); Graphics2D g2d = (Graphics2D) bimgnew.createGraphics(); if (arbshape != null) g2d.setClip(arbshape); AlphaComposite ac = AlphaComposite.getInstance(rule, (float) alpha); g2d.setComposite(ac); g2d.drawImage(bimg, 0, 0, null); ... |
void | fadeImages(BufferedImage source1, BufferedImage source2, BufferedImage target, int relX, int targetX) fade Images int pixel1, pixel2, newPixel; double f; int r1, g1, b1, r2, g2, b2; byte newR, newG, newB; ColorModel cm = source1.getColorModel(); for (int x = relX; x < source1.getWidth(); x++) { f = linearF(x, relX, source1.getWidth()); for (int y = 0; y < source1.getHeight(); y++) { ... |
BufferedImage | fakeAOI(final BufferedImage pImage, final Rectangle pSourceRegion) fake AOI if (pImage == null) { return null; if (pSourceRegion != null) { if (pSourceRegion.x != 0 || pSourceRegion.y != 0 || pSourceRegion.width != pImage.getWidth() || pSourceRegion.height != pImage.getHeight()) { return pImage.getSubimage(pSourceRegion.x, pSourceRegion.y, pSourceRegion.width, pSourceRegion.height); ... |
double | findavg(BufferedImage bimg) findavg double avg = 0; int avgarry[] = { 0, 32, 64, 128, 160, 192, 224, 255 }; int max = 0; int maxCols = bimg.getWidth(); int maxRows = bimg.getHeight(); int[][][] pixel_rgb = BufferedImagetoPixel3DRGB(bimg); for (int row = 0; row < maxRows; row++) { for (int col = 0; col < maxCols; col++) { ... |
Point | findColor(BufferedImage image, int startX, int startY, int dirX, int dirY, int colorIndex) find Color int curX = startX; int curY = startY; int[] pixel = new int[1]; Raster r = image.getRaster(); do { r.getPixel(curX, curY, pixel); if (pixel[0] == colorIndex) { return new Point(curX, curY); ... |
BufferedImage | findDifference(BufferedImage img2, BufferedImage img1) find Difference BufferedImage img = new BufferedImage(img2.getWidth(), img2.getHeight(), img2.getType()); Graphics2D g2d = img.createGraphics(); Raster data = img.getData(); for (int x = data.getMinX(); x < data.getWidth(); x++) { for (int y = data.getMinY(); y < data.getHeight(); y++) { if ((img2.getRGB(x, y) >> 24) == 0x00 && (img1.getRGB(x, y) >> 24) != 0x00) { g2d.setColor(new Color(img1.getRGB(x, y))); g2d.drawRect(x, y, 1, 1); ... |
Color | findDominantColor(BufferedImage paramBufferedImage) find Dominant Color return findDominantColor(paramBufferedImage, false, -1);
|
ColorModel | findLegacyColorModel(BufferedImage image) find Legacy Color Model ColorModel sourceColorModel = image.getColorModel(); boolean inColor = (sourceColorModel.getColorSpace().getType() != ColorSpace.TYPE_GRAY); boolean hasAlpha = sourceColorModel.hasAlpha(); if (inColor) { if (hasAlpha) { return COLOR_MODEL_RGBA; } else { return COLOR_MODEL_RGB; ... |
int[] | findLegendLH(BufferedImage bufferedImage) This find the low and high pixels with the legend (assuming the legend is near the bottom and is along the left edge, and spans the width of the image). int black = 0xFF000000; int height = bufferedImage.getHeight(); int lh[] = new int[] { 0, 0 }; for (int y = height - 1; y >= 0; y--) { if (bufferedImage.getRGB(0, y) == black) { lh[1] = y; break; for (int y = lh[1] - 1; y >= 0; y--) { if (bufferedImage.getRGB(0, y) != black) { lh[0] = y + 1; break; return lh; |
AffineTransform | findTranslation(AffineTransform at, BufferedImage bi) find Translation Point2D p2din, p2dout; p2din = new Point2D.Double(0.0, 0.0); p2dout = at.transform(p2din, null); double ytrans = p2dout.getY(); p2din = new Point2D.Double(0, bi.getHeight()); p2dout = at.transform(p2din, null); double xtrans = p2dout.getX(); AffineTransform tat = new AffineTransform(); ... |