I can't believe I made such a silly mistake...
Thanks, Tim
Although, the program still doesn't work
In fact, it seems this particular mistake had nothing to do with the result
Here's the latest version:
private GImage makeColorNegative(GImage image) {
int[][]array = image.getPixelArray();
for(int row = 0; row < array.length; row++) {
for(int col = 0; col < array[0].length; col++) {
int pixelColor = array[row][col];
array[row][col] = getNegativeColor(pixelColor);
}
}
return new GImage(array);
}
private int getNegativeColor(int color) {
int alpha = ((color >> 24) & 0xFF);
int negRed = ~((color >> 16) & 0xFF);
int negGreen = ~((color >> 8) & 0xFF);
int negBlue = ~(color & 0xFF);
return (alpha << 24) | (negRed << 16) | (negGreen << 8) | negBlue;
}