Go to the documentation of this file.
   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 (
uint_32 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 (
uint_32 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; recompile with PNG_READ_16_TO_8_SUPPORTED");
 
  117                 if (io.
get_bit_depth() != 16 && traits::get_bit_depth() == 16)
 
  119 #ifdef PNG_READ_USER_TRANSFORM_SUPPORTED 
  122                                                traits::get_channels());
 
  124                     throw error(
"expected 16-bit data but found 8-bit; recompile with PNG_READ_USER_TRANSFORM_SUPPORTED");
 
  129             template< 
class reader >
 
  135                 if ((src_alpha || src_tRNS) && !dst_alpha)
 
  137 #ifdef PNG_READ_STRIP_ALPHA_SUPPORTED 
  140                     throw error(
"alpha channel unexpected; recompile with PNG_READ_STRIP_ALPHA_SUPPORTED");
 
  143                 if (!src_alpha && dst_alpha)
 
  145 #if defined(PNG_tRNS_SUPPORTED) && defined(PNG_READ_EXPAND_SUPPORTED) 
  152 #if defined(PNG_READ_FILLER_SUPPORTED) && !defined(PNG_1_0_X) 
  155                     throw error(
"expected alpha channel but none found; recompile with PNG_READ_FILLER_SUPPORTED and be sure to use libpng > 1.0.x");
 
  160             template< 
class reader >
 
  167                 if (src_palette && !dst_palette)
 
  169 #ifdef PNG_READ_EXPAND_SUPPORTED 
  173                     throw error(
"indexed colors unexpected; recompile with PNG_READ_EXPAND_SUPPORTED");
 
  176                 else if (!src_palette && dst_palette)
 
  178                     throw error(
"conversion to indexed colors is unsupported (yet)");
 
  180                 else if (src_palette && dst_palette
 
  183                     if (traits::get_bit_depth() == 8)
 
  185 #ifdef PNG_READ_PACK_SUPPORTED 
  191                         throw error(
"cannot convert to indexed colors with bit-depth < 8");
 
  196             template< 
class reader >
 
  202                 if (src_rgb && !dst_rgb)
 
  204 #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED 
  207                     throw error(
"grayscale data expected; recompile with PNG_READ_RGB_TO_GRAY_SUPPORTED");
 
  210                 if (!src_rgb && dst_rgb)
 
  212 #ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED 
  215                     throw error(
"expected RGB data; recompile with PNG_READ_GRAY_TO_RGB_SUPPORTED");
 
  220             template< 
class reader >
 
  228 #ifdef PNG_READ_EXPAND_SUPPORTED 
  231                         throw error(
"convert_color_space: expected 8-bit data; recompile with PNG_READ_EXPAND_SUPPORTED");
 
  255     template< 
typename pixel >
 
  352 #endif // PNGPP_CONVERT_COLOR_SPACE_HPP_INCLUDED 
  
void set_read_user_transform(png_user_transform_ptr transform_fn)
Definition: io_base.hpp:400
static void handle_gray(reader &io)
Definition: convert_color_space.hpp:221
void set_strip_16() const
Definition: io_base.hpp:392
info & get_info()
Definition: io_base.hpp:87
uint_16 gray_pixel_16
The 16-bit Grayscale pixel type.
Definition: gray_pixel.hpp:49
@ color_type_palette
Definition: types.hpp:50
Basic Gray+Alpha pixel type.
Definition: ga_pixel.hpp:47
pixel_traits< pixel > traits
Definition: convert_color_space.hpp:56
void set_tRNS_to_alpha() const
Definition: io_base.hpp:212
@ color_mask_rgb
Definition: types.hpp:62
static void expand_8_to_16(png_struct *, png_row_info *row_info, byte *row)
Definition: convert_color_space.hpp:74
@ color_mask_alpha
Definition: types.hpp:63
png_uint_32 uint_32
Definition: types.hpp:41
color_type get_color_type() const
Definition: io_base.hpp:140
void set_bit_depth(int bit_depth)
Definition: io_base.hpp:155
@ chunk_tRNS
Definition: types.hpp:104
traits::component_type component_type
Definition: convert_color_space.hpp:57
@ color_type_gray
Definition: types.hpp:49
int get_bit_depth() const
Definition: io_base.hpp:150
static void dump_row(byte const *row, uint_32 width)
Definition: convert_color_space.hpp:95
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
IO transformation class template. Converts image color space.
Definition: convert_color_space.hpp:55
static void handle_alpha(reader &io, uint_32 filler)
Definition: convert_color_space.hpp:130
void set_user_transform_info(void *info, int bit_depth, int channels)
Definition: io_base.hpp:409
Basic pixel traits class template for pixels with alpha channel.
Definition: pixel_traits.hpp:90
The 8-bit Indexed (colormap) pixel type.
Definition: index_pixel.hpp:45
void set_packing() const
Definition: io_base.hpp:320
The PNG reader class template. This is the low-level reading interface–use image class or consumer cl...
Definition: reader.hpp:67
static void handle_palette(reader &io)
Definition: convert_color_space.hpp:161
void drop_palette()
Removes all entries from the palette.
Definition: image_info.hpp:155
IO transformation class template. Converts image color space.
Definition: convert_color_space.hpp:257
void set_add_alpha(uint_32 filler, filler_type type) const
Definition: io_base.hpp:301
void set_color_type(color_type color_space)
Definition: io_base.hpp:145
Exception class to represent runtime errors related to png++ operation.
Definition: error.hpp:59
void set_strip_alpha() const
Definition: io_base.hpp:266
bool has_chunk(chunk id)
Definition: io_base.hpp:192
RGB pixel type.
Definition: rgb_pixel.hpp:45
static void handle_rgb(reader &io)
Definition: convert_color_space.hpp:197
Pixel traits class template.
Definition: pixel_traits.hpp:48
static component get_alpha_filler()
Returns the default alpha channel filler for full opacity.
Definition: pixel_traits.hpp:95
@ color_mask_palette
Definition: types.hpp:60
void operator()(reader &io) const
Definition: convert_color_space.hpp:61
@ filler_after
Definition: types.hpp:69
void set_palette_to_rgb() const
Definition: io_base.hpp:206
static void handle_16(reader &io)
Definition: convert_color_space.hpp:107
RGBA pixel type.
Definition: rgba_pixel.hpp:45
void set_gray_1_2_4_to_8() const
Definition: io_base.hpp:200
byte gray_pixel
The 8-bit Grayscale pixel type.
Definition: gray_pixel.hpp:44
void set_gray_to_rgb() const
Definition: io_base.hpp:228
basic_alpha_pixel_traits< component_type > alpha_traits
Definition: convert_color_space.hpp:58