-
Notifications
You must be signed in to change notification settings - Fork 2
/
transmogrify.cpp
68 lines (41 loc) · 1.8 KB
/
transmogrify.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
67
#include "transmogrify.hpp"
#include "algorithms.hpp"
#include "convert.hpp"
#include <Magick++.h>
#include <sstream>
void
transmogrifier::init() {
Magick::InitializeMagick(NULL);
}
void
transmogrifier::streamToStream(const std::istream& inputStream, std::ostream& outStream, const std::string& outputFormat, unsigned iterations) {
std::stringstream ppmStream;
transmogrifier::streamToPixelMap(inputStream, ppmStream);
std::stringstream outputImg;
transmogrifier::penroseChuck(ppmStream, outputImg, iterations);
transmogrifier::pixelMapToStream(ppmStream, outStream, outputFormat);
}
void
transmogrifier::streamToNamedFile(const std::istream& inputStream, const std::string& outputFileName, unsigned iterations) {
std::stringstream ppmStream;
transmogrifier::streamToPixelMap(inputStream, ppmStream);
std::stringstream outputImg;
transmogrifier::penroseChuck(ppmStream, outputImg, iterations);
transmogrifier::pixelMapToNamedFile(ppmStream, outputFileName);
}
void
transmogrifier::namedFileToStream(const std::string& inputFileName, std::ostream& outStream, const std::string& outputFormat, unsigned iterations) {
std::stringstream ppmStream;
transmogrifier::namedFileToPixelMap(inputFileName, ppmStream);
std::stringstream outputImg;
transmogrifier::penroseChuck(ppmStream, outputImg, iterations);
transmogrifier::pixelMapToStream(ppmStream, outStream, outputFormat);
}
void
transmogrifier::namedFileToNamedFile(const std::string& inputFileName, const std::string& outputFileName, unsigned iterations) {
std::stringstream ppmStream;
transmogrifier::namedFileToPixelMap(inputFileName, ppmStream);
std::stringstream outputImg;
transmogrifier::penroseChuck(ppmStream, outputImg, iterations);
transmogrifier::pixelMapToNamedFile(outputImg, outputFileName);
}