main.cpp
Go to the documentation of this file.
00001 
00002 
00003 //
00004 //
00005 //  This tool will read ARToolKit pattern files (size 16x16) and save
00006 //  them mirrored in y-direction.
00007 //
00008 //  Usage: MirrorPatt [infilename] [outfilename]
00009 //
00010 //
00011 
00012 #include <stdio.h>
00013 #include <assert.h>
00014 
00015 
00016 
00017 void
00018 readLine(FILE* fp, char* line)
00019 {
00020         *line++ = fgetc(fp);
00021 
00022         while(line[-1] != '\n')
00023                 *line++ = fgetc(fp);
00024 
00025         *line++ = 0;
00026 }
00027 
00028 
00029 void mirrorMarkerFile(const char* nInName, const char* nOutName, int nMarkerWidth, int nMarkerHeight)
00030 {
00031         FILE    *finp = fopen(nInName, "r"),
00032                         *foutp = fopen(nOutName, "w");
00033 
00034         if(!finp)
00035                 return;
00036 
00037         const int strMax = 256, numPix = nMarkerWidth*nMarkerHeight;
00038         char str[32][strMax+1];
00039         int y,channel,rot;
00040 
00041         for(rot=0; rot<4; rot++)
00042         {
00043                 for(channel=0; channel<3; channel++)
00044                 {
00045                         for(y=0; y<nMarkerHeight; y++)
00046                         {
00047                                 readLine(finp, str[y]);
00048                         }
00049 
00050                         for(y=0; y<nMarkerHeight; y++)
00051                         {
00052                                 fprintf(foutp, "%s", str[nMarkerHeight-1-y]);
00053 //                              fprintf(foutp, "%s", str[y]);
00054                         }
00055                 }
00056 
00057                 readLine(finp, str[0]);
00058                 fprintf(foutp, "\n");
00059         }
00060 
00061         fclose(finp);
00062         fclose(finp);
00063 }
00064 
00065 
00066 int main(int argc, char** argv)
00067 {
00068         if(argc<3)
00069         {
00070                 printf("ERROR: to few parameters\n");
00071                 return -1;
00072         }
00073 
00074         const char      *inName = argv[1],
00075                                 *outName = argv[2];
00076 
00077         mirrorMarkerFile(inName, outName, 16,16);
00078         return 0;
00079 }


tuw_artoolkitplus
Author(s): Markus Bader
autogenerated on Sun May 29 2016 02:50:12