31 #ifndef PNGPP_CONVERT_COLOR_SPACE_HPP_INCLUDED
32 #define PNGPP_CONVERT_COLOR_SPACE_HPP_INCLUDED
53 template<
typename pixel >
56 typedef pixel_traits< pixel >
traits;
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