Learn Java - 2D Arrays: Image Manipulation Project

This question refers to the final project in Codecademy Learn Java.

Changing the code in

int[][] imageData = imgToTwoD("./apple.jpg");

(to ./kitten.jpg, for example)

should change the image at localhost, correct? Any idea why that’s not working?

I’ve limited knowledge of Java but there’s nothing I can see which actually alters what image should be shown in the right hand window. Try creating some new images and altering the URL (on the right hand side) to those new paths to see them.

The instructions say changing to .kitten.jpg would change the image, but nothing happens.

I can’t spot that instruction but it seems like task 9 states how to change the image. Which bit deals with kitten.jpg?

From #1 in the instructions:

Note that you can use one of the provided images… We’ve provided "./apple.jpg" , "./flower.jpg" , and "./kitten.jpg" .

You can use any of those images, but, you don’t have to and I still can’t see what would then change the image shown on the right, as described in task 9 it defaults to apple.jpg. Aside from task 9 does anything else say how you might change the image shown?

I think the confusion is that the browser window (the white box to the right of the coding screen) is static; it is not dynamically tied to the coding. The images that you create within the code get stored to the buffer, but you have to manually change the address in the browser window to call them. They mention this in step 9 but, I’ll admit, it’s not terribly clear and I struggled with it at first too.

So to view the kitten you need to type http://localhost:8000/kitten.jpg in the browser window above the picture.

To view the cropped kitten image, you need to update your code to int[][] imageData = imgToTwoD("./kitten.jpg"); (instead of ./apple ) and also update twoDToImage(trimmed, "./trimmed_kitten.jpg"); (instead of trimmed_apple.jpg ), run the code so that this image is saved in your buffer then manually change the address in the browser window above the picture to http://localhost:8000/trimmed_kitten.jpg.

To complete up to step 15, you will need to have written your negative color method per previous, then call this in the main method with something like:
int [][] negImage = negativeColor(imageData);
twoDToImage(negImage, "./negative_kitten.jpg");

…then manually change the address in the browser window above the picture to http://localhost:8000/negative_kitten.jpg.

Does that help at all?