static void handle_alpha(reader& io, uint_32 filler)
            {
                bool src_alpha = io.get_color_type() & color_mask_alpha;
                bool dst_alpha = traits::get_color_type() & color_mask_alpha;
                if (src_alpha && !dst_alpha)
                {
#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
                    io.set_strip_alpha();
#else
                    throw error("alpha channel unexpected;"
                                " recompile with"
                                " PNG_READ_STRIP_ALPHA_SUPPORTED");
#endif
                }
                if (!src_alpha && dst_alpha)
                {
#if defined(PNG_tRNS_SUPPORTED) && defined(PNG_READ_EXPAND_SUPPORTED)
                    if ((io.get_color_type() & color_mask_palette)
                        && io.has_chunk(chunk_tRNS))
                    {
                        io.set_tRNS_to_alpha();
                        return;
                    }
#endif
#if defined(PNG_READ_FILLER_SUPPORTED) && !defined(PNG_1_0_X)
                    io.set_add_alpha(filler, filler_after);
#else
                    throw error("expected alpha channel but none found;"
                                " recompile with PNG_READ_FILLER_SUPPORTED"
                                " and be sure to use libpng > 1.0.x");
#endif
                }
            }
            static void handle_rgb(reader& io)
            {
                bool src_rgb =
                    io.get_color_type() & (color_mask_rgb | color_mask_palette);
                bool dst_rgb = traits::get_color_type() & color_mask_rgb;
                if (src_rgb && !dst_rgb)
                {
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
                    io.set_rgb_to_gray(/*rgb_to_gray_error*/);
#else
                    throw error("grayscale data expected;"
                                " recompile with"
                                " PNG_READ_RGB_TO_GRAY_SUPPORTED");
#endif
                }
                if (!src_rgb && dst_rgb)
                {
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
                    io.set_gray_to_rgb();
#else
                    throw error("expected RGB data;"
                                " recompile with"
                                " PNG_READ_GRAY_TO_RGB_SUPPORTED");
#endif
                }
            }
            static void handle_gray(reader& io)
            {
                if ((io.get_color_type() & ~color_mask_alpha)
                    == color_type_gray)
                {
                    if (io.get_bit_depth() < 8 && traits::get_bit_depth() >= 8)
                    {
#ifdef PNG_READ_EXPAND_SUPPORTED
                        io.set_gray_1_2_4_to_8();
#else
                        throw error("convert_color_space: expected 8-bit data;"
                                    " recompile with"
                                    " PNG_READ_EXPAND_SUPPORTED");
#endif
                    }
                }
            }
            static void handle_palette(reader& io)
            {
                if (io.get_color_type() == color_type_palette)
                {
#ifdef PNG_READ_EXPAND_SUPPORTED
                    io.set_palette_to_rgb();

                    if (traits::get_color_type() != color_type_palette)
                    {
                        io.get_info().drop_palette();
                    }
#else
                    throw error("indexed colors unexpected;"
                                " recompile with PNG_READ_EXPAND_SUPPORTED");
#endif
                }
            }