Requirements for Blending the Images
Blending two images is similar to creating a collage of the two images.
* When you download these images, they should all be the same size (same height and same width): 200x200 pixels.
* First you must determine the size of the blended image:
o Width = Width of the first image + half the width of the second image.
o Height = Height of either images since they are all the same height.
o Blended area = half of the second image over the same area in the latter part of the first image.
The transparent blended effect in the image above is achieved simply by creating new pixels in the area of the overlap which are 50% each of the corresponding pixels from the two images. In other words, to blend two pixels one must sum 50% of the red value from the first pixel and 50% of the red value from the second pixel. Repeat for the green and blue values. Use the 50% RGB sums to form the blended pixel.
There are multiple ways to accomplish blending two images. Below are pseudo code hints for one algorithm:
* determine the height and the width of the blended image.
* make a pixel array for the blended image.
* determine the blended width based on the width of the second image.
* copy the first image to the pixel array of the blended image.
o This is easy. Take the pixel array of image one and copy all of it to the blended image pixel array
* blend the latter part of the blended image with the first half of the second image.
o Remember that you have to start copying from where you left off.
o You will use a nested for loop, so you need to keep track of how the index in the blended image pixel array corresponds to the second image pixel array.
* copy the remaining pixels of the second image to the pixel array of the blended image.
o Remember that you have to start copying from where you left off.
o You will use a nested for loop, so you need to keep track of how the index in the blended image pixel array corresponds to the second image pixel array.
To blend multiple images one need only invoke their blend two images method multiple times in the following order:
* Blend Lincoln and FDR and return a new image.
* Blend the new GImage with Washington and return a new image.
* Blend the new GImage with Jefferson and return a new image.
* Blend the new GImage with Obama and return a new image.
* Display that image CENTERED on the canvas.
You should create at least two methods in this program:
* public int blendPixels(int p1, p2)
o This method should take two pixels. Extract the red, green, and blue values of each pixel. Multiply each by 0.5. Then creates a new pixel by adding the reds, greens, and blues.
* public GImage blendImages(GImage one, GImage two)
o This method will take two images as input. Blended the second one in the first one. Returns a GImage representing the blended image of the two.
Of course you are going to need to call these methods in the run method where you will be display the collage on the canvas.
Requirements for Your Solution
Your run method must serve as a driver to invoke your other methods. When your program is run it must execute, create and display the blended presidents' image above.
When the TAs run your program, it should display the collage as shown above centered.