summaryrefslogtreecommitdiff
path: root/test/image_test.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-10-21 19:14:58 +0100
committerCarl Hetherington <cth@carlh.net>2014-10-21 19:14:58 +0100
commitcb990adba9c57e5107ef2aa9716cf0a26c1df83d (patch)
treee59571d05db47b6f1070c85331ba351fd2794adf /test/image_test.cc
parent8a19e2b56d3b95a18ae8ac9965eab750c28d30ad (diff)
parent5c8599593ee8b3ef05d5c55c5f0885a2d8bfb9d2 (diff)
Merge master.
Diffstat (limited to 'test/image_test.cc')
-rw-r--r--test/image_test.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/image_test.cc b/test/image_test.cc
index ee4819d6b..44d15a8cb 100644
--- a/test/image_test.cc
+++ b/test/image_test.cc
@@ -181,16 +181,24 @@ read_file (string file)
boost::shared_ptr<Image> image (new Image (PIX_FMT_RGB24, size, true));
+#ifdef DCPOMATIC_IMAGE_MAGICK
using namespace MagickCore;
+#endif
uint8_t* p = image->data()[0];
for (int y = 0; y < size.height; ++y) {
uint8_t* q = p;
for (int x = 0; x < size.width; ++x) {
Magick::Color c = magick_image.pixelColor (x, y);
+#ifdef DCPOMATIC_IMAGE_MAGICK
*q++ = c.redQuantum() * 255 / QuantumRange;
*q++ = c.greenQuantum() * 255 / QuantumRange;
*q++ = c.blueQuantum() * 255 / QuantumRange;
+#else
+ *q++ = c.redQuantum() * 255 / MaxRGB;
+ *q++ = c.greenQuantum() * 255 / MaxRGB;
+ *q++ = c.blueQuantum() * 255 / MaxRGB;
+#endif
}
p += image->stride()[0];
}
@@ -202,14 +210,20 @@ static
void
write_file (shared_ptr<Image> image, string file)
{
+#ifdef DCPOMATIC_IMAGE_MAGICK
using namespace MagickCore;
+#endif
Magick::Image magick_image (Magick::Geometry (image->size().width, image->size().height), Magick::Color (0, 0, 0));
uint8_t*p = image->data()[0];
for (int y = 0; y < image->size().height; ++y) {
uint8_t* q = p;
for (int x = 0; x < image->size().width; ++x) {
+#ifdef DCPOMATIC_IMAGE_MAGICK
Magick::Color c (q[0] * QuantumRange / 256, q[1] * QuantumRange / 256, q[2] * QuantumRange / 256);
+#else
+ Magick::Color c (q[0] * MaxRGB / 256, q[1] * MaxRGB / 256, q[2] * MaxRGB / 256);
+#endif
magick_image.pixelColor (x, y, c);
q += 3;
}