Here you can find the source of invertImage(BufferedImage image)
Parameter | Description |
---|---|
image | Input Image |
public static void invertImage(BufferedImage image)
//package com.java2s; /**/*from w w w . j av a2 s .c o m*/ * Copyright 2014 Comcast Cable Communications Management, LLC * * This file is part of CATS. * * CATS is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * CATS is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with CATS. If not, see <http://www.gnu.org/licenses/>. */ import java.awt.image.BufferedImage; public class Main { /** * Perform image invert operation. * * @param image * Input Image * @return Inverted image */ public static void invertImage(BufferedImage image) { 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); } } } }