Java Utililty Methods BufferedImage Invert

List of utility methods to do BufferedImage Invert

Description

The list of methods to do BufferedImage Invert are organized into topic(s).

Method

BufferedImageinvert(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();
...
voidinvertImage(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);
voidinvertImage(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);
...
BufferedImageinvertImage(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;
BufferedImageinvertImage(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;