-
saving a file
This might sound complicated but PLEASE bear with me!
What I am doing is giving the user the choice to save a file in a number of ways...
if (Select==1)
BasicSaveStructure(), SaveNormal();
else if (Select==2)
BasicSaveStructure(), Save90();
else if (Select==3)
BasicSaveStructure(), Save180();
else if (Select==4)
BasicSaveStructure(), Save270();
else if (Select==5)
BasicSaveStructure(), SaveInvert();
else if (Select==6)
BasicSaveStructure(), SaveInvert90();
else if (Select==7)
BasicSaveStructure(), SaveInvert180();
else if (Select==8)
BasicSaveStructure(), SaveInvert270();
else if (Select==9)
main();
ie. what the user selects then it will go to that particular section. All options to go the first section which deals with the basic of saving a file...
printf("Please enter the name of the file to save your image: ");
gets(Filename);
OutputFile=fopen(Filename, "w");
if (OutputFile==NULL)
{
printf("Cannot save file of that name\n");
printf("The program will now end\n");
GetInteger();
exit(1);
}
printf("\nImage file has been successfully saved\n");
printf("Press any key to return to the main menu\n");
GetInteger();
after that i need to go to the corresponding function to save the file in the way the user wants it. What I don't know is how to run the contents of a function and save it at the same time. I have included one of the functions that I am using in my program...
void Rotate90(void)
{
clrscr();
for (i=0;i<ROWS;i++)
for (j=0;j<COLS;j++)
Picture2[COLS-1-j][i]=Picture[i][j];
}
but i don't know how to call that function and perform the save section at the same time.
***THANK YOU SO MUCH FOR ANY HELP ON THIS SUBJECT***
-
Why don't you make any changes on the image and then have an option to save it? That way you only have to code the saving routine once and have options to actually change the image and then another option to save it as it is with the current changes.
-
Yes, convert the image in memory prior to writing it to disk. That way you can use one file writing function and a simple algorithm to alter or rotate the data. Since the data has already been changed to meet your needs, when the file writing function writes the file it will be written as it is in memory. Much simpler.
What's this for? More info would be helpful.