Browse code

simplification

haywalk authored on 02/04/2021 14:26:29
Showing 2 changed files

1 1
Binary files a/PixelPoke.class and b/PixelPoke.class differ
... ...
@@ -13,14 +13,7 @@ import java.io.*;
13 13
 import javax.imageio.*;
14 14
 
15 15
 public class PixelPoke {
16
-	public static void main(String[] args) throws IOException {
17
-		/*
18
-		 * The main function will read an image from a file (provided by the user
19
-		 * via command-line arguments) , pass it into the function that returns its negative, 
20
-		 * and will write the return value of that function to an output file, or if none 
21
-		 * is specified, it will overwrite the input file.
22
-		 */
23
-		 
16
+	public static void main(String[] args) throws IOException {	 
24 17
 		// Create variables to store names of input and output files
25 18
 		String inputFileName = "";
26 19
 		String outputFileName = "";
... ...
@@ -54,19 +47,7 @@ public class PixelPoke {
54 47
 			inputError();
55 48
 		}
56 49
 		
57
-		// Make a negative of the image
58
-		BufferedImage imgOut = negative(img);
59
-		
60
-		// Write the negative to the output file
61
-		ImageIO.write(imgOut, "jpg", outputFile);
62
-	}
63
-	
64
-	static BufferedImage negative(BufferedImage img) {
65
-		/*
66
-		 * This function takes in a buffered image and returns the image's negative.
67
-		 */
68
-		
69
-		// Get the dimensions of the image
50
+		// Get image dimensions
70 51
 		int width = img.getWidth();
71 52
 		int height = img.getHeight();
72 53
 		
... ...
@@ -79,8 +60,8 @@ public class PixelPoke {
79 60
 			}
80 61
 		}
81 62
 		
82
-		// Return the modified image
83
-		return img;
63
+		// Write the negative to the output file
64
+		ImageIO.write(img, "jpg", outputFile);
84 65
 	}
85 66
 			
86 67
 	static void inputError() {