add to image_reader and implement empty (placeholder)

```image_data_any read(unsigned x, unsigned y, unsigned width, unsigned height) final```
in png/jpeg/webp/tiff readers
This commit is contained in:
artemp 2014-12-03 10:44:56 +01:00
parent 33607145a6
commit 1df9d89a70
5 changed files with 51 additions and 21 deletions

View file

@ -60,7 +60,7 @@ struct MAPNIK_DECL image_reader : private mapnik::noncopyable
virtual bool has_alpha() const = 0;
virtual bool premultiplied_alpha() const = 0;
virtual void read(unsigned x,unsigned y,image_data_32& image) = 0;
virtual image_data_any read(unsigned x, unsigned y, unsigned width, unsigned height) = 0;
virtual ~image_reader() {}
};

View file

@ -81,11 +81,12 @@ public:
explicit jpeg_reader(std::string const& file_name);
explicit jpeg_reader(char const* data, size_t size);
~jpeg_reader();
unsigned width() const;
unsigned height() const;
inline bool has_alpha() const { return false; }
inline bool premultiplied_alpha() const { return true; }
void read(unsigned x,unsigned y,image_data_32& image);
unsigned width() const final;
unsigned height() const final;
inline bool has_alpha() const final { return false; }
inline bool premultiplied_alpha() const final { return true; }
void read(unsigned x,unsigned y,image_data_32& image) final;
image_data_any read(unsigned x, unsigned y, unsigned width, unsigned height) final;
private:
void init();
static void on_error(j_common_ptr cinfo);
@ -312,4 +313,10 @@ void jpeg_reader<T>::read(unsigned x0, unsigned y0, image_data_32& image)
jpeg_finish_decompress(&cinfo);
}
template <typename T>
image_data_any jpeg_reader<T>::read(unsigned x, unsigned y, unsigned width, unsigned height)
{
return image_data_any();
}
}

View file

@ -76,11 +76,12 @@ public:
explicit png_reader(std::string const& file_name);
png_reader(char const* data, std::size_t size);
~png_reader();
unsigned width() const;
unsigned height() const;
inline bool has_alpha() const { return has_alpha_; }
bool premultiplied_alpha() const { return false; } //http://www.libpng.org/pub/png/spec/1.1/PNG-Rationale.html
void read(unsigned x,unsigned y,image_data_32& image);
unsigned width() const final;
unsigned height() const final;
inline bool has_alpha() const final { return has_alpha_; }
bool premultiplied_alpha() const final { return false; } //http://www.libpng.org/pub/png/spec/1.1/PNG-Rationale.html
void read(unsigned x,unsigned y,image_data_32& image) final;
image_data_any read(unsigned x, unsigned y, unsigned width, unsigned height) final;
private:
void init();
static void png_read_data(png_structp png_ptr, png_bytep data, png_size_t length);
@ -300,4 +301,12 @@ void png_reader<T>::read(unsigned x0, unsigned y0,image_data_32& image)
}
png_read_end(png_ptr,0);
}
template <typename T>
image_data_any png_reader<T>::read(unsigned x, unsigned y, unsigned width, unsigned height)
{
return image_data_any();
}
}

View file

@ -141,11 +141,12 @@ public:
explicit tiff_reader(std::string const& file_name);
tiff_reader(char const* data, std::size_t size);
virtual ~tiff_reader();
unsigned width() const;
unsigned height() const;
inline bool has_alpha() const { return has_alpha_; }
bool premultiplied_alpha() const;
void read(unsigned x,unsigned y,image_data_32& image);
unsigned width() const final;
unsigned height() const final;
inline bool has_alpha() const final { return has_alpha_; }
bool premultiplied_alpha() const final;
void read(unsigned x,unsigned y,image_data_32& image) final;
image_data_any read(unsigned x, unsigned y, unsigned width, unsigned height) final;
private:
tiff_reader(const tiff_reader&);
tiff_reader& operator=(const tiff_reader&);
@ -296,6 +297,12 @@ void tiff_reader<T>::read(unsigned x,unsigned y,image_data_32& image)
}
}
template <typename T>
image_data_any tiff_reader<T>::read(unsigned x, unsigned y, unsigned width, unsigned height)
{
return image_data_any();
}
template <typename T>
void tiff_reader<T>::read_generic(unsigned, unsigned, image_data_32&)
{

View file

@ -120,11 +120,12 @@ public:
explicit webp_reader(char const* data, std::size_t size);
explicit webp_reader(std::string const& filename);
~webp_reader();
unsigned width() const;
unsigned height() const;
inline bool has_alpha() const { return has_alpha_; }
bool premultiplied_alpha() const { return false; }
void read(unsigned x,unsigned y,image_data_32& image);
unsigned width() const final;
unsigned height() const final;
inline bool has_alpha() const final { return has_alpha_; }
bool premultiplied_alpha() const final { return false; }
void read(unsigned x,unsigned y,image_data_32& image) final;
image_data_any read(unsigned x, unsigned y, unsigned width, unsigned height) final;
private:
void init();
};
@ -260,4 +261,10 @@ void webp_reader<T>::read(unsigned x0, unsigned y0,image_data_32& image)
}
}
template <typename T>
image_data_any webp_reader<T>::read(unsigned x, unsigned y, unsigned width, unsigned height)
{
return image_data_any();
}
}