List of utility methods to do BufferedImage Invert
BufferedImage | invert(BufferedImage inImg) invert if (inImg == null) { return null; int width = inImg.getWidth(); int height = inImg.getHeight(); BufferedImage outImg = new BufferedImage(width, height, inImg.getType()); WritableRaster outRaster = outImg.getRaster(); WritableRaster inRaster = inImg.getRaster(); ... |
void | invertImage(BufferedImage image) Perform image invert operation. int width = image.getWidth(); int height = image.getHeight(); int new_rgb; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { new_rgb = (~(image.getRGB(x, y))); image.setRGB(x, y, new_rgb); |
void | invertImage(BufferedImage image) Inverts a grey scale image. WritableRaster inRaster = image.getRaster(); int[] p = new int[3]; float v = 0; for (int x = 0; x < inRaster.getWidth(); x++) { for (int y = 0; y < inRaster.getHeight(); y++) { inRaster.getPixel(x, y, p); p[0] = 255 - p[0]; inRaster.setPixel(x, y, p); ... |
BufferedImage | invertImage(BufferedImage img, boolean newImage) Inverts the given image. BufferedImage returnImage = img; if (newImage) returnImage = new BufferedImage(img.getWidth(), img.getHeight(), img.getType()); for (int y = 0; y < img.getHeight(); y++) { for (int x = 0; x < img.getWidth(); x++) { int in = img.getRGB(x, y); returnImage.setRGB(x, y, (in & 0xff000000) | ((~in) & 0x00ffffff)); return returnImage; |
BufferedImage | invertImage(final BufferedImage savedImage) invert Image final BufferedImage invertedImage; AffineTransform tx = AffineTransform.getScaleInstance(1, -1); tx.translate(0, -savedImage.getHeight(null)); AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR); invertedImage = op.filter(savedImage, null); return invertedImage; |