2D Arrays: Image Manipulation Project

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?

Hey design3668737565!
I may be able to give you an answer, but in order to do so it would make it easier if you can add three backticks ``` before and after your code block, in order to style formatting it and making it more clear to read.

Cheers,

1 Like

I’m not actually sure how to edit my post…

There’s an option in the bottom right of the message box, near reply, but I think you have a limited time in which to edit (a couple of hours or so but I don’t know exactly how long). If the option is no longer there then you can just reply with your formatted code :slightly_smiling_face:.

A view of the following might also be useful for the future- How to ask good questions (and get good answers) as it covers useful things like formatting and linking relevant projects/lessons amongst other things, ta.

Okay, thanks! So @tgrtim, can you help with my original question about why the photo viewer in the activity isn’t working?

I’m not even sure what language you’re using so probably not. Posting the actual formatted code and a link to the lesson isn’t for your sake, it’s for anyone else who tries to assist so if you’d be so kind as to actually do that :laughing:

Okay - let me start over with a new post.

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?