Created
April 11, 2013 00:09
-
-
Save springmeyer/5359567 to your computer and use it in GitHub Desktop.
image reader test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <mapnik/image_reader.hpp> | |
#include <mapnik/image_util.hpp> | |
#include <mapnik/graphics.hpp> | |
#include <mapnik/noncopyable.hpp> | |
#include <boost/shared_ptr.hpp> | |
#include <boost/make_shared.hpp> | |
/* | |
clang++ -o image-reader-test image-reader-test.cpp `mapnik-config --cxxflags --defines --includes --libs --ldflags --dep-libs` | |
*/ | |
int main( int, char*[] ) | |
{ | |
try | |
{ | |
std::string dest_fn = "./mapnik/tests/data/images/dummy.png"; | |
std::auto_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(dest_fn,"png")); | |
if (!reader.get()) | |
{ | |
throw mapnik::image_reader_exception("Failed to load: " + dest_fn); | |
} | |
boost::shared_ptr<mapnik::image_32> image_ptr1 = boost::make_shared<mapnik::image_32>(reader->width(),reader->height()); | |
reader->read(0,0,image_ptr1->data()); | |
std::clog << "works if you see this: " << image_ptr1->width() << "\n"; | |
} | |
catch (std::exception const & ex) | |
{ | |
std::clog << "C++ image i/o problem: " << ex.what() << "\n"; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment