Another large set of modifications, finally allow this branch to build. Mostly modifications to the image_util_* files. Different processing based on the image type is now possible, and save_to_stream now could possibly accept grayscale with out breaking existing code.

This commit is contained in:
Blake Thompson 2015-01-08 19:31:14 -05:00
parent 035557450d
commit 094d0ec3e1
12 changed files with 175 additions and 109 deletions

View file

@ -266,20 +266,20 @@ extern template MAPNIK_DECL void save_to_file<image_data_rgba8>(image_data_rgba8
std::string const&); std::string const&);
extern template MAPNIK_DECL void save_to_file<image_view<image_data_rgba8> > (image_view<image_data_rgba8> const&, extern template MAPNIK_DECL void save_to_file<image_view_rgba8> (image_view_rgba8 const&,
std::string const&, std::string const&,
std::string const&, std::string const&,
rgba_palette const&); rgba_palette const&);
extern template MAPNIK_DECL void save_to_file<image_view<image_data_rgba8> > (image_view<image_data_rgba8> const&, extern template MAPNIK_DECL void save_to_file<image_view_rgba8> (image_view_rgba8 const&,
std::string const&, std::string const&,
std::string const&); std::string const&);
extern template MAPNIK_DECL void save_to_file<image_view<image_data_rgba8> > (image_view<image_data_rgba8> const&, extern template MAPNIK_DECL void save_to_file<image_view_rgba8> (image_view_rgba8 const&,
std::string const&, std::string const&,
rgba_palette const&); rgba_palette const&);
extern template MAPNIK_DECL void save_to_file<image_view<image_data_rgba8> > (image_view<image_data_rgba8> const&, extern template MAPNIK_DECL void save_to_file<image_view_rgba8> (image_view_rgba8 const&,
std::string const&); std::string const&);
extern template MAPNIK_DECL std::string save_to_string<image_data_rgba8>(image_data_rgba8 const&, extern template MAPNIK_DECL std::string save_to_string<image_data_rgba8>(image_data_rgba8 const&,
@ -289,10 +289,10 @@ extern template MAPNIK_DECL std::string save_to_string<image_data_rgba8>(image_d
std::string const&, std::string const&,
rgba_palette const&); rgba_palette const&);
extern template MAPNIK_DECL std::string save_to_string<image_view<image_data_rgba8> > (image_view<image_data_rgba8> const&, extern template MAPNIK_DECL std::string save_to_string<image_view_rgba8> (image_view_rgba8 const&,
std::string const&); std::string const&);
extern template MAPNIK_DECL std::string save_to_string<image_view<image_data_rgba8> > (image_view<image_data_rgba8> const&, extern template MAPNIK_DECL std::string save_to_string<image_view_rgba8> (image_view_rgba8 const&,
std::string const&, std::string const&,
rgba_palette const&); rgba_palette const&);
#ifdef _MSC_VER #ifdef _MSC_VER
@ -310,15 +310,15 @@ template MAPNIK_DECL void save_to_stream<image_data_rgba8>(
std::string const& type std::string const& type
); );
template MAPNIK_DECL void save_to_stream<image_view<image_data_rgba8> > ( template MAPNIK_DECL void save_to_stream<image_view_rgba8> (
image_view<image_data_rgba8> const& image, image_view_rgba8 const& image,
std::ostream & stream, std::ostream & stream,
std::string const& type, std::string const& type,
rgba_palette const& palette rgba_palette const& palette
); );
template MAPNIK_DECL void save_to_stream<image_view<image_data_rgba8> > ( template MAPNIK_DECL void save_to_stream<image_view_rgba8> (
image_view<image_data_rgba8> const& image, image_view_rgba8 const& image,
std::ostream & stream, std::ostream & stream,
std::string const& type std::string const& type
); );

View file

@ -23,18 +23,15 @@
#ifndef MAPNIK_IMAGE_UTIL_JPEG_HPP #ifndef MAPNIK_IMAGE_UTIL_JPEG_HPP
#define MAPNIK_IMAGE_UTIL_JPEG_HPP #define MAPNIK_IMAGE_UTIL_JPEG_HPP
// mapnik
#include <mapnik/util/variant.hpp>
// stl // stl
#include <string> #include <string>
#include <iostream> #include <iostream>
namespace mapnik { namespace mapnik {
struct jpeg_saver : public mapnik::util::static_visitor<> struct jpeg_saver
{ {
jpeg_saver(std::ostream &, std::string &); jpeg_saver(std::ostream &, std::string const&);
template <typename T> template <typename T>
void operator() (T const&) const; void operator() (T const&) const;
private: private:

View file

@ -23,18 +23,15 @@
#ifndef MAPNIK_IMAGE_UTIL_PNG_HPP #ifndef MAPNIK_IMAGE_UTIL_PNG_HPP
#define MAPNIK_IMAGE_UTIL_PNG_HPP #define MAPNIK_IMAGE_UTIL_PNG_HPP
// mapnik
#include <mapnik/util/variant.hpp>
// stl // stl
#include <string> #include <string>
#include <iostream> #include <iostream>
namespace mapnik { namespace mapnik {
struct png_saver_pal : public mapnik::util::static_visitor<> struct png_saver_pal
{ {
png_saver_pal(std::ostream &, std::string &, rgba_palette const&); png_saver_pal(std::ostream &, std::string const&, rgba_palette const&);
template <typename T> template <typename T>
void operator() (T const&) const; void operator() (T const&) const;
private: private:
@ -43,9 +40,9 @@ struct png_saver_pal : public mapnik::util::static_visitor<>
rgba_palette const& pal_; rgba_palette const& pal_;
}; };
struct png_saver : public mapnik::util::static_visitor<> struct png_saver
{ {
png_saver(std::ostream &, std::string &); png_saver(std::ostream &, std::string const&);
template <typename T> template <typename T>
void operator() (T const&) const; void operator() (T const&) const;
private: private:

View file

@ -23,18 +23,15 @@
#ifndef MAPNIK_IMAGE_UTIL_TIFF_HPP #ifndef MAPNIK_IMAGE_UTIL_TIFF_HPP
#define MAPNIK_IMAGE_UTIL_TIFF_HPP #define MAPNIK_IMAGE_UTIL_TIFF_HPP
// mapnik
#include <mapnik/util/variant.hpp>
// stl // stl
#include <string> #include <string>
#include <iostream> #include <iostream>
namespace mapnik { namespace mapnik {
struct tiff_saver : public mapnik::util::static_visitor<> struct tiff_saver
{ {
tiff_saver(std::ostream &, std::string &); tiff_saver(std::ostream &, std::string const&);
template <typename T> template <typename T>
void operator() (T const&) const; void operator() (T const&) const;
private: private:

View file

@ -23,18 +23,15 @@
#ifndef MAPNIK_IMAGE_UTIL_WEBP_HPP #ifndef MAPNIK_IMAGE_UTIL_WEBP_HPP
#define MAPNIK_IMAGE_UTIL_WEBP_HPP #define MAPNIK_IMAGE_UTIL_WEBP_HPP
// mapnik
#include <mapnik/util/variant.hpp>
// stl // stl
#include <string> #include <string>
#include <iostream> #include <iostream>
namespace mapnik { namespace mapnik {
struct webp_saver : public mapnik::util::static_visitor<> struct webp_saver
{ {
webp_saver(std::ostream &, std::string &); webp_saver(std::ostream &, std::string const&);
template <typename T> template <typename T>
void operator() (T const&) const; void operator() (T const&) const;
private: private:

View file

@ -607,7 +607,7 @@ void save_as_png8(T1 & file,
mapnik::image_data_gray8::pixel_type * row_out = reduced_image.getRow(y); mapnik::image_data_gray8::pixel_type * row_out = reduced_image.getRow(y);
for (unsigned x = 0; x < width; ++x) for (unsigned x = 0; x < width; ++x)
{ {
row_out[x] = tree->quantize(row[x]); row_out[x] = tree.quantize(row[x]);
} }
} }
save_as_png(file, palette, reduced_image, width, height, 8, alphaTable, opts); save_as_png(file, palette, reduced_image, width, height, 8, alphaTable, opts);
@ -635,7 +635,7 @@ void save_as_png8(T1 & file,
for (unsigned x = 0; x < width; ++x) for (unsigned x = 0; x < width; ++x)
{ {
index = tree->quantize(row[x]); index = tree.quantize(row[x]);
if (x%2 == 0) if (x%2 == 0)
{ {
index = index<<4; index = index<<4;

View file

@ -174,6 +174,10 @@ source = Split(
parse_path.cpp parse_path.cpp
image_reader.cpp image_reader.cpp
image_util.cpp image_util.cpp
image_util_jpeg.cpp
image_util_png.cpp
image_util_tiff.cpp
image_util_webp.cpp
layer.cpp layer.cpp
map.cpp map.cpp
load_map.cpp load_map.cpp

View file

@ -110,8 +110,8 @@ void save_to_file(T const& image,
else throw ImageWriterException("Could not write file to " + filename ); else throw ImageWriterException("Could not write file to " + filename );
} }
template <> template <typename T>
void save_to_stream<image_data_any>(image_data_any const& image, void save_to_stream(T const& image,
std::ostream & stream, std::ostream & stream,
std::string const& type, std::string const& type,
rgba_palette const& palette) rgba_palette const& palette)
@ -122,7 +122,9 @@ void save_to_stream<image_data_any>(image_data_any const& image,
std::transform(t.begin(), t.end(), t.begin(), ::tolower); std::transform(t.begin(), t.end(), t.begin(), ::tolower);
if (t == "png" || boost::algorithm::starts_with(t, "png")) if (t == "png" || boost::algorithm::starts_with(t, "png"))
{ {
mapnik::util::apply_visitor(png_saver_pal(stream, t, palette), image); png_saver_pal visitor(stream, t, palette);
visitor(image);
//mapnik::util::apply_visitor(visitor, image);
} }
else if (boost::algorithm::starts_with(t, "tif")) else if (boost::algorithm::starts_with(t, "tif"))
{ {
@ -137,7 +139,8 @@ void save_to_stream<image_data_any>(image_data_any const& image,
else throw ImageWriterException("Could not write to empty stream" ); else throw ImageWriterException("Could not write to empty stream" );
} }
void save_to_stream(image_data_any const& image, template <typename T>
void save_to_stream(T const& image,
std::ostream & stream, std::ostream & stream,
std::string const& type) std::string const& type)
{ {
@ -147,19 +150,27 @@ void save_to_stream(image_data_any const& image,
std::transform(t.begin(), t.end(), t.begin(), ::tolower); std::transform(t.begin(), t.end(), t.begin(), ::tolower);
if (t == "png" || boost::algorithm::starts_with(t, "png")) if (t == "png" || boost::algorithm::starts_with(t, "png"))
{ {
util::apply_visitor(png_saver(stream, t), image); png_saver visitor(stream, t);
visitor(image);
//util::apply_visitor(visitor, image);
} }
else if (boost::algorithm::starts_with(t, "tif")) else if (boost::algorithm::starts_with(t, "tif"))
{ {
util::apply_visitor(tiff_saver(stream, t), image); tiff_saver visitor(stream, t);
visitor(image);
//util::apply_visitor(visitor, image);
} }
else if (boost::algorithm::starts_with(t, "jpeg")) else if (boost::algorithm::starts_with(t, "jpeg"))
{ {
util::apply_visitor(jpeg_saver(stream, t), image); jpeg_saver visitor(stream, t);
visitor(image);
//util::apply_visitor(visitor, image);
} }
else if (boost::algorithm::starts_with(t, "webp")) else if (boost::algorithm::starts_with(t, "webp"))
{ {
util::apply_visitor(webp_saver(stream, t), image); webp_saver visitor(stream, t);
visitor(image);
//util::apply_visitor(visitor, image);
} }
else throw ImageWriterException("unknown file type: " + type); else throw ImageWriterException("unknown file type: " + type);
} }

View file

@ -25,8 +25,12 @@
#include <mapnik/jpeg_io.hpp> #include <mapnik/jpeg_io.hpp>
#endif #endif
#include <mapnik/image_util.hpp>
#include <mapnik/image_util_jpeg.hpp> #include <mapnik/image_util_jpeg.hpp>
#include <mapnik/image_data.hpp> #include <mapnik/image_data.hpp>
#include <mapnik/image_data_any.hpp>
#include <mapnik/image_view.hpp>
#include <mapnik/util/conversions.hpp>
// boost // boost
#include <boost/tokenizer.hpp> #include <boost/tokenizer.hpp>
@ -41,13 +45,8 @@ namespace mapnik
jpeg_saver::jpeg_saver(std::ostream & stream, std::string const& t): jpeg_saver::jpeg_saver(std::ostream & stream, std::string const& t):
stream_(stream), t_(t) {} stream_(stream), t_(t) {}
void jpeg_saver::operator() (image_data_null const& image) const
{
throw ImageWriterException("null images not supported");
}
template <typename T> template <typename T>
void jpeg_saver::operator() (T const& image) const void process_rgba8_jpeg(T const& image, std::string const& t, std::ostream & stream)
{ {
#if defined(HAVE_JPEG) #if defined(HAVE_JPEG)
int quality = 85; int quality = 85;
@ -65,13 +64,29 @@ void jpeg_saver::operator() (T const& image) const
#endif #endif
} }
template void jpeg_saver::operator()<image_data_rgba8> (image_data_rgba8 const& image) const; template<>
template void jpeg_saver::operator()<image_data_gray8> (image_data_gray8 const& image) const; void jpeg_saver::operator()<image_data_rgba8> (image_data_rgba8 const& image) const
template void jpeg_saver::operator()<image_data_gray16> (image_data_gray16 const& image) const; {
template void jpeg_saver::operator()<image_data_gray32f> (image_data_gray32f const& image) const; process_rgba8_jpeg(image, t_, stream_);
template void jpeg_saver::operator()<image_view<image_data_rgba8>> (image_view<image_data_rgba8> const& image) const; }
template void jpeg_saver::operator()<image_view<image_data_gray8>> (image_view<image_data_gray8> const& image) const;
template void jpeg_saver::operator()<image_view<image_data_gray16>> (image_view<image_data_gray16> const& image) const; template<>
template void jpeg_saver::operator()<image_view<image_data_gray32f>> (image_view<image_data_gray32f> const& image) const; void jpeg_saver::operator()<image_view_rgba8> (image_view_rgba8 const& image) const
{
process_rgba8_jpeg(image, t_, stream_);
}
template <typename T>
void jpeg_saver::operator() (T const& image) const
{
throw ImageWriterException("Mapnik does not support jpeg grayscale images");
}
template void jpeg_saver::operator() (image_data_gray8 const& image) const;
template void jpeg_saver::operator() (image_data_gray16 const& image) const;
template void jpeg_saver::operator() (image_data_gray32f const& image) const;
template void jpeg_saver::operator() (image_view_gray8 const& image) const;
template void jpeg_saver::operator() (image_view_gray16 const& image) const;
template void jpeg_saver::operator() (image_view_gray32f const& image) const;
} // end ns } // end ns

View file

@ -32,8 +32,12 @@ extern "C"
#include <mapnik/png_io.hpp> #include <mapnik/png_io.hpp>
#endif #endif
#include <mapnik/image_util.hpp>
#include <mapnik/image_util_png.hpp> #include <mapnik/image_util_png.hpp>
#include <mapnik/image_data.hpp> #include <mapnik/image_data.hpp>
#include <mapnik/image_data_any.hpp>
#include <mapnik/image_view.hpp>
#include <mapnik/util/conversions.hpp>
// boost // boost
#include <boost/tokenizer.hpp> #include <boost/tokenizer.hpp>
@ -179,37 +183,47 @@ png_saver::png_saver(std::ostream & stream, std::string const& t):
png_saver_pal::png_saver_pal(std::ostream & stream, std::string const& t, rgba_palette const& pal): png_saver_pal::png_saver_pal(std::ostream & stream, std::string const& t, rgba_palette const& pal):
stream_(stream), t_(t), pal_(pal) {} stream_(stream), t_(t), pal_(pal) {}
void png_saver::operator() (image_data_null const& image) const template<>
void png_saver::operator()<image_data_null> (image_data_null const& image) const
{ {
throw ImageWriterException("null images not supported"); throw ImageWriterException("null images not supported for png");
}
template<>
void png_saver_pal::operator()<image_data_null> (image_data_null const& image) const
{
throw ImageWriterException("null images not supported for png");
} }
template <typename T> template <typename T>
void process_rgb8_png_pal(T const& image) void process_rgba8_png_pal(T const& image,
std::string const& t,
std::ostream & stream,
rgba_palette const& pal)
{ {
#if defined(HAVE_PNG) #if defined(HAVE_PNG)
png_options opts; png_options opts;
handle_png_options(t_, opts); handle_png_options(t, opts);
if (pal_ && pal_->valid()) if (pal.valid())
{ {
png_options opts; png_options opts;
handle_png_options(t,opts); handle_png_options(t,opts);
save_as_png8_pal(stream, image, pal_, opts); save_as_png8_pal(stream, image, pal, opts);
} }
else if (opts.paletted) else if (opts.paletted)
{ {
if (opts.use_hextree) if (opts.use_hextree)
{ {
save_as_png8_hex(stream_, image, opts); save_as_png8_hex(stream, image, opts);
} }
else else
{ {
save_as_png8_oct(stream_, image, opts); save_as_png8_oct(stream, image, opts);
} }
} }
else else
{ {
save_as_png(stream_, image, opts); save_as_png(stream, image, opts);
} }
#else #else
throw ImageWriterException("png output is not enabled in your build of Mapnik"); throw ImageWriterException("png output is not enabled in your build of Mapnik");
@ -217,87 +231,94 @@ void process_rgb8_png_pal(T const& image)
} }
template <typename T> template <typename T>
void process_rgb8_png(T const& image) void process_rgba8_png(T const& image,
std::string const& t,
std::ostream & stream)
{ {
#if defined(HAVE_PNG) #if defined(HAVE_PNG)
png_options opts; png_options opts;
handle_png_options(t_, opts); handle_png_options(t, opts);
if (opts.paletted) if (opts.paletted)
{ {
if (opts.use_hextree) if (opts.use_hextree)
{ {
save_as_png8_hex(stream_, image, opts); save_as_png8_hex(stream, image, opts);
} }
else else
{ {
save_as_png8_oct(stream_, image, opts); save_as_png8_oct(stream, image, opts);
} }
} }
else else
{ {
save_as_png(stream_, image, opts); save_as_png(stream, image, opts);
} }
#else #else
throw ImageWriterException("png output is not enabled in your build of Mapnik"); throw ImageWriterException("png output is not enabled in your build of Mapnik");
#endif #endif
} }
void png_saver_pal::operator() (image_data_rgba8 const& image) const template<>
void png_saver_pal::operator()<image_data_rgba8> (image_data_rgba8 const& image) const
{ {
process_rgb8_png(image); process_rgba8_png_pal(image, t_, stream_, pal_);
} }
void png_saver_pal::operator() (image_view<image_data_rgba8> const& image) const template<>
void png_saver_pal::operator()<image_view_rgba8> (image_view_rgba8 const& image) const
{ {
process_rgb8_png(image); process_rgba8_png_pal(image, t_, stream_, pal_);
} }
void png_saver::operator() (image_data_rgba8 const& image) const template<>
void png_saver::operator()<image_data_rgba8> (image_data_rgba8 const& image) const
{ {
process_rgb8_png(image); process_rgba8_png(image, t_, stream_);
} }
void png_saver::operator() (image_view<image_data_rgba8> const& image) const template<>
void png_saver::operator()<image_view_rgba8> (image_view_rgba8 const& image) const
{ {
process_rgb8_png(image); process_rgba8_png(image, t_, stream_);
} }
template <typename T> template <typename T>
void png_saver::operator() (T const& image) const void png_saver::operator() (T const& image) const
{ {
#if defined(HAVE_PNG) #if defined(HAVE_PNG)
png_options opts; throw ImageWriterException("Mapnik does not support grayscale images for png");
handle_png_options(t_, opts); //png_options opts;
save_as_png(stream_, image, opts); //handle_png_options(t_, opts);
//save_as_png(stream_, image, opts);
#else #else
throw ImageWriterException("png output is not enabled in your build of Mapnik"); throw ImageWriterException("png output is not enabled in your build of Mapnik");
#endif #endif
} }
template void png_saver::operator()<image_data_gray8> (image_data_gray8 const& image) const;
template void png_saver::operator()<image_data_gray16> (image_data_gray16 const& image) const;
template void png_saver::operator()<image_data_gray32f> (image_data_gray32f const& image) const;
template void png_saver::operator()<image_view<image_data_gray8>> (image_view<image_data_gray8> const& image) const;
template void png_saver::operator()<image_view<image_data_gray16>> (image_view<image_data_gray16> const& image) const;
template void png_saver::operator()<image_view<image_data_gray32f>> (image_view<image_data_gray32f> const& image) const;
template <typename T> template <typename T>
void png_saver_pal::operator() (T const& image) const void png_saver_pal::operator() (T const& image) const
{ {
#if defined(HAVE_PNG) #if defined(HAVE_PNG)
png_options opts; throw ImageWriterException("Mapnik does not support grayscale images for png");
handle_png_options(t_, opts); //png_options opts;
save_as_png(stream_, image, opts); //handle_png_options(t_, opts);
//save_as_png(stream_, image, opts);
#else #else
throw ImageWriterException("png output is not enabled in your build of Mapnik"); throw ImageWriterException("png output is not enabled in your build of Mapnik");
#endif #endif
} }
template void png_saver_pal::operator()<image_data_gray8> (image_data_gray8 const& image) const; template void png_saver::operator() (image_data_gray8 const& image) const;
template void png_saver_pal::operator()<image_data_gray16> (image_data_gray16 const& image) const; template void png_saver::operator() (image_data_gray16 const& image) const;
template void png_saver_pal::operator()<image_data_gray32f> (image_data_gray32f const& image) const; template void png_saver::operator() (image_data_gray32f const& image) const;
template void png_saver_pal::operator()<image_view<image_data_gray8>> (image_view<image_data_gray8> const& image) const; template void png_saver::operator() (image_view_gray8 const& image) const;
template void png_saver_pal::operator()<image_view<image_data_gray16>> (image_view<image_data_gray16> const& image) const; template void png_saver::operator() (image_view_gray16 const& image) const;
template void png_saver_pal::operator()<image_view<image_data_gray32f>> (image_view<image_data_gray32f> const& image) const; template void png_saver::operator() (image_view_gray32f const& image) const;
template void png_saver_pal::operator() (image_data_gray8 const& image) const;
template void png_saver_pal::operator() (image_data_gray16 const& image) const;
template void png_saver_pal::operator() (image_data_gray32f const& image) const;
template void png_saver_pal::operator() (image_view_gray8 const& image) const;
template void png_saver_pal::operator() (image_view_gray16 const& image) const;
template void png_saver_pal::operator() (image_view_gray32f const& image) const;
} // end ns } // end ns

View file

@ -25,8 +25,12 @@
#include <mapnik/tiff_io.hpp> #include <mapnik/tiff_io.hpp>
#endif #endif
#include <mapnik/image_util.hpp>
#include <mapnik/image_util_tiff.hpp> #include <mapnik/image_util_tiff.hpp>
#include <mapnik/image_data.hpp> #include <mapnik/image_data.hpp>
#include <mapnik/image_data_any.hpp>
#include <mapnik/image_view.hpp>
#include <mapnik/util/conversions.hpp>
// boost // boost
#include <boost/tokenizer.hpp> #include <boost/tokenizer.hpp>
@ -161,8 +165,8 @@ void handle_tiff_options(std::string const& type,
tiff_saver::tiff_saver(std::ostream & stream, std::string const& t): tiff_saver::tiff_saver(std::ostream & stream, std::string const& t):
stream_(stream), t_(t) {} stream_(stream), t_(t) {}
template<>
void tiff_saver::operator() (image_data_null const& image) const void tiff_saver::operator()<image_data_null> (image_data_null const& image) const
{ {
throw ImageWriterException("null images not supported"); throw ImageWriterException("null images not supported");
} }
@ -179,13 +183,13 @@ void tiff_saver::operator() (T const& image) const
#endif #endif
} }
template void tiff_saver::operator()<image_data_rgba8> (image_data_rgba8 const& image) const; template void tiff_saver::operator() (image_data_rgba8 const& image) const;
template void tiff_saver::operator()<image_data_gray8> (image_data_gray8 const& image) const; template void tiff_saver::operator() (image_data_gray8 const& image) const;
template void tiff_saver::operator()<image_data_gray16> (image_data_gray16 const& image) const; template void tiff_saver::operator() (image_data_gray16 const& image) const;
template void tiff_saver::operator()<image_data_gray32f> (image_data_gray32f const& image) const; template void tiff_saver::operator() (image_data_gray32f const& image) const;
template void tiff_saver::operator()<image_view<image_data_rgba8>> (image_view<image_data_rgba8> const& image) const; template void tiff_saver::operator() (image_view_rgba8 const& image) const;
template void tiff_saver::operator()<image_view<image_data_gray8>> (image_view<image_data_gray8> const& image) const; template void tiff_saver::operator() (image_view_gray8 const& image) const;
template void tiff_saver::operator()<image_view<image_data_gray16>> (image_view<image_data_gray16> const& image) const; template void tiff_saver::operator() (image_view_gray16 const& image) const;
template void tiff_saver::operator()<image_view<image_data_gray32f>> (image_view<image_data_gray32f> const& image) const; template void tiff_saver::operator() (image_view_gray32f const& image) const;
} // end ns } // end ns

View file

@ -25,8 +25,12 @@
#include <mapnik/webp_io.hpp> #include <mapnik/webp_io.hpp>
#endif #endif
#include <mapnik/image_util.hpp>
#include <mapnik/image_util_webp.hpp> #include <mapnik/image_util_webp.hpp>
#include <mapnik/image_data.hpp> #include <mapnik/image_data.hpp>
#include <mapnik/image_data_any.hpp>
#include <mapnik/image_view.hpp>
#include <mapnik/util/conversions.hpp>
// boost // boost
#include <boost/tokenizer.hpp> #include <boost/tokenizer.hpp>
@ -330,13 +334,14 @@ void handle_webp_options(std::string const& type,
webp_saver::webp_saver(std::ostream & stream, std::string const& t): webp_saver::webp_saver(std::ostream & stream, std::string const& t):
stream_(stream), t_(t) {} stream_(stream), t_(t) {}
void webp_saver::operator() (image_data_null const& image) const template<>
void webp_saver::operator()<image_data_null> (image_data_null const& image) const
{ {
throw ImageWriterException("null images not supported"); throw ImageWriterException("null images not supported");
} }
template <typename T> template <typename T>
void webp_saver::operator() (T const& image) const void process_rgba8_webp(T const& image, std::string const& t, std::ostream & stream)
{ {
#if defined(HAVE_WEBP) #if defined(HAVE_WEBP)
WebPConfig config; WebPConfig config;
@ -354,6 +359,24 @@ void webp_saver::operator() (T const& image) const
#endif #endif
} }
template <>
void webp_saver::operator()<image_data_rgba8> (image_data_rgba8 const& image) const
{
process_rgba8_webp(image, t_, stream_);
}
template <>
void webp_saver::operator()<image_view_rgba8> (image_view_rgba8 const& image) const
{
process_rgba8_webp(image, t_, stream_);
}
template <typename T>
void webp_saver::operator() (T const& image) const
{
throw ImageWriterException("Mapnik does not support webp grayscale images");
}
template void webp_saver::operator()<image_data_rgba8> (image_data_rgba8 const& image) const; template void webp_saver::operator()<image_data_rgba8> (image_data_rgba8 const& image) const;
template void webp_saver::operator()<image_data_gray8> (image_data_gray8 const& image) const; template void webp_saver::operator()<image_data_gray8> (image_data_gray8 const& image) const;
template void webp_saver::operator()<image_data_gray16> (image_data_gray16 const& image) const; template void webp_saver::operator()<image_data_gray16> (image_data_gray16 const& image) const;