Click here to Skip to main content
15,888,908 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an assignment where I have to alter a ppm image and send it to a function in another file to print the new altered version. I'm really new to programming and I don't have much of a clue as to what to do. any help is appreciated!

C#
#include "transform.h"

int print(void){

    FILE *inFile


    inFile = fopen("tiger.ppm", "r");
    if(!inFile){
        fprintf(stderr, "File open error. Exiting program\n");
        exit(1);
    }
}


This is my transform.c file

C#
#include "transform.h"


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

    // declarations here
    FILE *inFile;



    // open input file
    inFile = fopen("tiger.ppm", "r")
    if (inFile == NULL){
        fprintf(stderr,"Output failure. Exiting program\n");
        exit(2);
    }


    // parseHeader function call here
    parseHeader();

    // malloc space for the array (example given in assignment write-up)
    struct pixel * image = (struct pixel *) malloc(sizeof(struct pixel) *       g_width * g_height);


    // parseImage function call here
    parseImage();

    // close input file
    fclose(inFile);


    // manipulate the image according to command-line parameter
    //      1: mirror image
    //      2: upside down image
    //      3: rotate to the right 90 degrees

    if(argv[1]){

        mirror();
    }
    if else(argv[2]){

        flipHorz();
    }
    if else (argv[3]){

        rotate();
    }



    return 0;
}
Posted

1 solution

in your first module you must open, modify and save the pic. At the end of the first module you must call the second module with some API as CreateProcess and use the parameters to give the file name with it, and so the second exe knows what to do.

As workaround you can loop in the second exe for some special-named file, which the first exe has to write.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900