Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Parsing Header Info from a ppm Image Overview This week, you will write a program that consists of multiple source files to parse the header

Parsing Header Info from a ppm Image Overview This week, you will 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. You will need to write the function to parse the header, as well as a makefile, and a header file. The files from this lab will be starter files for the third programming assignment.

mainDriver.c with starter code; need to 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 two image files You will also need to write a makefile that at the very least contains a target for compilation. 2. Your parseHeader() function will need the file pointer sent to it from main() as well as pointers to the column value and the row value. Since the 3 parts of the header can be on separate lines or not, and may or may not have comments in between them, parsing the header can be tricky. Take a look at each of the image files to see what the headers look. If your program for this lab parses the columns and rows from those two files, then it will be sufficient for the lab. For PA3 in the lecture, however, you should make sure to add code to handle other variations of the header. You will use file I/O functions to read in character by character, or string by string, or an entire line at a time. There are many different ways that this can be done. You will have to take a look at the different functions available and think about what makes the most sense to you. Remember, that for this lab, the goal is just to parse from the header the columns and the rows and print those values to the user. But for PA3, you will have to add more code to continue parsing through the header so that you move the file pointer to the next item after the 255; then at that point, the image pixel data can be read in.

Here, is three file addedd. Need help in this program.

//twoTigers.ppm P6 400 600 255

// tiger.ppm P6 690 461 #given ppm file 255 @ // mainDriver.c file

// fill out the code below as needed int main(int argc, char *argv[]) { int width, height; FILE *inputFile; // file pointer // if user only types the executable name and no other arguments, // remind them to type the image file name also if (argc == 1) { fprintf(stderr, " "); exit(1); } // open the image file for reading // - - > fill in code here:

// get the width and height of the image and print values to user // - - > fill in code here:

fprintf(stderr, " width is %d, height is %d ", width, height);

return 0; }

// parese.c file (fill out the code below as needed)

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"

// write parseHeader() function goes here:

//defs.h file #include #include #include

// write prototypes of parseHeader() function here:

~ ~ ~ ~

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions

Question

What is a product/service feasibility analysis?

Answered: 1 week ago