Question: lab2.c will contain a main method which should: o Require 2 command line arguments to be passed at execution: an input file name and an

 lab2.c will contain a main method which should: o Require 2command line arguments to be passed at execution: an input file name

lab2.c will contain a main method which should:

o Require 2 command line arguments to be passed at execution: an input file name and an output file name. If these arguments are not provided, the program should exit with a status of 1and print some error message.

o Open the input file for reading and the output file for writing. If either fails, return 1and printsome error message.

o Using the functions in ppm_utils, read in the image file creating an image_t* struct

o Using the functions in ppm_utils, write the same image out as a P6 ppm image

o free() the pixel_t* array and the image_t*struct

o close() the open files

o return0

ppm_utils.c should implement all the function defined in ppm_utils.h

including:

o header_t read_header(FILE* image_file);

o void write_header(FILE* out_file, header_t header);

o image_t* read_ppm(FILE* image_file);

o image_t* read_p6(FILE* image_file, header_t header);

o image_t* read_p3(FILE* image_file, header_t header);

o void write_p6(FILE* out_file, image_t* image);

o void write_p3(FILE* out_file, image_t* image);

and an output file name. If these arguments are not provided, the

Need help with the last two files. lab2.c and ppm_utils.c

Thank you!

# include "ppm utils. h" image_t* read_ppm (FILE* image_file) header_t header - read_header (image_file); image-t* image = NULL; if (strcmp("P3", heade r . MAGICNUMBER) 0) { - image readps (imagefile, header); else if (strcmp ("P6", header.MAGIC_NUMBER)0) l image read-p6(image-file, header); - - return image; # include "ppm utils. h" image_t* read_ppm (FILE* image_file) header_t header - read_header (image_file); image-t* image = NULL; if (strcmp("P3", heade r . MAGICNUMBER) 0) { - image readps (imagefile, header); else if (strcmp ("P6", header.MAGIC_NUMBER)0) l image read-p6(image-file, header); - - return image

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!