Posted: Mon Feb 2
Due: Wednesday 2/4 10:00am
- 4th Period: https://classroom.github.com/a/mnpCa4pG
- 5th Period: https://classroom.github.com/a/4EOzZZvU
Time for your first computer generated image:
- 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.
- Your program must compile and run via a makefile.
- The makefile should be called makefile.
- Entering
makein 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
displayimagemagick command. If display doesn’t work,openshould do the trick.
- Save, commit & push your changes to the cloned repository
- 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
- on ubuntu:
$ apt-get install imagemagick - on mac:
- First install XQuartz: https://www.xquartz.org/index.html
- Follow theses instructions: https://github.com/tlk/homebrew-imagemagick-x11
- on window
- Install wsl: https://learn.microsoft.com/en-us/windows/wsl/install
- Then in a wsl terminal run:
$ sudo apt install imagemagick. You should run an apt update before install.
- For more detailed instructions (including building and installing it on your own): http://www.imagemagick.org/script/binary-releases.php
- You can also log into any stuy machine remotely, and run convert on them. * Once you’ve installed image magic, you can convert with the following command:
$ magick <source> <destination>- example:
$ magick foo.ppm foo.png - The destination format will be automatically set based on the file extension.
- 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 .jpgetc) - Compiling/running byproducts (i.e.
.o .class .pycetc) - Temporary files
- Mac people:
.DS_Store
- Image files (i.e.
- 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