Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help writing a program to copy a ppm or pgm file. It needs to be written in C. Asg 1: Greyscale and color

image text in transcribed

I need help writing a program to copy a ppm or pgm file. It needs to be written in C.

Asg 1: Greyscale and color image copies Objective Implement basic grayscale and color image structs that you can use to copy (read in/read out) PGM and PPM images. The structs should each be in their own pgm.h and ppm.h header files. Each pgm.h and ppm.h header file should also include function prototypes to allocate, free, read, and write each of the PGM and PPM images. Assignment 1. Create two modules, pgm.c and ppm.c, each with its own header. 2. Handle memory allocation and deallocation by providing these functions: 1. PGM *pgm_alloc(int r, int c); 2. void pgm_free(PGM **ing); 3. PPM ppm_alloc(int r, int c): 4. void ppm_free(PPM **ing); 3. Handle file (image) i'o by providing read and write functions: 1. PGM *pgm_read(const char *file); 2. void pgm_write(PGM *ing, const char *file); 3. PPM *ppr_read(const char *file); 4. void ppr_write(PPM ing, const char *file); 4. Image data members should at least include: o int ptype; // magic number (int part of 'ps' or 'P6') oint w,h; // width, height o int bpp; // bytes per pixel (1 or 3) o int max; // max color (usually 255) o char *name; // file name Image data should be stored as one 1D array: o float *apix; or as three 10 arrays: o float #rpix; o float *gpix; o float *bpix; 5. Write a driver program pgmtest.c to test the PGM module: 1. calling img = pgm.read("mandrill.pg"); 2. calling pgm_write(img,"copy-pg"); 3. calling pgm_free(&img); and similarly for the PPM module: 1. calling img = ppm_read("mandrill.ppn): 2. calling ppm_write(ing, "copy-ppm); 3. calling ppm_free(&img)

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

Advances In Databases And Information Systems Second East European Symposium Adbis 98 Poznan Poland September 1998 Proceedings Lncs 1475

Authors: Witold Litwin ,Tadeusz Morzy ,Gottfried Vossen

1st Edition

3540649247, 978-3540649243

More Books

Students also viewed these Databases questions

Question

Make effective use of recognition to motivate others.

Answered: 1 week ago

Question

1. Explain the 2nd world war. 2. Who is the father of history?

Answered: 1 week ago

Question

2. Outline the business case for a diverse workforce.

Answered: 1 week ago