Question: Write a program that consists of multiple source files to parse the header information from a ppm image. Some ppm images and some starter code

Write a program that consists of multiple source files to parse the header information from a ppm image. Some ppm images and some starter code will be provided. Write the function to parse the header, as well as a makefile, and a header file. You will also need to write a makefile that at the very least contains a target for compilation.

The parseHeader() function will need the file pointer sent to it from main() as well as pointers to the column value and the row value. If your program parses the columns and rows from those two files, then it will be sufficient. For PA3 in the lecture, be sure to add code to handle other variations of the header.

The goal is to parse from the header the columns and the rows and print those values to the user. For PA3, you will add more code to continue parsing through the header to move the file pointer to the next item after the 255; then the image pixel data can be read in.

mainDriver.c with starter code; fill in some code

parse.c with header comment and #include for defs.h this is where the parseHeader() function goes

defs.h with #includes and a spot for the prototype of the parseHeader() function

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

P6 690 461

#given ppm file

255

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

P6

# magnify=10.000000 itermax=100

500 500

255

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

/* Parse.c

parse.c file, will be used for PA3 and will contain:

1. parseHeader() - - > this lab

is called from the main() function

gets cols & rows from the header of the image file

2. getImage() function - - > for the assignment, NOT this lab

gets the image data and puts into the 2-D array (of struct pixels)

3. any other helper functions you may write for parsing the file

use fprintf to stderr for printing any messages or values to the user

*/

#include "defs.h"

"parse.c" 28L, 566C Hello World!

1. parseHeader() - - > this lab

is called from the main() function

gets cols & rows from the header of the image file

2. getImage() function - - > for the assignment, NOT this lab

gets the image data and puts into the 2-D array (of struct pixels)

3. any other helper functions you may write for parsing the file

use fprintf to stderr for printing any messages or values to the user

*/

#include "defs.h"

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

// defs.h //

#include

#include

#include

// prototypes here:

~

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

/* mainDriver.c

mainDriver.c file

the main function uses command-line arguments

(notice the function signature)

to run the program, type a.out and the image file name, such as:

./a.out filename.ppm

use fprintf to stderr for printing any messages or values to the user

the parseHeader() function is called from here

*/

#include "defs.h"

int main(int argc, char *argv[]) {

int width, height;

FILE *inputFile; // file pointerF

"mainDriver.c" 60L, 940C

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!