Method toVertical, which accepts two parameters parameters in the following order:
(a) An image of type BufferedImage
(b) A proportional y-coordinate of type double
It returns as an int the pixel coordinate in the image that corresponds to the proportional coordinate. The proportion is inversely applied to the image’s height, with proportion 0 mapping to the bottommost row of pixels (whose index is one less than the image’s height), and proportion 1 mapping to the top row of pixels, whose index is 0. This inverse mapping has the effect of situating the image’s origin in proportional space to the bottom left of the image.
For example, if an image has width 30, the following values should be produced for various proportions:
• toVertical(image30, 0.0) → 29
• toVertical(image30, 1.0) → 0
• toVertical(image30, 0.75) → 7
• toVertical(image30, 0.77) → 7
I am confused as to how I should approach this problem. Here is the code I have so far.
public static int toVertical(BufferedImage image, double ycoor) {
int height = image.getHeight();
double prop = height * (1/ycoor);
int prop1 = (int) ()
return prop1 -+ 1;