Example #1
0
boost::shared_ptr<image_32> open_from_file(std::string const& filename)
{
    boost::optional<std::string> type = type_from_filename(filename);
    if (type)
    {
        std::auto_ptr<image_reader> reader(get_image_reader(filename,*type));
        if (reader.get())
        {
            boost::shared_ptr<image_32> image_ptr(new image_32(reader->width(),reader->height()));
            reader->read(0,0,image_ptr->data());
            return image_ptr;
        }
        throw mapnik::image_reader_exception("Failed to load: " + filename);  
    }
    throw mapnik::image_reader_exception("Unsupported image format:" + filename);
}