import java.awt.Color; class Lab13aPictsColor { /** Invert all the pixels in `nums`. */ static void invert( Color[][] nums ) { for ( int r=0; r < nums.length; ++r ) { // fill in row# `r` invert_row( nums, r ); } } /** Invert all the pixels in row `r` of `nums`. */ static void invert_row( Color[][] nums, int r ) { for ( int c=0; c < nums[r].length; ++c ) { invert_pixel(nums, r, c ); } } /** Invert pixel `r`,`c` of `nums`. * Mutates the array. (I.e. changes the value stored in the cell, * so a caller with a reference to the array will "see" the change. * Doesn't return a value; is void.) */ static void invert_pixel( Color[][] nums, int r, int c ) { nums[r][c] = new Color( 255 - nums[r][c].getRed(), 255 - nums[r][c].getGreen(), 255 - nums[r][c].getBlue() ); } static void demo() { Color[][] img; //data = new int[400][600]; //fill_pattern(data); img = Pict.fileToPixelsColor("https://snworksceo.imgix.net/dtc/10ec0a64-8f9d-46d9-acee-5ef9094d229d.sized-1000x1000.jpg?w=1000"); Pict.displayPixels( img ); invert(img); Pict.displayPixels( img ); } public static void main( String[] __ ) { demo(); } }