-
Notifications
You must be signed in to change notification settings - Fork 8
/
spy.cpp
38 lines (33 loc) · 1.01 KB
/
spy.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
#include <Magick++.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cassert>
#include <bitset>
using namespace std;
using namespace Magick;
int main(int argc, char** argv)
{
InitializeMagick(*argv);
if(argc < 4) {
cout << "Usage: " << argv[0] << " X Y image1.png [image2.png ...]\n"
<< "Identifies the color of the specified pixel in each image\n";
exit(1);
}
const int x = atoi(argv[1]);
const int y = atoi(argv[2]);
for(int i = 3; i < argc; i++) {
Image im (argv[i]);
Color c = im.pixelColor(x, y);
cout << setw(20) << argv[i] << ": "
<< setfill('0') << setw(2) << hex << (c.redQuantum() & 0xff)
<< setfill('0') << setw(2) << hex << (c.greenQuantum() & 0xff)
<< setfill('0') << setw(2) << hex << (c.blueQuantum() & 0xff)
<< " ";
bitset<8> r(c.redQuantum());
bitset<8> g(c.greenQuantum());
bitset<8> b(c.blueQuantum());
cout << r << ' ' << g << ' ' << b << '\n';
}
return 0;
}