Program 1 Guide

[ Assignment Writeup | Summary | Details | Prerequisites ]
[ PPM Format | Solution ]

Summary and Goal

Students are to create an image in PPM format to give them experience with PPM format and writing binary files. ( Assignment writeup )

Details

  • The students will write the output to standard out. Output will need to be redirected to a file.
  • They will output just a solid color or pattern of colors of size 800 by 600. This size should force them to use a loop.
  • Students will need to learn to use Unix image viewers, such as Gimp. (There is Windows software (IrfanView) available online for converting to PPM format.)

Prerequites for completing assignment

[ editor | compiler | program file | output | data files | PPM | ints | stdout | loops | image viewing ]
    The following topics need to be covered in order to provide students with the information needed to complete the assignments. Make sure they understand how each step works toward this phase of the project. Students should be able to begin before all steps are covered.

  1. An ability to create files in Eclipse Eclipse editor
  2. An ability to compile and run programs in Eclipse: Eclipse compiler  

  3. An understanding of a C program file
    • Definition of a function: a group of commands to be executed sequentially.
    • Explanation of the main function: the function that is automatically executed when you run a program.
    • Description of function definition syntax

  4. A knowledge of outputting to the screen with printf
    • Definition of printing to the screen.
    • Description of the printf function for printing text:
      printf ("Hello, world");
    • Explanation of the need to include the stdio library for printf:
      #include <stdio.h>
    • Explanation of the main function: the function that is automatically executed when you run a program.
  5. An understanding of binary files
    • Discussion of American Standard Code for Information Interchange ASCII files: files with readable text
    • Discussion of data files: files people can't read
    • Method of creating binary data: printf with %c:
      printf ("%c", 75);
  6. Familiarity with ( PPM format )
    • Creation of the magic number, width, height, and max value:
      printf(". . .");
    • Creation of the one pixel of data:
      printf("%c%c%c", r, g, b);
  7. An ability to create an integer counter variable
    • Definition of a variable: location in memory for holding a changable value
    • Description of an integer
    • Demonstration of defining an integer at the beginning of the main
  8. Knowledge of standard out
  9. An ability to create a counted loop
    • Discussion of the inability to make 480,000 printf statements.
    • Discussion of the concept of looping
    • Discussion of counted loops
    • For loop syntax
  10. An ability to view image files
      There are multiple ways to view the .ppm files:
    • Using a windows ppm viewer (e.g. IrfanView)
    • Converting to .png format and viewing in windows image viewers: IrfanView and others.

Solution

  • Sample output


    [ Assignment Writeup | Summary | Details | Prerequisites ]
    [ PPM Format | Solution ]