Create a new method that will blend two pictures with 10% from just the first picture and a 80% overlap and then 10% from the just the last picture. It helps if the two pictures are the same width and height.

What will be an ideal response?


```
public void blendPictures108010 ( )
{
Picture p1 = new Picture ( FileChooser.getMediaPath ( " church.jpg " ) ) ;
Picture p2 = new Pictur e ( FileChooser.getMediaPath ( " eiffel.jpg " ) ) ;
Pixel source1 = null ;
Pixel source2 = null ;
Pixel target = null ;
// copy the first 10% of p1
int end1 = ( int ) ( p1.getWidth ( ) * 0.10 ) ;
for ( int x = 0 ; x < end1 ; x++)
{
for ( int y = 0 ; y < p1.getHeight ( ) ; y++)
{
source1 = p1. getPixel (x , y) ;
target = this.getPixel (x , y ) ;
target.setColor (source1. getColor ( ) ) ;
}
}
// now blend p1 and p2 for 80% of p1
int end2 = ( int ) ( p1. getWidth ( ) * 0 . 9 ) ;
for ( int x = end1 ; x < end2 ; x++)
{
for (int y = 0 ; y < p1.getHeight ( ) ; y++)
{
source1 = p1.getPixel (x , y ) ;
source2 = p2.getPixel (x , y ) ;
target = this.getPixel (x , y ) ;
target.setColor (new Color (source1.getRed ( ) / 2 +
source2.getRed ( ) / 2 ,
source1.getGreen ( ) / 2 +
source2.getGreen ( ) / 2 ,
source1.getBlue ( ) / 2 +
source2.getBlue ( ) / 2 ) ) ;
}
}
// copy last 10% of p2
for ( int x = end2 ; x < p2.getWidth ( ) ; x++)
{
for ( int y = 0 ; y < p2.getHeight ( ) ; y++)
{
source2 = p2.getP xel (x ,y) ;
target = this.getPixel (x , y ) ;
target.setColor (source2.getColor ( ) ) ;
}
}
}
```

Computer Science & Information Technology

You might also like to view...

Which of the following method declarations correctly defines a method with a variable length parameter list?

a)``` public int average(int[] list) ``` b)``` public int average(int ... list) ``` c)``` public int average(...) ``` d)``` public int average(int a, int b, int c, ...) ``` e)``` public int average(integers) ```

Computer Science & Information Technology

Answer the following statements true (T) or false (F)

1) People prefer to manipulate bits instead of characters and fields because bits are more compact. 2) People specify programs and data items as characters; computers then manipulate and process these characters as groups of zeros and ones. 3) Most organizations store all information in a single file to facilitate computer processing. 4) Each statement that processes a file in a Python program explicitly refers to that file by name. 5) Python imposes no structure on a file.

Computer Science & Information Technology

In business decision making, Access is a versatile tool that can aid in transforming data into information

Indicate whether the statement is true or false

Computer Science & Information Technology

A(n) ____________________ printer works by spraying ionized ink at a sheet of paper.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology