|
25 Years of Programming
An open source source for C, C++, OWL, BASIC, MDB, XLS, DOT, and more... |
Home Projects Up Sitemap Search Blog Forum+Chat About Us Privacy Terms of Use Feedback FAQ Images Services Payments Humor Music |
Turn .PIC image file upside down (flip vertical), DeSmet CFor saving images in a semi-portable device-independent bitmap-like format on the Heathkit H-100 computer, I created a graphic format that I called .PIC. This short DeSmet C program reads the scan line data from one .PIC file and writes the lines in reverse order to a second file, turning the image upside down. |
/* upsidown.c 11/23/93
Copyright (C)1993 Steven Whitney.
Initially published by http://25yearsofprogramming.com.
Published under GNU GPL (General Public License) Version 3, with ABSOLUTELY NO WARRANTY.
REWRITES LINES FROM A .PIC FILE IN REVERSE ORDER TO A NEW FILE.
LINE 225 BECOMES LINE 1 IN THE NEW FILE, ETC.,
SO THE IMAGE IS TURNED UPSIDE DOWN.
*/
#include "stdio.h"
main(argc,argv)
int argc;
char **argv;
{
FILE *infile, *outfile;
char buf[640];
unsigned i, j;
int fline;
if(argc != 2)
abort("Usage: UPSIDOWN source (output is UPSIDOWN.PIC)\n");
if(!(infile = fopen(argv[1],"r")))
abort("Input file not found.\n");
outfile = fopen("upsidown.pic","w");
j = 0;
fseek(infile,0L,2); /* find end of file */
for(fline = 0 ; fline < 225 ; fline++)
{
fseek(infile,-640L,1); /* back up 640 bytes */
fread(buf,1,640,infile); /* read the bytes */
fseek(infile,-640L,1); /* back up to where we were */
printf("Line %d of 225\n",++j);
fwrite(buf,1,640,outfile);
}
closeall();
exit(0);
}
|
|
|
|
|
|
|
Copyright ©2011 Steven Whitney. Last modified Tue 05/24/2011 12:29:10 -0700. |
||