Posted: Mon Feb 2

Due: Wednesday 2/4 10:00am

Time for your first computer generated image:

  1. Create a program that generates a valid ppm image file, it should be at least 500x500, but also don’t make it too big (remember, each pixel is stored as up to 12 bytes - 3 for each color value - so a 1000x1000 image could be 12MB large, they get big fast).
    • To submit the assignment, you need to click on the assignment link above. It will create a repository for you. Do all your work in that repository.
    • Your repository will have 3 files in it, one in python, once in java and one in c. Each file is a small sample program that will create and write a file named image.ppm. You can either use the provided programs or make your own.
  2. Your program must compile and run via a makefile.
    • The makefile should be called makefile.
    • Entering make in the command line should compile (if necessary), run the program, and display the image.
    • Makefile help. There are also notes below with simple examples.
    • The makefile should invoke whatever is needed to compile and/or run your program.
    • The makefile should then display the image, ideally, use the display imagemagick command. If display doesn’t work, open should do the trick.
  3. Save, commit & push your changes to the cloned repository
  4. Convert your image to a png and upload it to the Graphics gallery website: http://gallery.stuycs.org
    • For help with converting, you could install ImageMagick
  5. You must submit your code via github repository and upload an image to the gallery.

Other Requirements:

  • Ensure that your repository does not contain the following things:
    • Image files (i.e. .ppm .png .jpg etc)
    • Compiling/running byproducts (i.e. .o .class .pyc etc)
    • Temporary files
    • Mac people: .DS_Store
  • Include in your makefile the following
    • clean: Removes any compiling/running byproducts, also temporary files.
    • cleanall: Removes everything except your source code (this includes executable files and generated images).

Makefile examples:

  • Java:
default: run

Main.class: Main.java
  javac Main.java

run: Main.class
  java Main
  display image.ppm

  • Python
default: run

run: main.py
  python main.py
  display image.ppm

python note: when I run python I get python 3.x, some people have needed to use python3 instead of python.

  • C
default: run

main.o: main.c
  gcc -c main.c

picmaker: main.o
  gcc -o picmaker main.o

run: picmaker
  ./picmaker
  display image.ppm