Assignment 4

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0
Task 1

Task 1 is to create a function putPixmap which takes four arguments. The purpose of this function is to put a small pixmap onto another bigger pixmap.

The code is as below:

Code Block
# place src into dst with upper left at (x,y) in dst
def putPixmap( dst, src, x, y ):
	# loop over each row i
	for i in range( src.getHeight() ):
		# loop over each column j
		for j in range( src.getWidth() ):
			# from src, get the (r, g, b) value at pixel (j, i)
			( r, g, b ) = src.getPixel( j, i )
			# in dst, set location (x + j, y + i) to (r, g, b)
			dst.setPixel( x + j, y + i, ( r, g, b ) )
	# return
Task 2

This task is to create 3 mor functions like swapRedBlue that edit the colors in a Pixmap. I have created a few more, and for the picture of it, please refer to extensions

Task 3

This task is to put 4 copies of the smaller Pixmap and put it into the bigger Pixmap. For this task, I have done some more extensions on it, so please refer to extensions


I am changing the blue screen behind my picture into another color. I have divided it into 4 quadrants, and changed its color. The picture produced:


I have undertook a few of the extensions unconsciously, I was excited to create several effects. One of them is putting myself onto a scene. I chose to put myself by the beach:
Also, I went on to create a bigger Warhol style collage, and also enable my Warhol program to read in multiple images from the command line.

The command is:

Code Block
 python <nameOfPicture1.ppm> <nameOfPicture2.ppm>

This essentially allows people to put different images onto the Warhol collage.

My collage:
I placed the beach in the middle of the collage, and did some alternation. I then placed myself surrounding the beach. One special picture is the most lower-right. I have half of myself, with different effects, and it spiral down till it is very small.


I have learned to make wonderful effects to a picture by writing simple codes. I also learned that sometimes it is hard to actually make an effect work, due to the positioning and the colors of the pixels. Finally, I learned how to put myself onto any scene, given a simple colored background.