Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.


+7 votes

I have the method ready to execute, but do not understand the syntax of printing the manipulated picture

asked in CSC212_Spring2019 by (8 points)

1 Answer

+3 votes
Best answer

Let's assume the method to create the relief image is named createReliefImage. I didn't give a name for the method so your method could be named something else.

You'll need these three lines of code in the main method to draw the relief image...

int[][] reliefArray = createReliefImage(imageArray);
// calls your method which returns a reference to a 2D array of ints with the "numbers" that make the relief look. The reference is stored in the variable reliefArray (or whatever you call it) in main.

// calls an instance method of the Image class (ealier in my code image is set as the name of the Image object) to store your array as the 2D array that will be used to draw the image

image.draw(g, image.getWidth(), OFF_SET);
// calls an instance method of the Image class to draw the image in the window connected to the Graphics object g. It will draw the image in the widow the image's width horizontally from the left side of the window and OFF_SET vertically from the top side of the window.

You'll repeat this code 4 more times for each manipulation changing the name of the method, the name of the 2D array that stores the result, and the position where the image is drawn. So the third image in the first row will be at position image.getWidth() * 2, OFF_SET. The first image in the second row will be at position 0, image.getHeight() + OFF_SET.

answered by (8 points)
selected by