31 #ifndef PNGPP_CONVERT_COLOR_SPACE_HPP_INCLUDED 32 #define PNGPP_CONVERT_COLOR_SPACE_HPP_INCLUDED 53 template<
typename pixel >
60 template<
class reader >
77 #ifdef DEBUG_EXPAND_8_16 78 printf(
"row: width=%d, bytes=%d, channels=%d\n",
79 row_info->width, row_info->rowbytes, row_info->channels);
83 for (
size_t i = row_info->rowbytes; i-- > 0; )
85 row[2*i + 1] = row[i];
88 #ifdef DEBUG_EXPAND_8_16 94 #ifdef DEBUG_EXPAND_8_16 98 for (
size_t i = 0; i < width; ++i)
100 printf(
" %02x,", row[i]);
106 template<
class reader >
109 if (io.
get_bit_depth() == 16 && traits::get_bit_depth() == 8)
111 #ifdef PNG_READ_16_TO_8_SUPPORTED 114 throw error(
"expected 8-bit data but found 16-bit;" 115 " recompile with PNG_READ_16_TO_8_SUPPORTED");
118 if (io.
get_bit_depth() != 16 && traits::get_bit_depth() == 16)
120 #ifdef PNG_READ_USER_TRANSFORM_SUPPORTED 123 traits::get_channels());
125 throw error(
"expected 16-bit data but found 8-bit;" 127 " PNG_READ_USER_TRANSFORM_SUPPORTED");
132 template<
class reader >
138 if ((src_alpha || src_tRNS) && !dst_alpha)
140 #ifdef PNG_READ_STRIP_ALPHA_SUPPORTED 143 throw error(
"alpha channel unexpected;" 145 " PNG_READ_STRIP_ALPHA_SUPPORTED");
148 if (!src_alpha && dst_alpha)
150 #if defined(PNG_tRNS_SUPPORTED) && defined(PNG_READ_EXPAND_SUPPORTED) 157 #if defined(PNG_READ_FILLER_SUPPORTED) && !defined(PNG_1_0_X) 160 throw error(
"expected alpha channel but none found;" 161 " recompile with PNG_READ_FILLER_SUPPORTED" 162 " and be sure to use libpng > 1.0.x");
167 template<
class reader >
172 #ifdef PNG_READ_EXPAND_SUPPORTED 180 throw error(
"indexed colors unexpected;" 181 " recompile with PNG_READ_EXPAND_SUPPORTED");
186 template<
class reader >
192 if (src_rgb && !dst_rgb)
194 #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED 197 throw error(
"grayscale data expected;" 199 " PNG_READ_RGB_TO_GRAY_SUPPORTED");
202 if (!src_rgb && dst_rgb)
204 #ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED 207 throw error(
"expected RGB data;" 209 " PNG_READ_GRAY_TO_RGB_SUPPORTED");
214 template<
class reader >
222 #ifdef PNG_READ_EXPAND_SUPPORTED 225 throw error(
"convert_color_space: expected 8-bit data;" 227 " PNG_READ_EXPAND_SUPPORTED");
251 template<
typename pixel >
338 #endif // PNGPP_CONVERT_COLOR_SPACE_HPP_INCLUDED static void handle_gray(reader &io)
Definition: convert_color_space.hpp:215
void set_add_alpha(uint_32 filler, filler_type type) const
Definition: io_base.hpp:301
Basic Gray+Alpha pixel type.
Definition: ga_pixel.hpp:46
void set_read_user_transform(png_user_transform_ptr transform_fn)
Definition: io_base.hpp:401
RGB pixel type.
Definition: rgb_pixel.hpp:44
static void handle_alpha(reader &io, uint_32 filler)
Definition: convert_color_space.hpp:133
Definition: types.hpp:104
void set_bit_depth(size_t bit_depth)
Definition: io_base.hpp:155
static void handle_16(reader &io)
Definition: convert_color_space.hpp:107
static void handle_palette(reader &io)
Definition: convert_color_space.hpp:168
The PNG reader class template. This is the low-level reading interface–use image class or consumer c...
Definition: reader.hpp:65
Pixel traits class template.
Definition: pixel_traits.hpp:48
color_type get_color_type() const
Definition: io_base.hpp:140
void set_strip_16() const
Definition: io_base.hpp:393
size_t get_bit_depth() const
Definition: io_base.hpp:150
IO transformation class template. Converts image color space.
Definition: convert_color_space.hpp:54
uint_16 gray_pixel_16
The 16-bit Grayscale pixel type.
Definition: gray_pixel.hpp:49
bool has_chunk(chunk id)
Definition: io_base.hpp:192
RGBA pixel type.
Definition: rgba_pixel.hpp:44
png_uint_32 uint_32
Definition: types.hpp:41
png_byte byte
Definition: types.hpp:39
void set_gray_to_rgb() const
Definition: io_base.hpp:228
static component get_alpha_filler()
Returns the default alpha channel filler for full opacity.
Definition: pixel_traits.hpp:91
void operator()(reader &io) const
Definition: convert_color_space.hpp:61
void drop_palette()
Removes all entries from the palette.
Definition: image_info.hpp:154
void set_color_type(color_type color_space)
Definition: io_base.hpp:145
info & get_info()
Definition: io_base.hpp:87
static void expand_8_to_16(png_struct *, png_row_info *row_info, byte *row)
Definition: convert_color_space.hpp:74
byte gray_pixel
The 8-bit Grayscale pixel type.
Definition: gray_pixel.hpp:44
static void handle_rgb(reader &io)
Definition: convert_color_space.hpp:187
pixel_traits< pixel > traits
Definition: convert_color_space.hpp:56
static void dump_row(byte const *row, size_t width)
Definition: convert_color_space.hpp:95
IO transformation class template. Converts image color space.
Definition: convert_color_space.hpp:252
void set_palette_to_rgb() const
Definition: io_base.hpp:206
basic_alpha_pixel_traits< component_type > alpha_traits
Definition: convert_color_space.hpp:58
void set_tRNS_to_alpha() const
Definition: io_base.hpp:212
void set_gray_1_2_4_to_8() const
Definition: io_base.hpp:200
void set_user_transform_info(void *info, int bit_depth, int channels)
Definition: io_base.hpp:410
void set_rgb_to_gray(rgb_to_gray_error_action error_action=rgb_to_gray_silent, double red_weight=-1.0, double green_weight=-1.0) const
Definition: io_base.hpp:236
Exception class to represent runtime errors related to png++ operation.
Definition: error.hpp:45
traits::component_type component_type
Definition: convert_color_space.hpp:57
void set_strip_alpha() const
Definition: io_base.hpp:266
Basic pixel traits class template for pixels with alpha channel.
Definition: pixel_traits.hpp:85