List of utility methods to do BufferedImage Operation
BufferedImage | composite(BufferedImage bg, BufferedImage fg) composite BufferedImage result = copyImage(bg);
Graphics g = result.getGraphics();
g.drawImage(fg, 0, 0, null);
g.dispose();
return result;
|
double[][] | computeBrightnesses(final BufferedImage image) compute Brightnesses final int width = image.getWidth(); final int height = image.getHeight(); final double[][] brightnesses = new double[width][height]; for (int i = 0; i < width; ++i) { for (int j = 0; j < height; ++j) { brightnesses[i][j] = getBrightness(image, i, j); return brightnesses; |
void | computeTrimmedBounds(BufferedImage image, Rectangle tbounds) Computes the bounds of the smallest rectangle that contains all non-transparent pixels of this image. int width = image.getWidth(), height = image.getHeight(); int firstrow = -1, lastrow = -1, minx = width, maxx = 0; for (int yy = 0; yy < height; yy++) { int firstidx = -1, lastidx = -1; for (int xx = 0; xx < width; xx++) { int argb = image.getRGB(xx, yy); if ((argb >> 24) == 0) { continue; ... |
BufferedImage | conformImageToInt(BufferedImage in) conform Image To Int return convertImage(in, BufferedImage.TYPE_INT_RGB);
|
BufferedImage | contrast(BufferedImage src, float scaleFactor) Contrasts image. RescaleOp rop = new RescaleOp(scaleFactor, 0, null); return rop.filter(src, null); |
BufferedImage | criarImagemCompativel(BufferedImage original, int largura, int altura, boolean manterQualidade) criar Imagem Compativel GraphicsConfiguration graphicsConfiguration = GraphicsEnvironment.getLocalGraphicsEnvironment() .getDefaultScreenDevice().getDefaultConfiguration(); BufferedImage imagemCompativel = graphicsConfiguration.createCompatibleImage(largura, altura, original.getTransparency()); Graphics2D g = (Graphics2D) imagemCompativel.getGraphics(); if (manterQualidade) { g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); g.drawImage(original, 0, 0, largura, altura, null); g.dispose(); return imagemCompativel; |
BufferedImage | cutToSquare(BufferedImage src) cut To Square int width = src.getWidth(); int height = src.getHeight(); if (width == height) return src; BufferedImage result = null; if (width > height) { int cut = (width - height) / 2; result = src.getSubimage(cut, 0, height, height); ... |
BufferedImage | cylindricalMapping(BufferedImage img, double f) cylindrical Mapping if (img == null) { return null; int w = img.getWidth(); int h = img.getHeight(); BufferedImage out = new BufferedImage(w, h, img.getType()); int x0 = (int) Math.floor(w / 2) + 1; int y0 = (int) Math.floor(h / 2) + 1; ... |
void | darkenImage(final BufferedImage image, final float darken) Darkens specified BufferedImage final Graphics2D g2d = image.createGraphics();
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, darken));
g2d.setPaint(Color.BLACK);
g2d.fillRect(0, 0, image.getWidth(), image.getHeight());
g2d.dispose();
|
BufferedImage | declareNewBufferedImage(int x, int y) declare New Buffered Image BufferedImage imgOut = new BufferedImage(x, y, BufferedImage.TYPE_INT_RGB); return imgOut; |