Question: 2. Complete the following Java class that is an abstraction of an RGB image. No console input/printing or file J/O is required. (27%) class Image

 2. Complete the following Java class that is an abstraction of

an RGB image. No console input/printing or file J/O is required. (27%)

2. Complete the following Java class that is an abstraction of an RGB image. No console input/printing or file J/O is required. (27%) class Image 1 protected int w,h;// dimensions width w by height h protected Color[][] pixels; // starts at row 0 , column 0 // Constructor initializing an Image object with all reddish pixels // of Color(255, 17, 8); assume both parameters are positive. public Image ( int weight, int height) // 78 \{ \} // end of constructor // According to this Image, create and return a new Image with // doubled height \& doubled width, by repeating each pixel 4 times. // I.e., one original pixel is copied to a 22 block in the new one public Image enlargeByDouble() //8\% 1 Question 2 cont'd. // Set Color of the pixel at row x, col c, both indices start at 0 . protected void setpixel( int r, int c, Color p ) //1 \% \{ \} // end of method // Adjust the red-component by adding a delta value to all pixels. // The delta value can be negative. Clamp the results to [0, 255]. // Use Color instance methods getRed(), getGreen () and getBlue (). // "Replace/ set" each and every Color pixels with a new one. protected void adjustRed ( int delta) //9% l \} // end of method \} // end of class Image Write down FOUR possible boolean conditions in terms of r,c,w,h, such that setPixel(r, c) may raise ArrayIndexOutofBoundsException. // 2\%

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!