Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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%) 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started