-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
61 lines (55 loc) · 1.54 KB
/
main.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
#include <iostream>
#include "../ilbmcreator.h"
#include <QImage>
#include <QFile>
#include <Magick++.h>
int main(int argc, char **argv) {
QImage img;
IlbmCreator ilmb_creator;
if (argc != 4)
{
std::cout << "Invalid argument count" << std::endl;
return -1;
}
int width = atoi(argv[2]);
int height = atoi(argv[3]);
bool result = ilmb_creator.create(argv[1], width, height, img);
if (!result)
{
std::cout << "Error creating thumbnail" << std::endl;
return -1;
}
QFile out_file("test.png");
out_file.open(QIODevice::WriteOnly);
img.save(&out_file,"PNG");
out_file.close();
/* Test image size */
Magick::Image image;
image.read("test.png");
Magick::Geometry imgsize = image.size();
if (width > 200 && height > 144)
{
if (imgsize.width() != 200 && imgsize.height() != 144)
{
std::cout << "Expected 200x144, got " << imgsize.width() << "x" << imgsize.height() << std::endl;
return -1;
}
}
else
{
if (imgsize.width() != width && imgsize.height() != (height * 23 / 32))
{
std::cout << "Expected 200x144, got " << imgsize.width() << "x" << imgsize.height() << std::endl;
return -1;
}
}
std::cout << "Result is " << imgsize.width() << "x" << imgsize.height() << std::endl;
/* Test we are blue */
Magick::ColorRGB col = image.pixelColor(0, 0);
if (col.red() > 0.01 && col.green() > 0.01 && col.blue() < 0.95)
{
std::cout << "Unexpectied color: " << col.red() << "," << col.green() << "," << col.blue() << std::endl;
return -1;
}
return 0;
}