/* CS1316 Summer '09 - Image Manipulation Homework * * Collaboration Statement: * LIST_OF_NAMES_OR_SOURCES_GOES_HERE -or- I worked on this assignment alone. * * In this homework you are given a main method which prompts the user * for a picture then displays it both stock and after a series of modifications * have been performed on it. * * Your assignment is to edit these methods such that they perform various actions * on the photo. These actions are described below in the code. * * You MAY NOT use any methods inside of Picture or SimplePicture. * * Note: I have written some rudamentary framework for the methods with regards to their * return statement. I did this so the code would compile; you may or may not want to * change it in your solution. You may not edit the method headers! */ public class ImageManipulation { public static Picture pic; public static void main( String[] args ) { pic = new Picture( FileChooser.pickAFile() ); Picture dg, r, n; Picture canvas = new Picture( pic.getWidth()*2 , pic.getHeight()*2 ); pic.compose( canvas , 0 , 0 ); dg = decreaseGreen(); dg.compose( canvas , pic.getWidth() , 0 ); r = reverse(); r.compose( canvas , 0 , pic.getHeight() ); n = negate(); n.compose( canvas , pic.getWidth() , pic.getHeight() ); canvas.show(); } public static Picture decreaseGreen(){ /* In this method, you must return 'pic' with all of its green values reduced by half. * * HINTS: * pic.getPixels() will return a 1-D array of all of the pixels in pic * pixel.getGreen() will return the green intensity in pixel as a value between 0-255 * pixel.setGreen(value) will set the green value of a pixel */ return ret; } public static Picture reverse(){ /* In this method, you must return a copy of 'pic' with all of its pixels reversed in order. * You may simply reverse the pixelArray that Picture.getPixels() returns. * HINT: * In order to assign a pixel's value to another pixel, you have to use pixel.setColor(anotherpixel.getColor()) */ return ret; } public static Picture negate(){ /* In this method, you must return 'pic' with all of its pixels negated. * * HINT: * To negate a pixel is to swap all its color values with their complements. * As an example, if a pixel had an (R,G,B) value of (1,10,100) its resulting negative * would be (254,245,155). Keep in mind the maximum value for an 8-bit int is 255 * so 255-1=254 , 255-10=245 , 255-100=155. */ return ret; } } // end Public class ImageManipulation