You can use JDeli to achieve image color inversion in Java. JDeli is an enterprise-level Java image library that makes it easy to read, write, convert, manipulate and process HEIC and other image file formats in Java.
This class uses the provided image and returns an inverted image containing negative argb values image. This makes the image appear inverted.
ImageProcessingOperations operations = new ImageProcessingOperations();
// You can chain several operations here such as scale, blur, etc
operations.invertColors();
// Apply the operations to a BufferedImage
BufferedImage modifiedImage = operations.apply(BufferedImage originalImage);
Process and convert between image formats using the following code examples:
File inputFile = new File("path/to/file");
File outputFile = new File("path/to/output-inverted-file");
JDeli.convert(inputFile, outputFile, operations);
final InputStream inputStream = new FileInputStream(inputFile);
final OutputStream outputStream = new FileOutputStream(outputFile);
final String outputFormat = "format"; // format of the output file eg. png, jpeg,...;
JDeli.convert(inputStream, outputStream, outputFormat, operations);
byte[] inputData = Files.readAllBytes(Paths.get("/path/to/file"));
final String outputFormat = "format"; // format of the output file eg. png, jpeg,...;
byte[] outputData = JDeli.convert(inputData, outputFormat, operations);