diff --git a/include/boost/gil/algorithm.hpp b/include/boost/gil/algorithm.hpp index d2c12124a..a8c0d6528 100644 --- a/include/boost/gil/algorithm.hpp +++ b/include/boost/gil/algorithm.hpp @@ -444,6 +444,11 @@ void destruct_range_impl( It first ++first; } } +<<<<<<< HEAD +======= +template GIL_FORCEINLINE +void destruct_range_impl(It, It, mpl::false_) {} +>>>>>>> 325700ffa2810faea2f41c77eded9992cbc7e91e template BOOST_FORCEINLINE void destruct_range_impl( It @@ -583,7 +588,11 @@ void default_construct_range_impl(It first, It last, mpl::true_) { } } +<<<<<<< HEAD template BOOST_FORCEINLINE +======= +template GIL_FORCEINLINE +>>>>>>> 325700ffa2810faea2f41c77eded9992cbc7e91e void default_construct_range_impl(It, It, mpl::false_) {} template BOOST_FORCEINLINE diff --git a/include/boost/gil/channel.hpp b/include/boost/gil/channel.hpp index d0af40440..a4f3b5b5d 100644 --- a/include/boost/gil/channel.hpp +++ b/include/boost/gil/channel.hpp @@ -248,6 +248,12 @@ BOOST_STATIC_ASSERT((boost::is_integral::value)); template class packed_channel_value { +<<<<<<< HEAD +======= + typedef typename detail::num_value_fn< NumBits >::type num_value_t; + static const num_value_t num_values = static_cast< num_value_t >( 1 ) << NumBits ; + +>>>>>>> 325700ffa2810faea2f41c77eded9992cbc7e91e public: typedef typename detail::min_fast_uint::type integer_t; @@ -264,11 +270,20 @@ public: BOOST_STATIC_CONSTANT(bool, is_mutable=true); packed_channel_value() {} +<<<<<<< HEAD packed_channel_value(integer_t v) { _value = static_cast< integer_t >( v & low_bits_mask_t::sig_bits_fast ); } template packed_channel_value(Scalar v) { _value = packed_channel_value( static_cast< integer_t >( v ) ); } static unsigned int num_bits() { return NumBits; } +======= + packed_channel_value(integer_t v) { _value = static_cast< integer_t >( v % num_values ); } + packed_channel_value(const packed_channel_value& v) : _value(v._value) {} + template packed_channel_value(Scalar v) { _value = static_cast< integer_t >( v ) % num_values; } + + static unsigned int num_bits() { return NumBits; } + +>>>>>>> 325700ffa2810faea2f41c77eded9992cbc7e91e operator integer_t() const { return _value; } private: diff --git a/include/boost/gil/extension/dynamic_image/any_image.hpp b/include/boost/gil/extension/dynamic_image/any_image.hpp index 3c4445ff1..6cba99d7b 100644 --- a/include/boost/gil/extension/dynamic_image/any_image.hpp +++ b/include/boost/gil/extension/dynamic_image/any_image.hpp @@ -93,7 +93,11 @@ public: template any_image& operator=(const T& obj) { parent_t::operator=(obj); return *this; } any_image& operator=(const any_image& v) { parent_t::operator=((const parent_t&)v); return *this;} +<<<<<<< HEAD template any_image& operator=(const any_image& v) { parent_t::operator=((const variant&)v); return *this;} +======= + template any_image& operator=(const any_image& v) { parent_t::operator=((const variant&)v); return *this;} +>>>>>>> 325700ffa2810faea2f41c77eded9992cbc7e91e void recreate(const point_t& dims, unsigned alignment=1) { apply_operation(*this,detail::recreate_image_fnobj(dims,alignment)); } void recreate(x_coord_t width, y_coord_t height, unsigned alignment=1) { recreate(point2(width,height),alignment); } diff --git a/include/boost/gil/extension/dynamic_image/any_image_view.hpp b/include/boost/gil/extension/dynamic_image/any_image_view.hpp index 74564cf86..03e2a3b4e 100644 --- a/include/boost/gil/extension/dynamic_image/any_image_view.hpp +++ b/include/boost/gil/extension/dynamic_image/any_image_view.hpp @@ -76,7 +76,11 @@ public: template any_image_view& operator=(const T& obj) { parent_t::operator=(obj); return *this; } any_image_view& operator=(const any_image_view& v) { parent_t::operator=((const parent_t&)v); return *this;} +<<<<<<< HEAD template any_image_view& operator=(const any_image_view& v) { parent_t::operator=((const variant&)v); return *this;} +======= + template any_image_view& operator=(const any_image_view& v) { parent_t::operator=((const variant&)v); return *this;} +>>>>>>> 325700ffa2810faea2f41c77eded9992cbc7e91e std::size_t num_channels() const { return apply_operation(*this, detail::any_type_get_num_channels()); } point_t dimensions() const { return apply_operation(*this, detail::any_type_get_dimensions()); } diff --git a/include/boost/gil/extension/dynamic_image/apply_operation_base.hpp b/include/boost/gil/extension/dynamic_image/apply_operation_base.hpp index 2204a93b0..2f049a2e9 100644 --- a/include/boost/gil/extension/dynamic_image/apply_operation_base.hpp +++ b/include/boost/gil/extension/dynamic_image/apply_operation_base.hpp @@ -141,7 +141,11 @@ namespace detail { template struct reduce_bind1 { const T2& _t2; +<<<<<<< HEAD Op& _op; +======= + Op& _op; +>>>>>>> 325700ffa2810faea2f41c77eded9992cbc7e91e typedef typename Op::result_type result_type; @@ -154,7 +158,11 @@ namespace detail { struct reduce_bind2 { const Bits1& _bits1; std::size_t _index1; +<<<<<<< HEAD Op& _op; +======= + Op& _op; +>>>>>>> 325700ffa2810faea2f41c77eded9992cbc7e91e typedef typename Op::result_type result_type; diff --git a/include/boost/gil/extension/dynamic_image/variant.hpp b/include/boost/gil/extension/dynamic_image/variant.hpp index 1ab53b549..6fb7be3cd 100644 --- a/include/boost/gil/extension/dynamic_image/variant.hpp +++ b/include/boost/gil/extension/dynamic_image/variant.hpp @@ -100,7 +100,12 @@ public: virtual ~variant() { apply_operation(*this, detail::destructor_op()); } // Throws std::bad_cast if T is not in Types - template explicit variant(const T& obj){ _index=type_id(); if (_index==NUM_TYPES) throw std::bad_cast(); detail::copy_construct_in_place(obj, _bits); } + template explicit variant(const T& obj){ _index=type_id(); if (_index==NUM_TYPES) throw std::bad_cast(); detail::copy_construct_in_place(obj, _bits); } + + template explicit variant(const variant& obj) : _index(apply_operation(obj,detail::type_to_index_fn())) { + if (_index==NUM_TYPES) throw std::bad_cast(); + apply_operation(obj, detail::copy_construct_in_place_fn(_bits)); + } template explicit variant(const variant& obj) : _index(apply_operation(obj,detail::type_to_index_fn())) { if (_index==NUM_TYPES) throw std::bad_cast(); @@ -132,7 +137,7 @@ public: private: template static std::size_t type_id() { return detail::type_to_index::value; } - template friend void swap(variant& x, variant& y); + template friend void swap(variant& x, variant& y); template friend typename UnaryOp::result_type apply_operation(variant& var, UnaryOp op); template friend typename UnaryOp::result_type apply_operation(const variant& var, UnaryOp op); template friend typename BinaryOp::result_type apply_operation(const variant& arg1, const variant& arg2, BinaryOp op); @@ -171,9 +176,15 @@ namespace detail { template struct type_to_index_fn { +<<<<<<< HEAD typedef std::size_t result_type; template result_type operator()(const T&) const { return detail::type_to_index::value; } +======= + typedef std::size_t result_type; + + template result_type operator()(const T&) const { return detail::type_to_index::value; } +>>>>>>> 325700ffa2810faea2f41c77eded9992cbc7e91e }; } diff --git a/include/boost/gil/extension/io/png_dynamic_io.hpp b/include/boost/gil/extension/io/png_dynamic_io.hpp new file mode 100644 index 000000000..a3a25a97f --- /dev/null +++ b/include/boost/gil/extension/io/png_dynamic_io.hpp @@ -0,0 +1,141 @@ +/* + Copyright 2005-2007 Adobe Systems Incorporated + + Use, modification and distribution are subject to the Boost Software License, + Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt). + + See http://opensource.adobe.com/gil for most recent version including documentation. +*/ + +/*************************************************************************************************/ + +#ifndef GIL_PNG_DYNAMIC_IO_H +#define GIL_PNG_DYNAMIC_IO_H + +/// \file +/// \brief Support for reading and writing PNG files +/// Requires libpng and zlib! +/// +/// \author Hailin Jin and Lubomir Bourdev \n +/// Adobe Systems Incorporated +/// \date 2005-2007 \n Last updated June 10, 2006 +// +// We are currently providing the following functions: +// template void png_read_image(const char*,any_image&) +// template void png_read_image(FILE*,any_image&,std::size_t) +// template void png_write_view(const char*,const any_image_view&) +// template void png_write_view(FILE*,const any_image_view&) + + +#include +#include +#include +#include +#include "../dynamic_image/dynamic_image_all.hpp" +#include "io_error.hpp" +#include "png_io.hpp" +#include "png_io_private.hpp" +#include "dynamic_io.hpp" + +namespace boost { namespace gil { + +namespace detail { + +struct png_write_is_supported { + template struct apply + : public mpl::bool_::is_supported> {}; +}; + +class png_writer_dynamic : public png_writer { +public: + png_writer_dynamic(FILE* file ) : png_writer(file) {} + png_writer_dynamic(const char* filename) : png_writer(filename){} + + template + void write_view(const any_image_view& runtime_view) { + dynamic_io_fnobj op(this); + apply_operation(runtime_view,op); + } +}; + +class png_type_format_checker { + int _bit_depth; + int _color_type; +public: + png_type_format_checker(int bit_depth_in,int color_type_in) : + _bit_depth(bit_depth_in),_color_type(color_type_in) {} + template + bool apply() { + return png_read_support::bit_depth==_bit_depth && + png_read_support::color_type==_color_type; + } +}; + +struct png_read_is_supported { + template struct apply + : public mpl::bool_::is_supported> {}; +}; + +class png_reader_dynamic : public png_reader { +public: + png_reader_dynamic(FILE* file) : png_reader(file) {} + png_reader_dynamic(const char* filename) : png_reader(filename){} + + template + void read_image(any_image& im) { + png_uint_32 width, height; + int bit_depth, color_type, interlace_type; + png_get_IHDR(_png_ptr, _info_ptr, + &width, &height,&bit_depth,&color_type,&interlace_type, + NULL, NULL); + if (!construct_matched(im,png_type_format_checker(bit_depth,color_type))) { + io_error("png_reader_dynamic::read_image(): no matching image type between those of the given any_image and that of the file"); + } else { + im.recreate(width,height); + dynamic_io_fnobj op(this); + apply_operation(view(im),op); + } + } +}; + +} // namespace detail + +/// \ingroup PNG_IO +/// \brief reads a PNG image into a run-time instantiated image +/// Opens the given png file name, selects the first type in Images whose color space and channel are compatible to those of the image file +/// and creates a new image of that type with the dimensions specified by the image file. +/// Throws std::ios_base::failure if none of the types in Images are compatible with the type on disk. +template +inline void png_read_image(const char* filename,any_image& im) { + detail::png_reader_dynamic m(filename); + m.read_image(im); +} + +/// \ingroup PNG_IO +/// \brief reads a PNG image into a run-time instantiated image +template +inline void png_read_image(const std::string& filename,any_image& im) { + png_read_image(filename.c_str(),im); +} + +/// \ingroup PNG_IO +/// \brief Saves the currently instantiated view to a png file specified by the given png image file name. +/// Throws std::ios_base::failure if the currently instantiated view type is not supported for writing by the I/O extension +/// or if it fails to create the file. +template +inline void png_write_view(const char* filename,const any_image_view& runtime_view) { + detail::png_writer_dynamic m(filename); + m.write_view(runtime_view); +} + +/// \ingroup PNG_IO +/// \brief Saves the currently instantiated view to a png file specified by the given png image file name. +template +inline void png_write_view(const std::string& filename,const any_image_view& runtime_view) { + png_write_view(filename.c_str(),runtime_view); +} + +} } // namespace boost::gil + +#endif diff --git a/include/boost/gil/extension/io/png_io_private.hpp b/include/boost/gil/extension/io/png_io_private.hpp new file mode 100644 index 000000000..a0ee57be5 --- /dev/null +++ b/include/boost/gil/extension/io/png_io_private.hpp @@ -0,0 +1,360 @@ +/* + Copyright 2005-2007 Adobe Systems Incorporated + + Use, modification and distribution are subject to the Boost Software License, + Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt). + + See http://stlab.adobe.com/gil for most recent version including documentation. +*/ +/*************************************************************************************************/ + +#ifndef GIL_PNG_IO_PRIVATE_H +#define GIL_PNG_IO_PRIVATE_H + +/// \file +/// \brief Internal support for reading and writing PNG files +/// \author Hailin Jin and Lubomir Bourdev \n +/// Adobe Systems Incorporated +/// \date 2005-2007 \n Last updated August 14, 2007 + +#include +#include +#include +#include "../../gil_all.hpp" +#include "io_error.hpp" +#include + +namespace boost { namespace gil { + +namespace detail { + +static const std::size_t PNG_BYTES_TO_CHECK = 4; + +// lbourdev: These can be greatly simplified, for example: +template struct png_color_type {BOOST_STATIC_CONSTANT(int,color_type=0);}; +template<> struct png_color_type { BOOST_STATIC_CONSTANT(int,color_type=PNG_COLOR_TYPE_GRAY); }; +template<> struct png_color_type { BOOST_STATIC_CONSTANT(int,color_type=PNG_COLOR_TYPE_RGB); }; +template<> struct png_color_type { BOOST_STATIC_CONSTANT(int,color_type=PNG_COLOR_TYPE_RGBA); }; + +template struct png_is_supported {BOOST_STATIC_CONSTANT(bool,value=false);}; +template <> struct png_is_supported {BOOST_STATIC_CONSTANT(bool,value=true);}; +template <> struct png_is_supported {BOOST_STATIC_CONSTANT(bool,value=true);}; +template <> struct png_is_supported {BOOST_STATIC_CONSTANT(bool,value=true);}; +template <> struct png_is_supported {BOOST_STATIC_CONSTANT(bool,value=true);}; +template <> struct png_is_supported {BOOST_STATIC_CONSTANT(bool,value=true);}; +template <> struct png_is_supported {BOOST_STATIC_CONSTANT(bool,value=true);}; + +template struct png_bit_depth {BOOST_STATIC_CONSTANT(int,bit_depth=sizeof(Channel)*8);}; + +template +struct png_read_support_private { + BOOST_STATIC_CONSTANT(bool,is_supported=false); + BOOST_STATIC_CONSTANT(int,bit_depth=0); + BOOST_STATIC_CONSTANT(int,color_type=0); +}; +template <> +struct png_read_support_private { + BOOST_STATIC_CONSTANT(bool,is_supported=true); + BOOST_STATIC_CONSTANT(int,bit_depth=8); + BOOST_STATIC_CONSTANT(int,color_type=PNG_COLOR_TYPE_GRAY); +}; +template <> +struct png_read_support_private { + BOOST_STATIC_CONSTANT(bool,is_supported=true); + BOOST_STATIC_CONSTANT(int,bit_depth=8); + BOOST_STATIC_CONSTANT(int,color_type=PNG_COLOR_TYPE_RGB); +}; +template <> +struct png_read_support_private { + BOOST_STATIC_CONSTANT(bool,is_supported=true); + BOOST_STATIC_CONSTANT(int,bit_depth=8); + BOOST_STATIC_CONSTANT(int,color_type=PNG_COLOR_TYPE_RGBA); +}; +template <> +struct png_read_support_private { + BOOST_STATIC_CONSTANT(bool,is_supported=true); + BOOST_STATIC_CONSTANT(int,bit_depth=16); + BOOST_STATIC_CONSTANT(int,color_type=PNG_COLOR_TYPE_GRAY); +}; +template <> +struct png_read_support_private { + BOOST_STATIC_CONSTANT(bool,is_supported=true); + BOOST_STATIC_CONSTANT(int,bit_depth=16); + BOOST_STATIC_CONSTANT(int,color_type=PNG_COLOR_TYPE_RGB); +}; +template <> +struct png_read_support_private { + BOOST_STATIC_CONSTANT(bool,is_supported=true); + BOOST_STATIC_CONSTANT(int,bit_depth=16); + BOOST_STATIC_CONSTANT(int,color_type=PNG_COLOR_TYPE_RGBA); +}; + +template +struct png_write_support_private { + BOOST_STATIC_CONSTANT(bool,is_supported=false); + BOOST_STATIC_CONSTANT(int,bit_depth=0); + BOOST_STATIC_CONSTANT(int,color_type=0); +}; +template <> +struct png_write_support_private { + BOOST_STATIC_CONSTANT(bool,is_supported=true); + BOOST_STATIC_CONSTANT(int,bit_depth=8); + BOOST_STATIC_CONSTANT(int,color_type=PNG_COLOR_TYPE_GRAY); +}; +template <> +struct png_write_support_private { + BOOST_STATIC_CONSTANT(bool,is_supported=true); + BOOST_STATIC_CONSTANT(int,bit_depth=8); + BOOST_STATIC_CONSTANT(int,color_type=PNG_COLOR_TYPE_RGB); +}; +template <> +struct png_write_support_private { + BOOST_STATIC_CONSTANT(bool,is_supported=true); + BOOST_STATIC_CONSTANT(int,bit_depth=8); + BOOST_STATIC_CONSTANT(int,color_type=PNG_COLOR_TYPE_RGBA); +}; +template <> +struct png_write_support_private { + BOOST_STATIC_CONSTANT(bool,is_supported=true); + BOOST_STATIC_CONSTANT(int,bit_depth=16); + BOOST_STATIC_CONSTANT(int,color_type=PNG_COLOR_TYPE_GRAY); +}; +template <> +struct png_write_support_private { + BOOST_STATIC_CONSTANT(bool,is_supported=true); + BOOST_STATIC_CONSTANT(int,bit_depth=16); + BOOST_STATIC_CONSTANT(int,color_type=PNG_COLOR_TYPE_RGB); +}; +template <> +struct png_write_support_private { + BOOST_STATIC_CONSTANT(bool,is_supported=true); + BOOST_STATIC_CONSTANT(int,bit_depth=16); + BOOST_STATIC_CONSTANT(int,color_type=PNG_COLOR_TYPE_RGBA); +}; + +class png_reader : public file_mgr { +protected: + png_structp _png_ptr; + png_infop _info_ptr; + + void init() { + char buf[PNG_BYTES_TO_CHECK]; + // read in some of the signature bytes + io_error_if(fread(buf, 1, PNG_BYTES_TO_CHECK, get()) != detail::PNG_BYTES_TO_CHECK, + "png_check_validity: fail to read file"); + // compare the first PNG_BYTES_TO_CHECK bytes of the signature. + io_error_if(png_sig_cmp((png_bytep)buf, (png_size_t)0, detail::PNG_BYTES_TO_CHECK)!=0, + "png_check_validity: invalid png file"); + + _png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,NULL,NULL,NULL); + io_error_if(_png_ptr==NULL,"png_get_file_size: fail to call png_create_write_struct()"); + // allocate/initialize the image information data + _info_ptr = png_create_info_struct(_png_ptr); + if (_info_ptr == NULL) { + png_destroy_read_struct(&_png_ptr,NULL,NULL); + io_error("png_get_file_size: fail to call png_create_info_struct()"); + } + if (setjmp(png_jmpbuf(_png_ptr))) { + //free all of the memory associated with the png_ptr and info_ptr + png_destroy_read_struct(&_png_ptr, &_info_ptr, NULL); + io_error("png_get_file_size: fail to call setjmp()"); + } + png_init_io(_png_ptr, get()); + png_set_sig_bytes(_png_ptr,PNG_BYTES_TO_CHECK); + png_read_info(_png_ptr, _info_ptr); + if (little_endian() && png_get_bit_depth(_png_ptr,_info_ptr)>8) + png_set_swap(_png_ptr); + } +public: + png_reader(FILE* file ) : file_mgr(file) { init(); } + png_reader(const char* filename) : file_mgr(filename, "rb") { init(); } + + ~png_reader() { + png_destroy_read_struct(&_png_ptr,&_info_ptr,NULL); + } + point2 get_dimensions() { + return point2(png_get_image_width(_png_ptr,_info_ptr), + png_get_image_height(_png_ptr,_info_ptr)); + } + template + void apply(const View& view) { + png_uint_32 width, height; + int bit_depth, color_type, interlace_type; + png_get_IHDR(_png_ptr, _info_ptr, + &width, &height,&bit_depth,&color_type,&interlace_type, + NULL, NULL); + io_error_if(((png_uint_32)view.width()!=width || (png_uint_32)view.height()!= height), + "png_read_view: input view size does not match PNG file size"); + + if(png_read_support_private::type, + typename color_space_type::type>::bit_depth!=bit_depth || + png_read_support_private::type, + typename color_space_type::type>::color_type!=color_type) + io_error("png_read_view: input view type is incompatible with the image type"); + + std::vector::type, + layout::type> > > row(width); + for(png_uint_32 y=0;y + void read_image(Image& im) { + im.recreate(get_dimensions()); + apply(view(im)); + } +}; + +// This code will be simplified... +template +class png_reader_color_convert : public png_reader { +private: + CC _cc; +public: + png_reader_color_convert(FILE* file ,CC cc_in) : png_reader(file),_cc(cc_in) {} + png_reader_color_convert(FILE* file ) : png_reader(file) {} + png_reader_color_convert(const char* filename,CC cc_in) : png_reader(filename),_cc(cc_in) {} + png_reader_color_convert(const char* filename) : png_reader(filename) {} + template + void apply(const View& view) { + png_uint_32 width, height; + int bit_depth, color_type, interlace_type; + png_get_IHDR(_png_ptr, _info_ptr, + &width, &height,&bit_depth,&color_type,&interlace_type, + int_p_NULL, int_p_NULL); + io_error_if(((png_uint_32)view.width()!=width || (png_uint_32)view.height()!= height), + "png_reader_color_convert::apply(): input view size does not match PNG file size"); + switch (color_type) { + case PNG_COLOR_TYPE_GRAY: + switch (bit_depth) { + case 8: { + std::vector row(width); + for(png_uint_32 y=0;y(_cc)); + } + break; + } + case 16: { + std::vector row(width); + for(png_uint_32 y=0;y(_cc)); + } + break; + } + default: io_error("png_reader_color_convert::apply(): unknown combination of color type and bit depth"); + } + break; + case PNG_COLOR_TYPE_RGB: + switch (bit_depth) { + case 8: { + std::vector row(width); + for(png_uint_32 y=0;y(_cc)); + } + break; + } + case 16: { + std::vector row(width); + for(png_uint_32 y=0;y(_cc)); + } + break; + } + default: io_error("png_reader_color_convert::apply(): unknown combination of color type and bit depth"); + } + break; + case PNG_COLOR_TYPE_RGBA: + switch (bit_depth) { + case 8: { + std::vector row(width); + for(png_uint_32 y=0;y(_cc)); + } + break; + } + case 16: { + std::vector row(width); + for(png_uint_32 y=0;y(_cc)); + } + break; + } + default: io_error("png_reader_color_convert::apply(): unknown combination of color type and bit depth"); + } + break; + default: io_error("png_reader_color_convert::apply(): unknown color type"); + } + png_read_end(_png_ptr,NULL); + } + template + void read_image(Image& im) { + im.recreate(get_dimensions()); + apply(view(im)); + } +}; + + +class png_writer : public file_mgr { +protected: + png_structp _png_ptr; + png_infop _info_ptr; + + void init() { + _png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,NULL,NULL,NULL); + io_error_if(!_png_ptr,"png_write_initialize: fail to call png_create_write_struct()"); + _info_ptr = png_create_info_struct(_png_ptr); + if (!_info_ptr) { + png_destroy_write_struct(&_png_ptr,NULL); + io_error("png_write_initialize: fail to call png_create_info_struct()"); + } + if (setjmp(png_jmpbuf(_png_ptr))) { + png_destroy_write_struct(&_png_ptr, &_info_ptr); + io_error("png_write_initialize: fail to call setjmp(png_jmpbuf())"); + } + png_init_io(_png_ptr,get()); + } +public: + png_writer(FILE* file ) : file_mgr(file) { init(); } + png_writer(const char* filename) : file_mgr(filename, "wb") { init(); } + + ~png_writer() { + png_destroy_write_struct(&_png_ptr,&_info_ptr); + } + template + void apply(const View& view) { + png_set_IHDR(_png_ptr, _info_ptr, view.width(), view.height(), + png_write_support_private::type, + typename color_space_type::type>::bit_depth, + png_write_support_private::type, + typename color_space_type::type>::color_type, + PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_DEFAULT,PNG_FILTER_TYPE_DEFAULT); + png_write_info(_png_ptr,_info_ptr); + if (little_endian() && + png_write_support_private::type, + typename color_space_type::type>::bit_depth>8) + png_set_swap(_png_ptr); + std::vector::type, + layout::type> > > row(view.width()); + for(int y=0;y +#include +#include +#include +#include +#include "../../gil_all.hpp" +#include "io_error.hpp" + +namespace boost { namespace gil { + +namespace detail { + +template +struct tiff_read_support_private { + BOOST_STATIC_CONSTANT(bool,is_supported=false); + BOOST_STATIC_CONSTANT(int,bit_depth=0); + BOOST_STATIC_CONSTANT(int,color_type=0); +}; +template <> +struct tiff_read_support_private { + BOOST_STATIC_CONSTANT(bool,is_supported=true); + BOOST_STATIC_CONSTANT(int,bit_depth=8); + BOOST_STATIC_CONSTANT(int,color_type=PHOTOMETRIC_MINISBLACK); +}; +template <> +struct tiff_read_support_private { + BOOST_STATIC_CONSTANT(bool,is_supported=true); + BOOST_STATIC_CONSTANT(int,bit_depth=8); + BOOST_STATIC_CONSTANT(int,color_type=PHOTOMETRIC_RGB); +}; +template <> +struct tiff_read_support_private { + BOOST_STATIC_CONSTANT(bool,is_supported=true); + BOOST_STATIC_CONSTANT(int,bit_depth=16); + BOOST_STATIC_CONSTANT(int,color_type=PHOTOMETRIC_MINISBLACK); +}; +template <> +struct tiff_read_support_private { + BOOST_STATIC_CONSTANT(bool,is_supported=true); + BOOST_STATIC_CONSTANT(int,bit_depth=16); + BOOST_STATIC_CONSTANT(int,color_type=PHOTOMETRIC_RGB); +}; +template <> +struct tiff_read_support_private { + BOOST_STATIC_CONSTANT(bool,is_supported=true); + BOOST_STATIC_CONSTANT(int,bit_depth=32); + BOOST_STATIC_CONSTANT(int,color_type=PHOTOMETRIC_MINISBLACK); +}; +template <> +struct tiff_read_support_private { + BOOST_STATIC_CONSTANT(bool,is_supported=true); + BOOST_STATIC_CONSTANT(int,bit_depth=32); + BOOST_STATIC_CONSTANT(int,color_type=PHOTOMETRIC_RGB); +}; + +template +struct tiff_write_support_private { + BOOST_STATIC_CONSTANT(bool,is_supported=false); + BOOST_STATIC_CONSTANT(int,bit_depth=0); + BOOST_STATIC_CONSTANT(int,color_type=0); +}; +template <> +struct tiff_write_support_private { + BOOST_STATIC_CONSTANT(bool,is_supported=true); + BOOST_STATIC_CONSTANT(int,bit_depth=8); + BOOST_STATIC_CONSTANT(int,color_type=PHOTOMETRIC_MINISBLACK); +}; +template <> +struct tiff_write_support_private { + BOOST_STATIC_CONSTANT(bool,is_supported=true); + BOOST_STATIC_CONSTANT(int,bit_depth=8); + BOOST_STATIC_CONSTANT(int,color_type=PHOTOMETRIC_RGB); +}; +template <> +struct tiff_write_support_private { + BOOST_STATIC_CONSTANT(bool,is_supported=true); + BOOST_STATIC_CONSTANT(int,bit_depth=16); + BOOST_STATIC_CONSTANT(int,color_type=PHOTOMETRIC_MINISBLACK); +}; +template <> +struct tiff_write_support_private { + BOOST_STATIC_CONSTANT(bool,is_supported=true); + BOOST_STATIC_CONSTANT(int,bit_depth=16); + BOOST_STATIC_CONSTANT(int,color_type=PHOTOMETRIC_RGB); +}; +template <> +struct tiff_write_support_private { + BOOST_STATIC_CONSTANT(bool,is_supported=true); + BOOST_STATIC_CONSTANT(int,bit_depth=32); + BOOST_STATIC_CONSTANT(int,color_type=PHOTOMETRIC_MINISBLACK); +}; +template <> +struct tiff_write_support_private { + BOOST_STATIC_CONSTANT(bool,is_supported=true); + BOOST_STATIC_CONSTANT(int,bit_depth=32); + BOOST_STATIC_CONSTANT(int,color_type=PHOTOMETRIC_RGB); +}; + +class tiff_reader { +protected: + TIFF *_tp; +public: + tiff_reader(const char* filename,tdir_t dirnum=0) { + io_error_if((_tp=TIFFOpen(filename,"r"))==NULL, + "tiff_reader: fail to open file"); + if(dirnum>0) { + io_error_if(TIFFSetDirectory(_tp,dirnum)!=1, + "tiff_reader: fail to set directory"); + } + } + ~tiff_reader() { TIFFClose(_tp); } + template + void apply(const View& view) { + unsigned short bps,photometric; + point2 dims=get_dimensions(); + io_error_if(TIFFGetField(_tp,TIFFTAG_BITSPERSAMPLE,&bps)!=1); + io_error_if(TIFFGetField(_tp,TIFFTAG_PHOTOMETRIC,&photometric)!=1); + io_error_if(dims!=view.dimensions(), + "tiff_read_view: input view size does not match TIFF file size"); + io_error_if(tiff_read_support_private::type, + typename color_space_type::type>::bit_depth!=bps || + tiff_read_support_private::type, + typename color_space_type::type>::color_type!=photometric, + "tiff_read_view: input view type is incompatible with the image type"); + std::size_t element_size=sizeof(pixel::type, + layout::type> >); + std::size_t size_to_allocate = (std::max)((std::size_t)view.width(), + (std::size_t)(TIFFScanlineSize(_tp)+element_size-1)/element_size); + std::vector::type, + layout::type> > > row(size_to_allocate); + for (int y=0;y get_dimensions() { + int w,h; + io_error_if(TIFFGetField(_tp,TIFFTAG_IMAGEWIDTH, &w)!=1); + io_error_if(TIFFGetField(_tp,TIFFTAG_IMAGELENGTH,&h)!=1); + return point2(w,h); + } + + template + void read_image(Image& im) { + im.recreate(get_dimensions()); + apply(view(im)); + } +}; + +// This code will be simplified... +template +class tiff_reader_color_convert : public tiff_reader { +private: + CC _cc; +public: + tiff_reader_color_convert(const char* filename,tdir_t dirnum=0) : + tiff_reader(filename,dirnum) {} + tiff_reader_color_convert(const char* filename,CC cc_in,tdir_t dirnum=0) : + tiff_reader(filename,dirnum),_cc(cc_in) {} + template + void apply(const View& view) { + point2 dims=get_dimensions(); + unsigned short bps,photometric; + io_error_if(TIFFGetField(_tp,TIFFTAG_BITSPERSAMPLE,&bps)!=1); + io_error_if(TIFFGetField(_tp,TIFFTAG_PHOTOMETRIC,&photometric)!=1); + io_error_if(dims!=view.dimensions(), + "tiff_reader_color_convert::apply(): input view size does not match TIFF file size"); + switch (photometric) { + case PHOTOMETRIC_MINISBLACK: { + switch (bps) { + case 8: { + std::size_t element_size=sizeof(gray8_pixel_t); + std::size_t size_to_allocate = (std::max)((std::size_t)view.width(), + (std::size_t)(TIFFScanlineSize(_tp)+element_size-1)/element_size); + std::vector row(size_to_allocate); + for (int y=0;y(_cc)); + } + break; + } + case 16: { + std::size_t element_size=sizeof(gray16_pixel_t); + std::size_t size_to_allocate = (std::max)((std::size_t)view.width(), + (std::size_t)(TIFFScanlineSize(_tp)+element_size-1)/element_size); + std::vector row(size_to_allocate); + for (int y=0;y(_cc)); + } + break; + } + case 32: { + std::size_t element_size=sizeof(gray32f_pixel_t); + std::size_t size_to_allocate = (std::max)((std::size_t)view.width(), + (std::size_t)(TIFFScanlineSize(_tp)+element_size-1)/element_size); + std::vector row(size_to_allocate); + for (int y=0;y(_cc)); + } + break; + } + default: + io_error("tiff_reader_color_convert::apply(): unknown combination of color type and bit depth"); + } + break; + } + case PHOTOMETRIC_RGB: { + switch (bps) { + case 8: { + std::size_t element_size=sizeof(rgb8_pixel_t); + std::size_t size_to_allocate = (std::max)((std::size_t)view.width(), + (std::size_t)(TIFFScanlineSize(_tp)+element_size-1)/element_size); + std::vector row(size_to_allocate); + for (int y=0;y(_cc)); + } + break; + } + case 16: { + std::size_t element_size=sizeof(rgb16_pixel_t); + std::size_t size_to_allocate = (std::max)((std::size_t)view.width(), + (std::size_t)(TIFFScanlineSize(_tp)+element_size-1)/element_size); + std::vector row(size_to_allocate); + for (int y=0;y(_cc)); + } + break; + } + case 32: { + std::size_t element_size=sizeof(rgb32f_pixel_t); + std::size_t size_to_allocate = (std::max)((std::size_t)view.width(), + (std::size_t)(TIFFScanlineSize(_tp)+element_size-1)/element_size); + std::vector row(size_to_allocate); + for (int y=0;y(_cc)); + } + break; + } + default: + io_error("tiff_reader_color_convert::apply(): unknown combination of color type and bit depth"); + } + break; + } + default: { + // reads an image in incompatible format via TIFFReadRGBAImage + rgba8_image_t rgbaImg(dims); + io_error_if(!TIFFReadRGBAImage(_tp, dims.x, dims.y, (uint32*)&gil::view(rgbaImg)(0,0), 0), + "tiff_reader_color_convert::unsupported image format"); + copy_and_convert_pixels(flipped_up_down_view(const_view(rgbaImg)), view, _cc); + } + } + } + template + void read_image(Image& im) { + im.recreate(get_dimensions()); + apply(view(im)); + } +}; + +class tiff_writer { +protected: + TIFF* _tp; +public: + tiff_writer(const char *filename) { + io_error_if((_tp=TIFFOpen(filename,"w"))==NULL, + "tiff_writer: fail to open file"); + } + ~tiff_writer() {TIFFClose(_tp);} + template + void apply(const View& view) { + io_error_if(TIFFSetField(_tp,TIFFTAG_IMAGELENGTH, view.height())!=1); + io_error_if(TIFFSetField(_tp,TIFFTAG_IMAGEWIDTH, view.width())!=1); + io_error_if(TIFFSetField(_tp,TIFFTAG_PHOTOMETRIC, tiff_write_support_private::type, + typename color_space_type::type>::color_type)!=1); + io_error_if(TIFFSetField(_tp,TIFFTAG_RESOLUTIONUNIT, RESUNIT_NONE)!=1); + io_error_if(TIFFSetField(_tp,TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG)!=1); + io_error_if(TIFFSetField(_tp,TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT)!=1); + io_error_if(TIFFSetField(_tp,TIFFTAG_SAMPLESPERPIXEL,num_channels::value)!=1); + io_error_if(TIFFSetField(_tp,TIFFTAG_BITSPERSAMPLE, tiff_write_support_private::type, + typename color_space_type::type>::bit_depth)!=1); + io_error_if(TIFFSetField(_tp,TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(_tp, 0))!=1); + std::vector::type, + layout::type> > > row(view.width()); + for (int y=0;y +struct tiff_read_support { + BOOST_STATIC_CONSTANT(bool,is_supported= + (detail::tiff_read_support_private::type, + typename color_space_type::type>::is_supported)); + BOOST_STATIC_CONSTANT(int,bit_depth= + (detail::tiff_read_support_private::type, + typename color_space_type::type>::bit_depth)); + BOOST_STATIC_CONSTANT(int,color_type= + (detail::tiff_read_support_private::type, + typename color_space_type::type>::color_type)); +}; + +/// \ingroup TIFF_IO +/// \brief Returns the number of directories in the TIFF file +inline int tiff_get_directory_count(const char* filename) { + TIFF *tif; + io_error_if((tif=TIFFOpen(filename,"r"))==NULL, + "tiff_get_count: fail to open file"); + + int dircount = 0; + do { + dircount++; + } while (TIFFReadDirectory(tif)); + + TIFFClose(tif); + return dircount; +} + +/// \ingroup TIFF_IO +/// \brief Returns the width and height of the TIFF file at the specified location. +/// Throws std::ios_base::failure if the location does not correspond to a valid TIFF file +inline point2 tiff_read_dimensions(const char* filename,tdir_t dirnum=0) { + detail::tiff_reader m(filename,dirnum); + return m.get_dimensions(); +} + +/// \ingroup TIFF_IO +/// \brief Returns the width and height of the TIFF file at the specified location. +/// Throws std::ios_base::failure if the location does not correspond to a valid TIFF file +inline point2 tiff_read_dimensions(const std::string& filename,tdir_t dirnum=0) { + return tiff_read_dimensions(filename.c_str(),dirnum); +} + +/// \ingroup TIFF_IO +/// \brief Loads the image specified by the given tiff image file name into the given view. +/// Triggers a compile assert if the view color space and channel depth are not supported by the TIFF library or by the I/O extension. +/// Throws std::ios_base::failure if the file is not a valid TIFF file, or if its color space or channel depth are not +/// compatible with the ones specified by View, or if its dimensions don't match the ones of the view. +template +inline void tiff_read_view(const char* filename,const View& view,tdir_t dirnum=0) { + BOOST_STATIC_ASSERT(tiff_read_support::is_supported); + detail::tiff_reader m(filename,dirnum); + m.apply(view); +} + +/// \ingroup TIFF_IO +/// \brief Loads the image specified by the given tiff image file name into the given view. +template +inline void tiff_read_view(const std::string& filename,const View& view,tdir_t dirnum=0) { + tiff_read_view(filename.c_str(),view,dirnum); +} + +/// \ingroup TIFF_IO +/// \brief Allocates a new image whose dimensions are determined by the given tiff image file, and loads the pixels into it. +/// Triggers a compile assert if the image color space or channel depth are not supported by the TIFF library or by the I/O extension. +/// Throws std::ios_base::failure if the file is not a valid TIFF file, or if its color space or channel depth are not +/// compatible with the ones specified by Image +template +void tiff_read_image(const char* filename,Image& im,tdir_t dirnum=0) { + BOOST_STATIC_ASSERT(tiff_read_support::is_supported); + detail::tiff_reader m(filename,dirnum); + m.read_image(im); +} + +/// \ingroup TIFF_IO +/// \brief Allocates a new image whose dimensions are determined by the given tiff image file, and loads the pixels into it. +template +inline void tiff_read_image(const std::string& filename,Image& im,tdir_t dirnum=0) { + tiff_read_image(filename.c_str(),im,dirnum); +} + +/// \ingroup TIFF_IO +/// \brief Loads and color-converts the image specified by the given tiff image file name into the given view. +/// Throws std::ios_base::failure if the file is not a valid TIFF file, or if its dimensions don't match the ones of the view. +template +inline void tiff_read_and_convert_view(const char* filename,const View& view,CC cc,tdir_t dirnum=0) { + detail::tiff_reader_color_convert m(filename,cc,dirnum); + m.apply(view); +} + +/// \ingroup TIFF_IO +/// \brief Loads and color-converts the image specified by the given tiff image file name into the given view. +/// Throws std::ios_base::failure if the file is not a valid TIFF file, or if its dimensions don't match the ones of the view. +template +inline void tiff_read_and_convert_view(const char* filename,const View& view,tdir_t dirnum=0) { + detail::tiff_reader_color_convert m(filename,default_color_converter(),dirnum); + m.apply(view); +} + +/// \ingroup TIFF_IO +/// \brief Loads and color-converts the image specified by the given tiff image file name into the given view. +template +inline void tiff_read_and_convert_view(const std::string& filename,const View& view,CC cc,tdir_t dirnum=0) { + tiff_read_and_convert_view(filename.c_str(),view,cc,dirnum); +} + +/// \ingroup TIFF_IO +/// \brief Loads and color-converts the image specified by the given tiff image file name into the given view. +template +inline void tiff_read_and_convert_view(const std::string& filename,const View& view,tdir_t dirnum=0) { + tiff_read_and_convert_view(filename.c_str(),view,dirnum); +} + +/// \ingroup TIFF_IO +/// \brief Allocates a new image whose dimensions are determined by the given tiff image file, loads and color-converts the pixels into it. +/// Throws std::ios_base::failure if the file is not a valid TIFF file +template +void tiff_read_and_convert_image(const char* filename,Image& im,CC cc,tdir_t dirnum=0) { + detail::tiff_reader_color_convert m(filename,cc,dirnum); + m.read_image(im); +} + +/// \ingroup TIFF_IO +/// \brief Allocates a new image whose dimensions are determined by the given tiff image file, loads and color-converts the pixels into it. +/// Throws std::ios_base::failure if the file is not a valid TIFF file +template +void tiff_read_and_convert_image(const char* filename,Image& im,tdir_t dirnum=0) { + detail::tiff_reader_color_convert m(filename,default_color_converter(),dirnum); + m.read_image(im); +} + +/// \ingroup TIFF_IO +/// \brief Allocates a new image whose dimensions are determined by the given tiff image file, loads and color-converts the pixels into it. +template +inline void tiff_read_and_convert_image(const std::string& filename,Image& im,CC cc,tdir_t dirnum=0) { + tiff_read_and_convert_image(filename.c_str(),im,cc,dirnum); +} + +/// \ingroup TIFF_IO +/// \brief Allocates a new image whose dimensions are determined by the given tiff image file, loads and color-converts the pixels into it. +template +inline void tiff_read_and_convert_image(const std::string& filename,Image& im,tdir_t dirnum=0) { + tiff_read_and_convert_image(filename.c_str(),im,dirnum); +} + +/// \ingroup TIFF_IO +/// \brief Determines whether the given view type is supported for writing +template +struct tiff_write_support { + BOOST_STATIC_CONSTANT(bool,is_supported= + (detail::tiff_write_support_private::type, + typename color_space_type::type>::is_supported)); + BOOST_STATIC_CONSTANT(int,bit_depth= + (detail::tiff_write_support_private::type, + typename color_space_type::type>::bit_depth)); + BOOST_STATIC_CONSTANT(int,color_type= + (detail::tiff_write_support_private::type, + typename color_space_type::type>::color_type)); + BOOST_STATIC_CONSTANT(bool, value=is_supported); +}; + +/// \ingroup TIFF_IO +/// \brief Saves the view to a tiff file specified by the given tiff image file name. +/// Triggers a compile assert if the view color space and channel depth are not supported by the TIFF library or by the I/O extension. +/// Throws std::ios_base::failure if it fails to create the file. +template +inline void tiff_write_view(const char* filename,const View& view) { + BOOST_STATIC_ASSERT(tiff_write_support::is_supported); + detail::tiff_writer m(filename); + m.apply(view); +} + +/// \ingroup TIFF_IO +/// \brief Saves the view to a tiff file specified by the given tiff image file name. +template +inline void tiff_write_view(const std::string& filename,const View& view) { + tiff_write_view(filename.c_str(),view); +} + +} } // namespace boost::gil + +#endif diff --git a/include/boost/gil/image.hpp b/include/boost/gil/image.hpp index f2ecafcb2..0be752127 100644 --- a/include/boost/gil/image.hpp +++ b/include/boost/gil/image.hpp @@ -55,7 +55,11 @@ namespace boost { namespace gil { /// //////////////////////////////////////////////////////////////////////////////////////// +<<<<<<< HEAD template< typename Pixel, bool IsPlanar = false, typename Alloc=std::allocator > +======= +template< typename Pixel, bool IsPlanar = false, typename Alloc=std::allocator > +>>>>>>> 325700ffa2810faea2f41c77eded9992cbc7e91e class image { public: typedef typename Alloc::template rebind::other allocator_type; @@ -351,11 +355,16 @@ private: std::size_t total_allocated_size_in_bytes(const point_t& dimensions) const { +<<<<<<< HEAD typedef typename view_t::x_iterator x_iterator; +======= + typedef typename view_t::x_iterator x_iterator; +>>>>>>> 325700ffa2810faea2f41c77eded9992cbc7e91e // when value_type is a non-pixel, like int or float, num_channels< ... > doesn't work. const std::size_t _channels_in_image = mpl::eval_if< is_pixel< value_type > , num_channels< view_t > +<<<<<<< HEAD , mpl::int_< 1 > >::type::value; @@ -367,6 +376,19 @@ private: // return the size rounded up to the nearest byte return ( size_in_units + byte_to_memunit< x_iterator >::value - 1 ) / byte_to_memunit::value +======= + , mpl::int_< 1 > + >::type::value; + + std::size_t size_in_units = get_row_size_in_memunits(dimensions.x)*dimensions.y; + + if (IsPlanar) + size_in_units = size_in_units * _channels_in_image ; + + // return the size rounded up to the nearest byte + return ( size_in_units + byte_to_memunit< x_iterator >::value - 1 ) + / byte_to_memunit::value +>>>>>>> 325700ffa2810faea2f41c77eded9992cbc7e91e + ( _align_in_bytes > 0 ? _align_in_bytes - 1 : 0 ); // add extra padding in case we need to align the first image pixel } diff --git a/include/boost/gil/packed_pixel.hpp b/include/boost/gil/packed_pixel.hpp index 0087e2729..9083f3e94 100644 --- a/include/boost/gil/packed_pixel.hpp +++ b/include/boost/gil/packed_pixel.hpp @@ -81,9 +81,13 @@ struct packed_pixel { } packed_pixel(int chan0, int chan1, int chan2) : _bitfield(0) { BOOST_STATIC_ASSERT((num_channels::value==3)); +<<<<<<< HEAD gil::at_c<0>(*this) = chan0; gil::at_c<1>(*this) = chan1; gil::at_c<2>(*this) = chan2; +======= + gil::at_c<0>(*this)=chan0; gil::at_c<1>(*this)=chan1; gil::at_c<2>(*this)=chan2; +>>>>>>> 325700ffa2810faea2f41c77eded9992cbc7e91e } packed_pixel(int chan0, int chan1, int chan2, int chan3) : _bitfield(0) { BOOST_STATIC_ASSERT((num_channels::value==4)); diff --git a/include/boost/gil/planar_pixel_iterator.hpp b/include/boost/gil/planar_pixel_iterator.hpp index 666896291..6ed0dc300 100644 --- a/include/boost/gil/planar_pixel_iterator.hpp +++ b/include/boost/gil/planar_pixel_iterator.hpp @@ -117,7 +117,11 @@ private: void advance(std::ptrdiff_t d) { static_transform(*this,*this,std::bind2nd(detail::plus_asymmetric(),d)); } reference dereference() const { return this->template deref(); } +<<<<<<< HEAD std::ptrdiff_t distance_to(const planar_pixel_iterator& it) const { return gil::at_c<0>(it)-gil::at_c<0>(*this); } +======= + ptrdiff_t distance_to(const planar_pixel_iterator& it) const { return gil::at_c<0>(it)-gil::at_c<0>(*this); } +>>>>>>> 325700ffa2810faea2f41c77eded9992cbc7e91e bool equal(const planar_pixel_iterator& it) const { return gil::at_c<0>(*this)==gil::at_c<0>(it); } }; @@ -181,8 +185,13 @@ template inline std::ptrdiff_t memunit_step(const planar_pixel_iterator&) { return sizeof(typename std::iterator_traits::value_type); } template +<<<<<<< HEAD inline std::ptrdiff_t memunit_distance(const planar_pixel_iterator& p1, const planar_pixel_iterator& p2) { return memunit_distance(gil::at_c<0>(p1),gil::at_c<0>(p2)); +======= +inline std::ptrdiff_t memunit_distance(const planar_pixel_iterator& p1, const planar_pixel_iterator& p2) { + return memunit_distance(gil::at_c<0>(p1),gil::at_c<0>(p2)); +>>>>>>> 325700ffa2810faea2f41c77eded9992cbc7e91e } template diff --git a/test/pixel_iterator.cpp b/test/pixel_iterator.cpp index 856d3da3c..d5268dfe8 100644 --- a/test/pixel_iterator.cpp +++ b/test/pixel_iterator.cpp @@ -128,7 +128,11 @@ void test_pixel_iterator() { buf[2] = 219; iterator_t it( &buf[0], 0 ); +<<<<<<< HEAD +======= + +>>>>>>> 325700ffa2810faea2f41c77eded9992cbc7e91e ref_t p1 = *it; it++; ref_t p2 = *it; it++; ref_t p3 = *it; it++; @@ -148,6 +152,7 @@ void test_pixel_iterator() { unsigned char v8 = get_color( p8, gray_color_t() ); // all values should be 110b ( 6 ); +<<<<<<< HEAD assert( v1 == 6 ); assert( v2 == 6 ); assert( v3 == 6 ); @@ -156,6 +161,16 @@ void test_pixel_iterator() { assert( v6 == 6 ); assert( v7 == 6 ); assert( v8 == 6 ); +======= + //assert( v1 == 6 ); + //assert( v2 == 6 ); + //assert( v3 == 6 ); + //assert( v4 == 6 ); + //assert( v5 == 6 ); + //assert( v6 == 6 ); + //assert( v7 == 6 ); + //assert( v8 == 6 ); +>>>>>>> 325700ffa2810faea2f41c77eded9992cbc7e91e } // TODO: Make better tests. Use some code from below. @@ -337,6 +352,10 @@ BOOST_AUTO_TEST_SUITE(GIL_Tests) BOOST_AUTO_TEST_CASE(pixel_iterator_test) { test_pixel_iterator(); +<<<<<<< HEAD +======= + return 0; +>>>>>>> 325700ffa2810faea2f41c77eded9992cbc7e91e } BOOST_AUTO_TEST_SUITE_END()