mapnik/include/mapnik/image_reader.hpp

78 lines
2.3 KiB
C++
Raw Normal View History

2006-03-31 10:32:02 +00:00
/*****************************************************************************
2012-02-01 17:53:35 -08:00
*
2006-03-31 10:32:02 +00:00
* This file is part of Mapnik (c++ mapping toolkit)
2005-06-14 15:06:59 +00:00
*
* Copyright (C) 2011 Artem Pavlenko
2005-06-14 15:06:59 +00:00
*
2006-03-31 10:32:02 +00:00
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
2005-06-14 15:06:59 +00:00
* but WITHOUT ANY WARRANTY; without even the implied warranty of
2006-03-31 10:32:02 +00:00
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
2005-06-14 15:06:59 +00:00
*
2006-03-31 10:32:02 +00:00
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
2005-06-14 15:06:59 +00:00
#ifndef MAPNIK_IMAGE_READER_HPP
#define MAPNIK_IMAGE_READER_HPP
2005-06-14 15:06:59 +00:00
// mapnik
#include <mapnik/image_data.hpp>
#include <mapnik/config.hpp>
2013-04-10 18:15:09 -07:00
#include <mapnik/noncopyable.hpp>
#include <mapnik/factory.hpp>
// boost
#include <boost/optional.hpp>
2007-10-08 18:10:31 +00:00
// stl
#include <stdexcept>
#include <string>
2012-02-01 17:53:35 -08:00
namespace mapnik
2005-06-14 15:06:59 +00:00
{
2009-12-16 20:02:06 +00:00
class image_reader_exception : public std::exception
{
private:
std::string message_;
public:
2012-09-03 10:27:48 -07:00
image_reader_exception(std::string const& message)
2010-06-02 11:03:30 +00:00
: message_(message) {}
2009-12-16 20:02:06 +00:00
~image_reader_exception() throw() {}
2009-12-16 20:02:06 +00:00
virtual const char* what() const throw()
{
2010-06-02 11:03:30 +00:00
return message_.c_str();
2009-12-16 20:02:06 +00:00
}
};
2013-04-10 18:15:09 -07:00
struct MAPNIK_DECL image_reader : private mapnik::noncopyable
2009-12-16 20:02:06 +00:00
{
virtual unsigned width() const=0;
virtual unsigned height() const=0;
virtual bool premultiplied_alpha() const=0;
2009-12-16 20:02:06 +00:00
virtual void read(unsigned x,unsigned y,image_data_32& image)=0;
virtual ~image_reader() {}
};
template <typename...Args>
bool register_image_reader(std::string const& type, image_reader* (* fun)(Args...))
{
return factory<image_reader,std::string, Args...>::instance().register_product(type, fun);
}
2012-09-03 10:27:48 -07:00
MAPNIK_DECL image_reader* get_image_reader(std::string const& file,std::string const& type);
MAPNIK_DECL image_reader* get_image_reader(std::string const& file);
MAPNIK_DECL image_reader* get_image_reader(char const* data, size_t size);
2012-02-01 17:53:35 -08:00
2005-06-14 15:06:59 +00:00
}
#endif // MAPNIK_IMAGE_READER_HPP