Question: Java Homework Question: I am trying to rotate an image +90 degrees and -90 degrees. I have only begun the +90 degrees code. I keep
Java Homework Question:
I am trying to rotate an image +90 degrees and -90 degrees.
I have only begun the +90 degrees code. I keep getting the errors: int cannot be converted to Pixel and Pixel cannot be converted to int.
I have to get and set the data the way it is. I'm just confused on the actual rotating, and I cannot use any extra packages.
This is what I have so far, please help me to fix it:
public class RotateClockwiseFilter implements Filter { /** * Rotate the image 90 degrees clockwise * * @param theImage The image to modify */ public void filter(PixelImage theImage) { // get the data from the image Pixel[][] data = theImage.getData(); int[][] matrix; for (int row = 0; row < theImage.getHeight(); row++) { for (int col = 0; col < theImage.getWidth(); col++) { Pixel temp = data[row][col]; data[row][col] = matrix[col][row]; matrix[col][row] = temp; } } theImage.setData(data); } }
This is
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
