2010-06-03 23:24:58 +02:00
|
|
|
/*****************************************************************************
|
2012-02-02 02:53:35 +01:00
|
|
|
*
|
2010-06-03 23:24:58 +02:00
|
|
|
* This file is part of Mapnik (c++ mapping toolkit)
|
|
|
|
*
|
2024-07-22 11:20:47 +02:00
|
|
|
* Copyright (C) 2024 Artem Pavlenko
|
2010-06-03 23:24:58 +02: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,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
// mapnik
|
|
|
|
#include <mapnik/image_reader.hpp>
|
2016-06-22 18:21:25 +02:00
|
|
|
#include <mapnik/util/char_array_buffer.hpp>
|
2010-06-03 23:24:58 +02:00
|
|
|
#include <mapnik/color.hpp>
|
|
|
|
|
|
|
|
// jpeg
|
2022-08-17 17:22:07 +02:00
|
|
|
extern "C" {
|
2010-06-03 23:24:58 +02:00
|
|
|
#include <jpeglib.h>
|
|
|
|
}
|
|
|
|
|
2011-11-08 19:34:00 +01:00
|
|
|
// std
|
|
|
|
#include <cstdio>
|
2013-09-20 16:01:58 +02:00
|
|
|
#include <memory>
|
2016-06-22 18:21:25 +02:00
|
|
|
#include <fstream>
|
2010-06-04 00:43:25 +02:00
|
|
|
|
2022-01-26 10:43:31 +01:00
|
|
|
namespace mapnik {
|
2013-04-12 13:46:40 +02:00
|
|
|
|
2022-01-26 10:43:31 +01:00
|
|
|
template<typename T>
|
2013-04-09 12:34:20 +02:00
|
|
|
class jpeg_reader : public image_reader
|
2012-02-02 02:53:35 +01:00
|
|
|
{
|
2022-01-26 10:43:31 +01:00
|
|
|
public:
|
2014-07-07 19:23:15 +02:00
|
|
|
using source_type = T;
|
2016-06-22 18:21:25 +02:00
|
|
|
using input_stream = std::iostream;
|
2013-04-12 13:46:40 +02:00
|
|
|
const static unsigned BUF_SIZE = 4096;
|
2022-01-26 10:43:31 +01:00
|
|
|
|
|
|
|
private:
|
2013-04-12 13:46:40 +02:00
|
|
|
struct jpeg_stream_wrapper
|
2013-04-08 16:56:19 +02:00
|
|
|
{
|
2013-04-12 13:46:40 +02:00
|
|
|
jpeg_source_mgr manager;
|
2022-01-26 10:43:31 +01:00
|
|
|
input_stream* stream;
|
2013-04-12 13:46:40 +02:00
|
|
|
JOCTET buffer[BUF_SIZE];
|
2013-04-10 03:36:02 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct jpeg_info_guard
|
|
|
|
{
|
2022-01-26 10:43:31 +01:00
|
|
|
jpeg_info_guard(jpeg_decompress_struct* cinfo)
|
|
|
|
: i_(cinfo)
|
|
|
|
{}
|
2013-04-10 03:36:02 +02:00
|
|
|
|
2022-01-26 10:43:31 +01:00
|
|
|
~jpeg_info_guard() { jpeg_destroy_decompress(i_); }
|
|
|
|
jpeg_decompress_struct* i_;
|
2013-04-08 16:56:19 +02:00
|
|
|
};
|
|
|
|
|
2022-01-26 10:43:31 +01:00
|
|
|
private:
|
2013-04-12 13:46:40 +02:00
|
|
|
source_type source_;
|
|
|
|
input_stream stream_;
|
2012-02-02 02:53:35 +01:00
|
|
|
unsigned width_;
|
|
|
|
unsigned height_;
|
2022-01-26 10:43:31 +01:00
|
|
|
|
|
|
|
public:
|
2016-06-22 18:21:25 +02:00
|
|
|
explicit jpeg_reader(std::string const& filename);
|
2013-04-12 13:46:40 +02:00
|
|
|
explicit jpeg_reader(char const* data, size_t size);
|
2013-04-09 12:34:20 +02:00
|
|
|
~jpeg_reader();
|
2014-12-03 10:44:56 +01:00
|
|
|
unsigned width() const final;
|
|
|
|
unsigned height() const final;
|
2024-04-19 20:45:24 +02:00
|
|
|
std::optional<box2d<double>> bounding_box() const override final;
|
2014-12-03 10:44:56 +01:00
|
|
|
inline bool has_alpha() const final { return false; }
|
2022-01-26 10:43:31 +01:00
|
|
|
void read(unsigned x, unsigned y, image_rgba8& image) final;
|
2015-01-22 02:40:12 +01:00
|
|
|
image_any read(unsigned x, unsigned y, unsigned width, unsigned height) final;
|
2022-01-26 10:43:31 +01:00
|
|
|
|
|
|
|
private:
|
2012-02-02 02:53:35 +01:00
|
|
|
void init();
|
2013-03-26 02:29:29 +01:00
|
|
|
static void on_error(j_common_ptr cinfo);
|
|
|
|
static void on_error_message(j_common_ptr cinfo);
|
2013-04-12 13:46:40 +02:00
|
|
|
static void init_source(j_decompress_ptr cinfo);
|
|
|
|
static boolean fill_input_buffer(j_decompress_ptr cinfo);
|
|
|
|
static void skip(j_decompress_ptr cinfo, long count);
|
|
|
|
static void term(j_decompress_ptr cinfo);
|
|
|
|
static void attach_stream(j_decompress_ptr cinfo, input_stream* in);
|
2012-02-02 02:53:35 +01:00
|
|
|
};
|
|
|
|
|
2016-06-22 18:21:25 +02:00
|
|
|
image_reader* create_jpeg_reader(std::string const& filename)
|
2012-02-02 02:53:35 +01:00
|
|
|
{
|
2016-06-22 18:21:25 +02:00
|
|
|
return new jpeg_reader<std::filebuf>(filename);
|
2013-04-12 13:46:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
image_reader* create_jpeg_reader2(char const* data, size_t size)
|
|
|
|
{
|
2016-06-22 18:21:25 +02:00
|
|
|
return new jpeg_reader<mapnik::util::char_array_buffer>(data, size);
|
2013-04-12 13:46:40 +02:00
|
|
|
}
|
2022-02-02 17:20:29 +01:00
|
|
|
void register_jpeg_reader()
|
|
|
|
{
|
|
|
|
const bool registered = register_image_reader("jpeg", create_jpeg_reader);
|
|
|
|
const bool registered2 = register_image_reader("jpeg", create_jpeg_reader2);
|
|
|
|
}
|
2013-04-12 13:46:40 +02:00
|
|
|
|
|
|
|
// ctors
|
2022-01-26 10:43:31 +01:00
|
|
|
template<typename T>
|
2016-06-22 18:21:25 +02:00
|
|
|
jpeg_reader<T>::jpeg_reader(std::string const& filename)
|
2022-01-26 10:43:31 +01:00
|
|
|
: source_()
|
|
|
|
, stream_(&source_)
|
|
|
|
, width_(0)
|
|
|
|
, height_(0)
|
2013-04-12 13:46:40 +02:00
|
|
|
{
|
2016-06-22 18:21:25 +02:00
|
|
|
source_.open(filename, std::ios_base::in | std::ios_base::binary);
|
2022-01-26 10:43:31 +01:00
|
|
|
if (!stream_)
|
|
|
|
throw image_reader_exception("cannot open image file " + filename);
|
2013-04-12 13:46:40 +02:00
|
|
|
init();
|
2012-02-02 02:53:35 +01:00
|
|
|
}
|
2010-06-03 23:24:58 +02:00
|
|
|
|
2022-01-26 10:43:31 +01:00
|
|
|
template<typename T>
|
2013-04-12 13:46:40 +02:00
|
|
|
jpeg_reader<T>::jpeg_reader(char const* data, size_t size)
|
2022-01-26 10:43:31 +01:00
|
|
|
: source_(data, size)
|
|
|
|
, stream_(&source_)
|
|
|
|
, width_(0)
|
|
|
|
, height_(0)
|
2012-02-02 02:53:35 +01:00
|
|
|
{
|
2022-01-26 10:43:31 +01:00
|
|
|
if (!stream_)
|
|
|
|
throw image_reader_exception("cannot open image stream");
|
2012-02-02 02:53:35 +01:00
|
|
|
init();
|
|
|
|
}
|
2010-06-03 23:24:58 +02:00
|
|
|
|
2013-04-12 13:46:40 +02:00
|
|
|
// dtor
|
2022-01-26 10:43:31 +01:00
|
|
|
template<typename T>
|
|
|
|
jpeg_reader<T>::~jpeg_reader()
|
|
|
|
{}
|
2013-03-26 02:29:29 +01:00
|
|
|
|
2013-04-12 13:46:40 +02:00
|
|
|
// jpeg stream wrapper
|
2022-01-26 10:43:31 +01:00
|
|
|
template<typename T>
|
|
|
|
void jpeg_reader<T>::init_source(j_decompress_ptr cinfo)
|
2013-04-12 13:46:40 +02:00
|
|
|
{
|
|
|
|
jpeg_stream_wrapper* wrap = reinterpret_cast<jpeg_stream_wrapper*>(cinfo->src);
|
2022-01-26 10:43:31 +01:00
|
|
|
wrap->stream->seekg(0, std::ios_base::beg);
|
2013-04-12 13:46:40 +02:00
|
|
|
}
|
|
|
|
|
2022-01-26 10:43:31 +01:00
|
|
|
template<typename T>
|
|
|
|
boolean jpeg_reader<T>::fill_input_buffer(j_decompress_ptr cinfo)
|
2013-04-12 13:46:40 +02:00
|
|
|
{
|
|
|
|
jpeg_stream_wrapper* wrap = reinterpret_cast<jpeg_stream_wrapper*>(cinfo->src);
|
2022-01-26 10:43:31 +01:00
|
|
|
wrap->stream->read(reinterpret_cast<char*>(&wrap->buffer[0]), BUF_SIZE);
|
2013-04-12 13:46:40 +02:00
|
|
|
std::streamsize size = wrap->stream->gcount();
|
|
|
|
wrap->manager.next_input_byte = wrap->buffer;
|
|
|
|
wrap->manager.bytes_in_buffer = BUF_SIZE;
|
|
|
|
return (size > 0) ? TRUE : FALSE;
|
|
|
|
}
|
|
|
|
|
2022-01-26 10:43:31 +01:00
|
|
|
template<typename T>
|
2013-04-12 13:46:40 +02:00
|
|
|
void jpeg_reader<T>::skip(j_decompress_ptr cinfo, long count)
|
|
|
|
{
|
2022-01-26 10:43:31 +01:00
|
|
|
if (count <= 0)
|
|
|
|
return; // A zero or negative skip count should be treated as a no-op.
|
2013-04-12 13:46:40 +02:00
|
|
|
jpeg_stream_wrapper* wrap = reinterpret_cast<jpeg_stream_wrapper*>(cinfo->src);
|
|
|
|
|
2013-10-01 20:47:47 +02:00
|
|
|
if (wrap->manager.bytes_in_buffer > 0 && count < static_cast<long>(wrap->manager.bytes_in_buffer))
|
2013-04-12 13:46:40 +02:00
|
|
|
{
|
|
|
|
wrap->manager.bytes_in_buffer -= count;
|
|
|
|
wrap->manager.next_input_byte = &wrap->buffer[BUF_SIZE - wrap->manager.bytes_in_buffer];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-01-19 05:31:47 +01:00
|
|
|
wrap->stream->seekg(count - wrap->manager.bytes_in_buffer, std::ios_base::cur);
|
2013-04-12 13:46:40 +02:00
|
|
|
// trigger buffer fill
|
|
|
|
wrap->manager.next_input_byte = 0;
|
2022-01-26 10:43:31 +01:00
|
|
|
wrap->manager.bytes_in_buffer = 0; // bytes_in_buffer may be zero on return.
|
2013-04-12 13:46:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-26 10:43:31 +01:00
|
|
|
template<typename T>
|
|
|
|
void jpeg_reader<T>::term(j_decompress_ptr /*cinfo*/)
|
2013-04-12 13:46:40 +02:00
|
|
|
{
|
2022-01-26 10:43:31 +01:00
|
|
|
// no-op
|
2013-04-12 13:46:40 +02:00
|
|
|
}
|
|
|
|
|
2022-01-26 10:43:31 +01:00
|
|
|
template<typename T>
|
|
|
|
void jpeg_reader<T>::attach_stream(j_decompress_ptr cinfo, input_stream* in)
|
2013-04-12 13:46:40 +02:00
|
|
|
{
|
|
|
|
if (cinfo->src == 0)
|
|
|
|
{
|
2022-01-26 10:43:31 +01:00
|
|
|
cinfo->src = (struct jpeg_source_mgr*)(*cinfo->mem->alloc_small)((j_common_ptr)cinfo,
|
|
|
|
JPOOL_PERMANENT,
|
|
|
|
sizeof(jpeg_stream_wrapper));
|
2013-04-12 13:46:40 +02:00
|
|
|
}
|
2022-01-26 10:43:31 +01:00
|
|
|
jpeg_reader::jpeg_stream_wrapper* src = reinterpret_cast<jpeg_reader::jpeg_stream_wrapper*>(cinfo->src);
|
2013-04-12 13:46:40 +02:00
|
|
|
src->manager.init_source = init_source;
|
|
|
|
src->manager.fill_input_buffer = fill_input_buffer;
|
|
|
|
src->manager.skip_input_data = skip;
|
|
|
|
src->manager.resync_to_restart = jpeg_resync_to_restart;
|
|
|
|
src->manager.term_source = term;
|
|
|
|
src->manager.bytes_in_buffer = 0;
|
|
|
|
src->manager.next_input_byte = 0;
|
|
|
|
src->stream = in;
|
|
|
|
}
|
|
|
|
|
2022-01-26 10:43:31 +01:00
|
|
|
template<typename T>
|
2015-06-11 23:02:34 +02:00
|
|
|
void jpeg_reader<T>::on_error(j_common_ptr cinfo)
|
2013-03-26 02:29:29 +01:00
|
|
|
{
|
2015-06-11 23:02:34 +02:00
|
|
|
char buffer[JMSG_LENGTH_MAX];
|
|
|
|
(*cinfo->err->format_message)(cinfo, buffer);
|
|
|
|
throw image_reader_exception(std::string("JPEG Reader: libjpeg could not read image: ") + buffer);
|
2013-03-26 02:29:29 +01:00
|
|
|
}
|
|
|
|
|
2022-01-26 10:43:31 +01:00
|
|
|
template<typename T>
|
2013-04-12 13:46:40 +02:00
|
|
|
void jpeg_reader<T>::on_error_message(j_common_ptr cinfo)
|
2013-03-26 02:29:29 +01:00
|
|
|
{
|
2013-07-24 00:46:54 +02:00
|
|
|
char buffer[JMSG_LENGTH_MAX];
|
|
|
|
(*cinfo->err->format_message)(cinfo, buffer);
|
|
|
|
throw image_reader_exception(std::string("JPEG Reader: libjpeg could not read image: ") + buffer);
|
2013-03-26 02:29:29 +01:00
|
|
|
}
|
2010-06-03 23:24:58 +02:00
|
|
|
|
2022-01-26 10:43:31 +01:00
|
|
|
template<typename T>
|
2013-04-12 13:46:40 +02:00
|
|
|
void jpeg_reader<T>::init()
|
2012-02-02 02:53:35 +01:00
|
|
|
{
|
2013-04-10 03:36:02 +02:00
|
|
|
jpeg_decompress_struct cinfo;
|
|
|
|
jpeg_info_guard iguard(&cinfo);
|
|
|
|
jpeg_error_mgr jerr;
|
2012-02-02 02:53:35 +01:00
|
|
|
cinfo.err = jpeg_std_error(&jerr);
|
2013-03-26 02:29:29 +01:00
|
|
|
jerr.error_exit = on_error;
|
|
|
|
jerr.output_message = on_error_message;
|
2012-02-02 02:53:35 +01:00
|
|
|
jpeg_create_decompress(&cinfo);
|
2013-04-12 13:46:40 +02:00
|
|
|
attach_stream(&cinfo, &stream_);
|
2013-04-10 03:36:02 +02:00
|
|
|
int ret = jpeg_read_header(&cinfo, TRUE);
|
2013-04-12 13:46:40 +02:00
|
|
|
if (ret != JPEG_HEADER_OK)
|
|
|
|
throw image_reader_exception("JPEG Reader: failed to read header");
|
2012-02-02 02:53:35 +01:00
|
|
|
jpeg_start_decompress(&cinfo);
|
|
|
|
width_ = cinfo.output_width;
|
|
|
|
height_ = cinfo.output_height;
|
2013-04-08 16:56:19 +02:00
|
|
|
|
|
|
|
if (cinfo.out_color_space == JCS_UNKNOWN)
|
|
|
|
{
|
2013-04-12 13:46:40 +02:00
|
|
|
throw image_reader_exception("JPEG Reader: failed to read unknown color space");
|
2013-04-08 16:56:19 +02:00
|
|
|
}
|
|
|
|
if (cinfo.output_width == 0 || cinfo.output_height == 0)
|
|
|
|
{
|
2013-04-12 13:46:40 +02:00
|
|
|
throw image_reader_exception("JPEG Reader: failed to read image size of");
|
2013-04-08 16:56:19 +02:00
|
|
|
}
|
2012-02-02 02:53:35 +01:00
|
|
|
}
|
2010-06-03 23:24:58 +02:00
|
|
|
|
2022-01-26 10:43:31 +01:00
|
|
|
template<typename T>
|
2013-04-12 13:46:40 +02:00
|
|
|
unsigned jpeg_reader<T>::width() const
|
2012-02-02 02:53:35 +01:00
|
|
|
{
|
|
|
|
return width_;
|
|
|
|
}
|
2010-06-03 23:24:58 +02:00
|
|
|
|
2022-01-26 10:43:31 +01:00
|
|
|
template<typename T>
|
2013-04-12 13:46:40 +02:00
|
|
|
unsigned jpeg_reader<T>::height() const
|
2012-02-02 02:53:35 +01:00
|
|
|
{
|
|
|
|
return height_;
|
|
|
|
}
|
2010-06-03 23:24:58 +02:00
|
|
|
|
2022-01-26 10:43:31 +01:00
|
|
|
template<typename T>
|
2024-04-19 20:45:24 +02:00
|
|
|
std::optional<box2d<double>> jpeg_reader<T>::bounding_box() const
|
2014-12-10 10:44:51 +01:00
|
|
|
{
|
2024-04-19 20:45:24 +02:00
|
|
|
return std::nullopt;
|
2014-12-10 10:44:51 +01:00
|
|
|
}
|
|
|
|
|
2022-01-26 10:43:31 +01:00
|
|
|
template<typename T>
|
2015-01-22 03:31:02 +01:00
|
|
|
void jpeg_reader<T>::read(unsigned x0, unsigned y0, image_rgba8& image)
|
2012-02-02 02:53:35 +01:00
|
|
|
{
|
2013-04-12 13:46:40 +02:00
|
|
|
stream_.clear();
|
|
|
|
stream_.seekg(0, std::ios_base::beg);
|
|
|
|
|
2013-04-10 03:36:02 +02:00
|
|
|
jpeg_decompress_struct cinfo;
|
|
|
|
jpeg_info_guard iguard(&cinfo);
|
|
|
|
jpeg_error_mgr jerr;
|
|
|
|
cinfo.err = jpeg_std_error(&jerr);
|
|
|
|
jerr.error_exit = on_error;
|
|
|
|
jerr.output_message = on_error_message;
|
|
|
|
jpeg_create_decompress(&cinfo);
|
2013-04-12 13:46:40 +02:00
|
|
|
attach_stream(&cinfo, &stream_);
|
2013-04-10 03:36:02 +02:00
|
|
|
int ret = jpeg_read_header(&cinfo, TRUE);
|
2022-01-26 10:43:31 +01:00
|
|
|
if (ret != JPEG_HEADER_OK)
|
|
|
|
throw image_reader_exception("JPEG Reader read(): failed to read header");
|
2013-04-10 03:36:02 +02:00
|
|
|
jpeg_start_decompress(&cinfo);
|
2012-02-02 02:53:35 +01:00
|
|
|
JSAMPARRAY buffer;
|
|
|
|
int row_stride;
|
2022-01-26 10:43:31 +01:00
|
|
|
unsigned char a, r, g, b;
|
2012-02-02 02:53:35 +01:00
|
|
|
row_stride = cinfo.output_width * cinfo.output_components;
|
2022-01-26 10:43:31 +01:00
|
|
|
buffer = (*cinfo.mem->alloc_sarray)((j_common_ptr)&cinfo, JPOOL_IMAGE, row_stride, 1);
|
2012-02-02 02:53:35 +01:00
|
|
|
|
2024-04-19 20:45:24 +02:00
|
|
|
const unsigned w = std::min(unsigned(image.width()), width_ - x0);
|
|
|
|
const unsigned h = std::min(unsigned(image.height()), height_ - y0);
|
2012-02-02 02:53:35 +01:00
|
|
|
|
2013-09-20 16:01:58 +02:00
|
|
|
const std::unique_ptr<unsigned int[]> out_row(new unsigned int[w]);
|
2013-04-08 16:56:19 +02:00
|
|
|
unsigned row = 0;
|
|
|
|
while (cinfo.output_scanline < cinfo.output_height)
|
2012-02-02 02:53:35 +01:00
|
|
|
{
|
|
|
|
jpeg_read_scanlines(&cinfo, buffer, 1);
|
2013-04-08 16:56:19 +02:00
|
|
|
if (row >= y0 && row < y0 + h)
|
2010-06-03 23:24:58 +02:00
|
|
|
{
|
2013-04-08 16:56:19 +02:00
|
|
|
for (unsigned int x = 0; x < w; ++x)
|
2010-06-03 23:24:58 +02:00
|
|
|
{
|
2013-04-08 16:56:19 +02:00
|
|
|
unsigned col = x + x0;
|
2012-02-02 02:53:35 +01:00
|
|
|
a = 255; // alpha not supported in jpg
|
2013-04-08 16:56:19 +02:00
|
|
|
r = buffer[0][cinfo.output_components * col];
|
2012-02-02 02:53:35 +01:00
|
|
|
if (cinfo.output_components > 2)
|
2010-06-03 23:24:58 +02:00
|
|
|
{
|
2013-04-08 16:56:19 +02:00
|
|
|
g = buffer[0][cinfo.output_components * col + 1];
|
|
|
|
b = buffer[0][cinfo.output_components * col + 2];
|
2022-01-26 10:43:31 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-02-02 02:53:35 +01:00
|
|
|
g = r;
|
|
|
|
b = r;
|
2010-06-03 23:24:58 +02:00
|
|
|
}
|
2012-02-02 02:53:35 +01:00
|
|
|
out_row[x] = color(r, g, b, a).rgba();
|
|
|
|
}
|
2015-05-04 12:49:11 +02:00
|
|
|
image.set_row(row - y0, out_row.get(), w);
|
2010-06-03 23:24:58 +02:00
|
|
|
}
|
2013-04-08 16:56:19 +02:00
|
|
|
++row;
|
2010-06-03 23:24:58 +02:00
|
|
|
}
|
2013-04-10 03:36:02 +02:00
|
|
|
jpeg_finish_decompress(&cinfo);
|
2012-02-02 02:53:35 +01:00
|
|
|
}
|
2013-04-08 16:56:19 +02:00
|
|
|
|
2022-01-26 10:43:31 +01:00
|
|
|
template<typename T>
|
2015-01-22 02:40:12 +01:00
|
|
|
image_any jpeg_reader<T>::read(unsigned x, unsigned y, unsigned width, unsigned height)
|
2014-12-03 10:44:56 +01:00
|
|
|
{
|
2022-01-26 10:43:31 +01:00
|
|
|
image_rgba8 data(width, height, true, true);
|
2014-12-03 10:56:19 +01:00
|
|
|
read(x, y, data);
|
2015-01-22 02:40:12 +01:00
|
|
|
return image_any(std::move(data));
|
2014-12-03 10:44:56 +01:00
|
|
|
}
|
|
|
|
|
2022-01-26 10:43:31 +01:00
|
|
|
} // namespace mapnik
|