Create a new method that will blend two pictures with 20% from just the first picture and a 60% overlap and then 20% 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 blendPictures206020 ( )
{
Picture p1 =
new Picture ( FileChooser. getMediaPath ( " church . jpg " ) ) ;
Picture p2 =
newPicture ( Fi l eChooser.getMediaPath ( " e i f f e l . jpg " ) ) ;
Pixel source1 = null ;
Pixel source2 = null ;
Pixel target = null ;
// copy the first 20% of p1
int end1 = ( int ) ( p1 . getWidth ( ) ¤ 0 . 2 0 ) ;
for ( int x = 0 ; x < end1 ; x++)
f
for ( int y = 0 ; y < p1 . getHe ight ( ) ; y++)
f
source1 = p1.getPixel (x , y ) ;
target = this.getPixel (x , y ) ;
target . setColor ( source1 . getColor ( ) ) ;
}
}
// now blend p1 and p2 f o r 60% of p1
int end2 = ( int ) ( p1 . getWidth ( ) ¤ 0 . 8 ) ;
for ( int x = end1 ; x < end2 ; x++)
{
for ( int y = 0 ; y < p1 . ge tHeight ( ) ; 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 20% of p2
for ( int x = end2 ; x < p2 . getWidth ( ) ; x++)
{
for ( int y = 0 ; y < p2 . getHeight ( ) ; y++)
{
source2 = p2 . getPixel (x , y ) ;
target = this.getPixel (x,y) ;
target.setColor ( source2.getColor ( ) ) ;
}
}
}
```

Computer Science & Information Technology

You might also like to view...

What kind of iterators does the stack template container have?

What will be an ideal response?

Computer Science & Information Technology

Which of the following is not a type of bias introduced unintentionally during output presentations?

A) how information is sorted B) choice of fonts C) choice of graphics D) setting of acceptable limits

Computer Science & Information Technology

How can you add photos to an existing Person, Place or Event?

What will be an ideal response?

Computer Science & Information Technology

What are the two most popular web server applications?

a. Nginx b. Tomcat c. Apache d. IIS

Computer Science & Information Technology