forked from matthewarcus/mmps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
addgrid.cpp
67 lines (57 loc) · 1.83 KB
/
addgrid.cpp
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
// $Revision: 1.1 $
// addgrid.cpp
// (C) 2004 by Matthew Arcus
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "utils.h"
#include "image.h"
#include "transform.h"
const char* usage =
"Usage: %s [-grid x][-gridx x][-gridy x] file\n";
int main(int argc, char* argv[])
{
Image inImage;
char* infilename = NULL;
double gridx = 10.0;
double gridy = 10.0;
Rgb gridcolor(0,0,0);
char *progname = argv[0];
argc--;argv++;
while (argc > 0 && argv[0][0] == '-') {
if (strcmp(argv[0], "-grid") == 0) {
argc--; argv++;
if (argc == 0) { error(usage, progname); };
gridx = strtod(argv[0],NULL);
gridy = gridx;
} else if (strcmp(argv[0], "-gridx") == 0) {
argc--; argv++;
if (argc == 0) { error(usage, progname); };
gridx = strtod(argv[0],NULL);
} else if (strcmp(argv[0], "-gridy") == 0) {
argc--; argv++;
if (argc == 0) { error(usage, progname); };
gridy = strtod(argv[0],NULL);
} else {
error(usage, progname);
}
argc--; argv++;
}
if (argc != 1) {
error(usage, progname);
}
infilename = argv[0];
inImage.Read(infilename, true);
inImage.AddGrid(gridx, gridy, gridcolor);
inImage.Close();
return 0;
}