1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
| #include <stdio.h>
#include <stdlib.h>
#include <string.h>
/********Constant**************/
#define TAILLE_MAX 20
/*******Struct_1***************/
typedef struct
{
char InpName[TAILLE_MAX];
char OutName[TAILLE_MAX];
int cpt;
char tabImage[2000];
} Image;
/*********Prototypes***********/
void InpOutFile(Image *Im1);
char * saisir_chaine(char * lpBuffer, int buf_size);
void cptChar(Image *Im2);
void CopyFile(Image *Im3);
void StockMemory(Image *Im3);
int main()
{
char choix[6]="";
Image Im;
for(;;)
{
printf("PANORAMA(7)\n\n");
printf("NAME\n");
printf(" panorama - automatically create panoramas \n\n");
printf("SYNOPSIS\n");
printf(" panorama [OPTION]...\n\n");
printf("DESCRIPTION\n");
printf(" Image manipulation helper to create panoram\n\n");
printf("USAGE \n");
printf(" Usage : panorama [OPTION...]\n\n");
printf(" Help options\n");
printf(" -?, --help Shows this help message\n");
printf(" General Options\n");
printf(" -g Convert the input file(s) to grayscale\n");
printf(" -h Extract the histogram from the input file(s)\n");
printf(" -e Erode the input file(s)\n");
printf(" -d Dilate the input file(s)\n");
printf(" -b threshold Render a black-white image using the giving threshold \n");
printf(" -c file Apply a convolution on the input file(s) using the \n given file as the convolution matrix\n");
printf(" -p Render the panorama from the input file(s)\n");
printf(" Working on single file\n");
printf(" -i file Define the input file\n");
printf(" -o file Define the output file\n");
printf(" Using multiple files\n");
printf(" -li file1,file2,...,filen Define a set of files as the input\n");
printf(" -lo file1,file2,...,filen Define a set of files as the output\n");
printf(" -exit Exit\n");
scanf("%s",choix);
if(strcmp(choix,"-?") ==0)
printf("need help ?");
else if(strcmp(choix,"--help")==0)
printf("need mega help ?");
else if(strcmp(choix,"-g")==0)
printf("work in progress ...");
else if(strcmp(choix,"-h")==0)
printf("work in progress ...");
else if(strcmp(choix,"-e")==0)
printf("work in progress ...");
else if(strcmp(choix,"-d")==0)
printf("work in progress ...");
else if(strcmp(choix,"-b")==0)
printf("work in progress ...");
else if(strcmp(choix,"-c")==0)
printf("work in progress ...");
else if(strcmp(choix,"-p")==0)
printf("work in progress ...");
else if(strcmp(choix,"-i")==0)
{
InpOutFile(&Im);
}
else if(strcmp(choix,"-o")==0)
{
}
else if(strcmp(choix,"-li")==0)
printf("work in progress ...");
else if(strcmp(choix,"-lo")==0)
printf("work in progress ...");
else if(strcmp(choix,"-exit")==0)
exit (0);
fflush(stdin);// On vide le buffer clavier
}
}
/******Function***************/
void InpOutFile(Image *Im1)
{
FILE *pictureI=NULL;
FILE *pictureO=NULL;
printf("Ce programme permet de copier un fichier.\n");
printf("source : ");
saisir_chaine(Im1->InpName, sizeof(Im1->InpName));
pictureI= fopen(Im1->InpName,"rb");
if(pictureI== NULL)
perror(Im1->InpName);
printf("dest : ");
saisir_chaine(Im1->OutName, sizeof(Im1->OutName));
if (strcmp(Im1->InpName, Im1->OutName) == 0)
printf("La source ne peut pas etre en meme temps la destination.\n");
else
{
pictureO = fopen(Im1->OutName,"wb");
if (pictureO == NULL)
perror(Im1->OutName);
}
close(pictureI);
close(pictureO);
}
char * saisir_chaine(char * lpBuffer, int buf_size)
{
char * ret = fgets(lpBuffer, buf_size, stdin);
if (ret != NULL)
{
char * p = strchr(lpBuffer, '\n');
if (p != NULL)
*p = '\0';
else
{
int c;
do
c = getchar();
while (c != EOF && c != '\n');
}
}
return ret;
} |
Partager