Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/ARToolKitPlus/tools/MirrorPatt/src/main.cpp
blob: f05ea77f88633bd67144802ceb9ebcf326ca7781 (plain)
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


//
//
//  This tool will read ARToolKit pattern files (size 16x16) and save
//  them mirrored in y-direction.
//
//  Usage: MirrorPatt [infilename] [outfilename]
//
//

#include <stdio.h>
#include <assert.h>



void
readLine(FILE* fp, char* line)
{
	*line++ = fgetc(fp);

	while(line[-1] != '\n')
		*line++ = fgetc(fp);

	*line++ = 0;
}


void mirrorMarkerFile(const char* nInName, const char* nOutName, int nMarkerWidth, int nMarkerHeight)
{
	FILE	*finp = fopen(nInName, "r"),
			*foutp = fopen(nOutName, "w");

	if(!finp)
		return;

	const int strMax = 256, numPix = nMarkerWidth*nMarkerHeight;
	char str[32][strMax+1];
	int y,channel,rot;

	for(rot=0; rot<4; rot++)
	{
		for(channel=0; channel<3; channel++)
		{
			for(y=0; y<nMarkerHeight; y++)
			{
				readLine(finp, str[y]);
			}

			for(y=0; y<nMarkerHeight; y++)
			{
				fprintf(foutp, "%s", str[nMarkerHeight-1-y]);
//				fprintf(foutp, "%s", str[y]);
			}
		}

		readLine(finp, str[0]);
		fprintf(foutp, "\n");
	}

	fclose(finp);
	fclose(finp);
}


int main(int argc, char** argv)
{
	if(argc<3)
	{
		printf("ERROR: to few parameters\n");
		return -1;
	}

	const char	*inName = argv[1],
				*outName = argv[2];

	mirrorMarkerFile(inName, outName, 16,16);
	return 0;
}