31 #ifndef PNGPP_IO_BASE_HPP_INCLUDED 32 #define PNGPP_IO_BASE_HPP_INCLUDED 42 trace_io_transform(
char const* fmt, ...)
44 #ifdef DEBUG_IO_TRANSFORM 47 fprintf(stderr,
"TRANSFORM_IO: ");
48 vfprintf(stderr, fmt, va);
52 #define TRACE_IO_TRANSFORM trace_io_transform 194 return png_get_valid(
m_png,
199 #if defined(PNG_READ_EXPAND_SUPPORTED) 202 TRACE_IO_TRANSFORM(
"png_set_expand_gray_1_2_4_to_8\n");
203 png_set_expand_gray_1_2_4_to_8(
m_png);
208 TRACE_IO_TRANSFORM(
"png_set_palette_to_rgb\n");
209 png_set_palette_to_rgb(
m_png);
214 TRACE_IO_TRANSFORM(
"png_set_tRNS_to_alpha\n");
215 png_set_tRNS_to_alpha(
m_png);
217 #endif // defined(PNG_READ_EXPAND_SUPPORTED) 219 #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) 222 TRACE_IO_TRANSFORM(
"png_set_bgr\n");
227 #if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) 230 TRACE_IO_TRANSFORM(
"png_set_gray_to_rgb\n");
231 png_set_gray_to_rgb(
m_png);
235 #ifdef PNG_FLOATING_POINT_SUPPORTED 238 double red_weight = -1.0,
239 double green_weight = -1.0)
const 241 TRACE_IO_TRANSFORM(
"png_set_rgb_to_gray: error_action=%d," 242 " red_weight=%lf, green_weight=%lf\n",
243 error_action, red_weight, green_weight);
245 png_set_rgb_to_gray(
m_png, error_action, red_weight, green_weight);
253 TRACE_IO_TRANSFORM(
"png_set_rgb_to_gray_fixed: error_action=%d," 254 " red_weight=%d, green_weight=%d\n",
255 error_action, red_weight, green_weight);
257 png_set_rgb_to_gray_fixed(
m_png, error_action,
258 red_weight, green_weight);
260 #endif // PNG_FLOATING_POINT_SUPPORTED 265 #if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) 268 TRACE_IO_TRANSFORM(
"png_set_strip_alpha\n");
269 png_set_strip_alpha(
m_png);
273 #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) \ 274 || defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) 277 TRACE_IO_TRANSFORM(
"png_set_swap_alpha\n");
278 png_set_swap_alpha(
m_png);
282 #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) \ 283 || defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) 286 TRACE_IO_TRANSFORM(
"png_set_invert_alpha\n");
287 png_set_invert_alpha(
m_png);
291 #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) 294 TRACE_IO_TRANSFORM(
"png_set_filler: filler=%08x, type=%d\n",
297 png_set_filler(
m_png, filler, type);
300 #if !defined(PNG_1_0_X) 303 TRACE_IO_TRANSFORM(
"png_set_add_alpha: filler=%08x, type=%d\n",
306 png_set_add_alpha(
m_png, filler, type);
309 #endif // PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED 311 #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) 314 TRACE_IO_TRANSFORM(
"png_set_swap\n");
319 #if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) 322 TRACE_IO_TRANSFORM(
"png_set_packing\n");
323 png_set_packing(
m_png);
327 #if defined(PNG_READ_PACKSWAP_SUPPORTED) \ 328 || defined(PNG_WRITE_PACKSWAP_SUPPORTED) 331 TRACE_IO_TRANSFORM(
"png_set_packswap\n");
332 png_set_packswap(
m_png);
336 #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) 338 byte alpha_bits = 0)
const 340 TRACE_IO_TRANSFORM(
"png_set_shift: red_bits=%d, green_bits=%d," 341 " blue_bits=%d, alpha_bits=%d\n",
342 red_bits, green_bits, blue_bits, alpha_bits);
347 throw error(
"set_shift: expected RGB or RGBA color type");
351 bits.green = green_bits;
352 bits.blue = blue_bits;
353 bits.alpha = alpha_bits;
354 png_set_shift(
m_png, & bits);
359 TRACE_IO_TRANSFORM(
"png_set_shift: gray_bits=%d, alpha_bits=%d\n",
360 gray_bits, alpha_bits);
365 throw error(
"set_shift: expected Gray or Gray+Alpha color type");
368 bits.gray = gray_bits;
369 bits.alpha = alpha_bits;
370 png_set_shift(
m_png, & bits);
372 #endif // PNG_READ_SHIFT_SUPPORTED || PNG_WRITE_SHIFT_SUPPORTED 374 #if defined(PNG_READ_INTERLACING_SUPPORTED) \ 375 || defined(PNG_WRITE_INTERLACING_SUPPORTED) 378 TRACE_IO_TRANSFORM(
"png_set_interlace_handling\n");
379 return png_set_interlace_handling(
m_png);
383 #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) 386 TRACE_IO_TRANSFORM(
"png_set_invert_mono\n");
387 png_set_invert_mono(
m_png);
391 #if defined(PNG_READ_16_TO_8_SUPPORTED) 394 TRACE_IO_TRANSFORM(
"png_set_strip_16\n");
395 png_set_strip_16(
m_png);
399 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) 402 TRACE_IO_TRANSFORM(
"png_set_read_user_transform_fn\n");
403 png_set_read_user_transform_fn(
m_png, transform_fn);
407 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) \ 408 || defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) 411 TRACE_IO_TRANSFORM(
"png_set_user_transform_info: bit_depth=%d," 412 " channels=%d\n", bit_depth, channels);
414 png_set_user_transform_info(
m_png, info, bit_depth, channels);
421 return png_get_io_ptr(
m_png);
449 longjmp(png_jmpbuf(
m_png), -1);
467 #endif // PNGPP_IO_BASE_HPP_INCLUDED end_info m_end_info
Definition: io_base.hpp:461
int get_bit_depth() const
Definition: io_base.hpp:150
filter_type get_filter_type() const
Definition: image_info.hpp:127
void set_filter_type(filter_type filter)
Definition: io_base.hpp:185
png_info * get_png_info() const
Definition: info_base.hpp:59
void set_invert_alpha() const
Definition: io_base.hpp:284
void set_filler(uint_32 filler, filler_type type) const
Definition: io_base.hpp:292
uint_32 get_width() const
Definition: image_info.hpp:67
void set_strip_16() const
Definition: io_base.hpp:392
void set_read_user_transform(png_user_transform_ptr transform_fn)
Definition: io_base.hpp:400
filler_type
Definition: types.hpp:66
void set_color_type(color_type color_space)
Definition: image_info.hpp:92
interlace_type
Definition: types.hpp:79
void set_height(uint_32 height)
Definition: io_base.hpp:135
Base class for PNG reader/writer classes.
Definition: io_base.hpp:62
png_struct * get_png_struct() const
Definition: io_base.hpp:82
bool is_error() const
Definition: io_base.hpp:442
color_type get_color_type() const
Definition: io_base.hpp:140
void set_filter_type(filter_type filter)
Definition: image_info.hpp:132
Internal class to hold PNG ending info.
Definition: end_info.hpp:44
void set_bgr() const
Definition: io_base.hpp:220
io_base(png_struct *png)
Definition: io_base.hpp:68
filter_type
Definition: types.hpp:91
void set_interlace_type(interlace_type interlace)
Definition: image_info.hpp:112
info m_info
Definition: io_base.hpp:460
void set_packing() const
Definition: io_base.hpp:320
png_color_8 color_info
Definition: types.hpp:43
static void raise_error(png_struct *png, char const *message)
Definition: io_base.hpp:452
uint_32 get_height() const
Definition: io_base.hpp:130
uint_32 get_height() const
Definition: image_info.hpp:77
std::string m_error
Definition: io_base.hpp:462
Holds information about PNG image.
Definition: image_info.hpp:47
filter_type get_filter_type() const
Definition: io_base.hpp:180
~io_base()
Definition: io_base.hpp:75
void raise_error()
Definition: io_base.hpp:447
color_type
Definition: types.hpp:46
void set_gray_1_2_4_to_8() const
Definition: io_base.hpp:200
void set_shift(byte red_bits, byte green_bits, byte blue_bits, byte alpha_bits=0) const
Definition: io_base.hpp:337
void set_bit_depth(int bit_depth)
Definition: io_base.hpp:155
void set_strip_alpha() const
Definition: io_base.hpp:266
bool has_chunk(chunk id)
Definition: io_base.hpp:192
png_struct * m_png
Definition: io_base.hpp:459
void set_add_alpha(uint_32 filler, filler_type type) const
Definition: io_base.hpp:301
void set_gray_to_rgb() const
Definition: io_base.hpp:228
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
end_info & get_end_info()
Definition: io_base.hpp:107
compression_type
Definition: types.hpp:85
void set_tRNS_to_alpha() const
Definition: io_base.hpp:212
void set_width(uint_32 width)
Definition: image_info.hpp:72
int get_bit_depth() const
Definition: image_info.hpp:97
void set_image_info(image_info const &info)
Definition: io_base.hpp:102
png_uint_32 uint_32
Definition: types.hpp:41
png_fixed_point fixed_point
Definition: types.hpp:42
interlace_type get_interlace_type() const
Definition: image_info.hpp:107
png_byte byte
Definition: types.hpp:39
end_info const & get_end_info() const
Definition: io_base.hpp:112
compression_type get_compression_type() const
Definition: image_info.hpp:117
int set_interlace_handling() const
Definition: io_base.hpp:376
compression_type get_compression_type() const
Definition: io_base.hpp:170
void set_color_type(color_type color_space)
Definition: io_base.hpp:145
chunk
Definition: types.hpp:98
void set_bit_depth(int bit_depth)
Definition: image_info.hpp:102
info & get_info()
Definition: io_base.hpp:87
void reset_error()
Definition: io_base.hpp:430
void set_interlace_type(interlace_type interlace)
Definition: io_base.hpp:165
void set_compression_type(compression_type compression)
Definition: image_info.hpp:122
info const & get_info() const
Definition: io_base.hpp:92
void set_rgb_to_gray(rgb_to_gray_error_action error_action=rgb_to_gray_silent, fixed_point red_weight=-1, fixed_point green_weight=-1) const
Definition: io_base.hpp:248
void set_height(uint_32 height)
Definition: image_info.hpp:82
void set_palette_to_rgb() const
Definition: io_base.hpp:206
void set_compression_type(compression_type compression)
Definition: io_base.hpp:175
void set_invert_mono() const
Definition: io_base.hpp:384
color_type get_color_type() const
Definition: image_info.hpp:87
Holds information about PNG image. Adapter class for IO image operations.
Definition: info.hpp:45
void set_shift(byte gray_bits, byte alpha_bits=0) const
Definition: io_base.hpp:357
void set_swap_alpha() const
Definition: io_base.hpp:275
void * get_io_ptr() const
Definition: io_base.hpp:419
void set_packswap() const
Definition: io_base.hpp:329
image_info const & get_image_info() const
Definition: io_base.hpp:97
uint_32 get_width() const
Definition: io_base.hpp:120
void set_width(uint_32 width)
Definition: io_base.hpp:125
interlace_type get_interlace_type() const
Definition: io_base.hpp:160
void set_user_transform_info(void *info, int bit_depth, int channels)
Definition: io_base.hpp:409
Exception class to represent runtime errors related to png++ operation.
Definition: error.hpp:57
rgb_to_gray_error_action
Definition: types.hpp:72
void set_error(char const *message)
Definition: io_base.hpp:424
void set_swap() const
Definition: io_base.hpp:312