コード例 #1
0
            static void handle_16(reader& io)
            {
                if (io.get_bit_depth() == 16 && traits::get_bit_depth() == 8)
                {
#ifdef PNG_READ_16_TO_8_SUPPORTED
                    io.set_strip_16();
#else
                    throw error("expected 8-bit data but found 16-bit;"
                                " recompile with PNG_READ_16_TO_8_SUPPORTED");
#endif
                }
                if (io.get_bit_depth() != 16 && traits::get_bit_depth() == 16)
                {
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
                    io.set_read_user_transform(expand_8_to_16);
                    io.set_user_transform_info(NULL, 16,
                                               traits::get_channels());
#else
                    throw error("expected 16-bit data but found 8-bit;"
                                " recompile with"
                                " PNG_READ_USER_TRANSFORM_SUPPORTED");
#endif
                }
            }
コード例 #2
0
            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
                    }
                }
            }