Consider writing code that starts with the image "astrachan.jpg" shown below on the left and replaces the bottom 10 rows of pixels with black pixels, resulting in the picture on the right below.

EBK JAVA PROGRAMMING
8th Edition
ISBN:9781305480537
Author:FARRELL
Publisher:FARRELL
Chapter16: Graphics
Section: Chapter Questions
Problem 2PE
icon
Related questions
Question

Please help!!

4. Consider writing code that starts with the image "astrachan.jpg" shown below on the left and replaces the bottom 10 rows
0/1 point
of pixels with black pixels, resulting in the picture on the right below.
The code has been started below but has missing code.
var image = new Simplelmage("astrachan.jpg"):
Il missing code
print(image):
Which one of the following is the best choice for the correct missing code to replace the bottom 10 rows with black pixels?
O var height = somelmage.getHeight();
for (var pixel of somelmage.values()) {
if (pixel.getY() >= height - 10) {
pixel.setRed(0):
pixel.setGreen(0):
pixel.setBlue(0);
O var width = somelmage.getWidth();
for (var pixel of somelmage.values() {
if (pixel.getX() >= width - 10) {
pixel.setRed(0):
pixel.setGreen(0):
pixel.setBlue(0);
var width = somelmage.getWidth();
for (var pixel of somelmage.values()) {
if (pixel.getX() <= width - 10) {
pixel.setRed(0):
pixel.setGreen(0):
pixel.setBlue(0);
O var height = somelmage.getHeight();
for (var pixel of somelmage.values() {
if (pixel.getY() <= height - 10) {
pixel.setRed(0):
pixel.setGreen(0);
pixel.setBlue(0);
! Incorrect
This is not a correct answer. This changes columns of pixels on the right side.
Transcribed Image Text:4. Consider writing code that starts with the image "astrachan.jpg" shown below on the left and replaces the bottom 10 rows 0/1 point of pixels with black pixels, resulting in the picture on the right below. The code has been started below but has missing code. var image = new Simplelmage("astrachan.jpg"): Il missing code print(image): Which one of the following is the best choice for the correct missing code to replace the bottom 10 rows with black pixels? O var height = somelmage.getHeight(); for (var pixel of somelmage.values()) { if (pixel.getY() >= height - 10) { pixel.setRed(0): pixel.setGreen(0): pixel.setBlue(0); O var width = somelmage.getWidth(); for (var pixel of somelmage.values() { if (pixel.getX() >= width - 10) { pixel.setRed(0): pixel.setGreen(0): pixel.setBlue(0); var width = somelmage.getWidth(); for (var pixel of somelmage.values()) { if (pixel.getX() <= width - 10) { pixel.setRed(0): pixel.setGreen(0): pixel.setBlue(0); O var height = somelmage.getHeight(); for (var pixel of somelmage.values() { if (pixel.getY() <= height - 10) { pixel.setRed(0): pixel.setGreen(0); pixel.setBlue(0); ! Incorrect This is not a correct answer. This changes columns of pixels on the right side.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Troubleshooting
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT