Lab assignment 5
The first task in this lab was to create a collage image with several pictures blended together and the bluescreen image of myself in the middle. The first step was one that we learned how to to in the lab period last week, the alpha blending technique. That was done by including an "alpha" component in the buildCollage and putPixmap fuctions, and adding the following code to putPixmap:
( r0, g0, b0 ) = src.getPixel( j, i )
(r1, g1, b1 ) = dst.getPixel( j + x, i + y )
newr = r0*alpha + (1.0 - alpha)*r1
newg = g0*alpha + (1.0 - alpha)*g1
newb = b0*alpha + (1.0 - alpha)*b1
dst.setPixel( x + j, y + i, ( newr, newg, newb ) )
This would determine the opacity of the image from 0.0 to 1.0.
The next step was to create a list of images to put in the collage, which I called clist. The components for each image in the clist were 1- the filename, 2- the x offset, 3- the y offset, 4- the effect to apply to the image, 5- the alpha blend level, 6- whether to put the überblue pixels in the destination file (using the putPixmapNoBlue function), used for putting the bluescreen image in the collage, and 7- a sort of placeholder for the pixmap itself.
I used some new effects, including "stripeIt," (? minor extension) and ended up with the following image:
The next task was to create a triangle of pictures. For this, I assigned the height and width of each of the three images to a variable, and arranged them accordingly using the following code:
height1 = clist[-1].getHeight()
width1 = clist[-1].getWidth()
width2 = clist[-1].getWidth()
clist = int( width1*0.5 )
clist = height1
clist = width2
clist = height1
( cols, rows ) = collage.getImageSize( clist )
dst = graphics.Pixmap( cols, rows )
I ended up with the following image:
I had a few problems in this step, most notably, a frustrating one where I didn't realize I needed to specify that width*0.5 was an integer. But eventually all problems were fixed, and the picture came out nicely.