Question: #8940

CSCI1302 Lab 3 Complete Solution

CSCI 1302 Lab 3

 (100 points)

Question 1.

Write a method changeBlue(weight). Do not change any color of the pixels in the first half of a picture. For the second half, change blue value of each pixel by new blue=original blue * weight. For example, if a pixel has values (200,100,100) and weight is 0.5, then the new values will be (200,100,50). If the weight is 1.5, then the new values will be (200,100,150).

 

This is first half, do not change!

This is second half, change blue.

 

Question 2.

Write a method mirrorVertical(). The method  mirrors the left half of a picture to  the right half of the picture. For instance, the two pictures below show that the left one is the original picture, and the right one is the new picture.

Question 3.

Write a method copyPart(w,h). The method copies an upper left rectangle area in an image to its lower right area. w and h are width and height of the rectangle. In the figure below, |ab| is w and |ac| is h. We assume that 2*w is less than the picture’s width,  and 2*h is less than the picture’s height. That is, the source area and the destination area are not overlapped and w or h is not out of bound.

All methods need to be included in the file Picture.java. Once you are finished, recompile your Picture.java, and then test your methods in DrJava. You can use any picture to test your programs.

Solution: #8968

CSCI1302 Lab 3 Complete Solution

import java.awt.*; import java.awt.font.*; import java.awt.geom.*; import java.awt.image.BufferedImage; import java.text.*; /** * A class that...
Tutormaster
Rating: A+ Purchased: 11 x Posted By: Vikas
Comments
Posted by: Vikas

Online Users