/* * Dump2MTV.C - Converts DKB/QRT Dump 24-bit output file to MTV/Rayshade format * * Written by Ville Saari * * Copyright (c) 1991 Ferry Island Pixelboys. * All rights reserved. * * Created 27-Dec-90 * Updated 31-jan-90 * * Updated 26-Apr-91 V. 1.10 - Aaron A. Collins - made somewhat more portable, * and made the program read and write files instead of stdin and stdout. */ #include #include #define BUFSIZE 32767L FILE *infile, *outfile; void error(char *text, int code) { if(code) fprintf(stderr,"Dump2MTV: "); fprintf(stderr,text); if(infile != NULL) fclose(infile); if(outfile != NULL) { fflush(outfile); fclose(outfile); } exit(code); } int main(int argc, char *argv[]) { char *buffer; long bufptr, width, height, f, n; char *c; fprintf(stderr,"DUMP2MTV V1.10 by Ville Saari.\n" "Copyright (c) 1990 Ferry Island Pixelboys.\n" "Freeware.\n\n"); if(argc != 3) error("Usage: Dump2MTV inputfile outputfile\n", 0); if((infile = fopen(argv[1], "rb")) == NULL) error("Can't open input file.\n", 1); if((outfile = fopen(argv[2], "wb")) == NULL) error("Can't create output file.\n", 1); if((buffer=malloc((unsigned int)BUFSIZE)) == NULL) error("Can't allocate memory for buffer.\n", 103); if(!fread(buffer, 4, 1, infile)) error("Can't read DKB/QRT Dump header.\n", 20); width =(unsigned char)buffer[0]; width |=((unsigned char)buffer[1]<<8); height = (unsigned char)buffer[2]; height |= ((unsigned char)buffer[3]<<8); fprintf(stderr,"Picture size: %d x %d.\n Processing line ",width,height); fprintf(outfile, "%d %d\n", width, height); bufptr=0; for(f=0; fBUFSIZE || f>=height-1) { if(!fwrite(buffer, (unsigned int)bufptr, 1, outfile)) error("Error in writing MTV/Rayshade file.\n", 20); bufptr=0; } } fprintf(stderr,"\n"); return(0); }