Program 1 Guide
[
Assignment Writeup
|
Summary
|
Details
|
Prerequisites
]
[
PPM Format
|
Solution
]
Students are to create an image in PPM format to give them experience with PPM format and
writing binary files. (
Assignment writeup
)
- 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.)
[ 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.
- An ability to create files in Eclipse
Eclipse editor
- An ability to compile and run programs in
Eclipse:
Eclipse compiler
- 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
- 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.
- 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);
- 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);
- 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
- Knowledge of standard out
- 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
- 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.
Sample output
[
Assignment Writeup
|
Summary
|
Details
|
Prerequisites
]
[
PPM Format
|
Solution
]
|