如何将ppm发送到另一个文件中的函数 [英] How do I send a ppm to a function in another file

查看:116
本文介绍了如何将ppm发送到另一个文件中的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一项任务,我必须更改ppm图像并将其发送到另一个文件中的函数以打印新的更改版本。我对编程很陌生,对于该怎么做我没有太多线索。任何帮助表示赞赏!



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!

#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);
    }
}





这是我的transform.c文件





This is my transform.c file

#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;
}

推荐答案

在您的第一个模块中,您必须打开,修改和保存图片。在第一个模块的末尾,您必须使用某个API调用第二个模块 CreateProcess 并使用参数为其提供文件名,因此第二个exe知道该怎么做。



作为解决方法你可以在第二个exe中循环一些特殊命名的文件,第一个exe必须写入。
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.


这篇关于如何将ppm发送到另一个文件中的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆