2016-03-10 22:40:48 +01:00
|
|
|
#ifndef MAPNIK_COMPARE_IMAGES_HPP
|
|
|
|
#define MAPNIK_COMPARE_IMAGES_HPP
|
2013-11-15 08:11:21 +01:00
|
|
|
|
2015-01-22 18:39:37 +01:00
|
|
|
#include <mapnik/image.hpp>
|
2013-11-15 08:11:21 +01:00
|
|
|
#include <mapnik/image_util.hpp>
|
|
|
|
#include <mapnik/image_reader.hpp>
|
|
|
|
|
|
|
|
|
|
|
|
namespace benchmark {
|
|
|
|
|
|
|
|
bool compare_images(std::string const& src_fn,std::string const& dest_fn)
|
|
|
|
{
|
|
|
|
std::unique_ptr<mapnik::image_reader> reader1(mapnik::get_image_reader(dest_fn,"png"));
|
|
|
|
if (!reader1.get())
|
|
|
|
{
|
|
|
|
throw mapnik::image_reader_exception("Failed to load: " + dest_fn);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<mapnik::image_reader> reader2(mapnik::get_image_reader(src_fn,"png"));
|
|
|
|
if (!reader2.get())
|
|
|
|
{
|
|
|
|
throw mapnik::image_reader_exception("Failed to load: " + src_fn);
|
|
|
|
}
|
|
|
|
|
2016-03-10 22:40:48 +01:00
|
|
|
const mapnik::image_any desc_any = reader1->read(0,0,reader1->width(), reader1->height());
|
|
|
|
const mapnik::image_any src_any = reader2->read(0,0,reader2->width(), reader2->height());
|
2015-04-29 14:53:46 +02:00
|
|
|
|
2016-03-10 22:40:48 +01:00
|
|
|
mapnik::image_rgba8 const& dest = mapnik::util::get<mapnik::image_rgba8>(desc_any);
|
|
|
|
mapnik::image_rgba8 const& src = mapnik::util::get<mapnik::image_rgba8>(src_any);
|
2013-11-15 08:11:21 +01:00
|
|
|
|
2015-07-02 17:10:27 +02:00
|
|
|
return compare(dest, src, 0, true) == 0;
|
2013-11-15 08:11:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-03-10 22:40:48 +01:00
|
|
|
#endif // MAPNIK_COMPARE_IMAGES_HPP
|