|
From: Foster B. <fos...@us...> - 2006-02-03 18:33:54
|
Update of /cvsroot/adobe-source/sandbox/adobe-source/adobe/test/gil In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6755/adobe/test/gil Modified Files: dynamic_image.cpp gil_test_config.hpp image.cpp main.cpp pixel.cpp pixel_iterator.cpp stdafx.h Log Message: asl 1.0.13 Index: dynamic_image.cpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/test/gil/dynamic_image.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** dynamic_image.cpp 6 Jan 2006 18:03:03 -0000 1.1 --- dynamic_image.cpp 3 Feb 2006 18:33:39 -0000 1.2 *************** *** 1,6 **** /* ! Copyright 2005-2006 Adobe Systems Incorporated ! Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt ! or a copy at http://opensource.adobe.com/licenses.html) */ // image_test.cpp : Defines the entry point for the console application. --- 1,6 ---- /* ! Copyright 2005-2006 Adobe Systems Incorporated ! Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt ! or a copy at http://opensource.adobe.com/licenses.html) */ // image_test.cpp : Defines the entry point for the console application. *************** *** 33,49 **** template <typename V> const point2<int>& get_size(const image<V>& img) { ! return view(img).dimensions(); } // BEGIN GLUE CODE struct size2_fn { ! typedef const point2<int>& result_type; ! template <typename V> ! result_type operator()(const image<V>& img) const { return get_size(img); } }; template <typename C> const point2<int>& get_size(const variant<C>& img) { ! return img.apply_visitor(size2_fn()); } // END GLUE CODE --- 33,49 ---- template <typename V> const point2<int>& get_size(const image<V>& img) { ! return view(img).dimensions(); } // BEGIN GLUE CODE struct size2_fn { ! typedef const point2<int>& result_type; ! template <typename V> ! result_type operator()(const image<V>& img) const { return get_size(img); } }; template <typename C> const point2<int>& get_size(const variant<C>& img) { ! return img.apply_visitor(size2_fn()); } // END GLUE CODE *************** *** 52,91 **** // non-const operation struct set_firstp_fn { ! typedef void result_type; ! template <typename I> ! result_type operator()(image<I>& img) const { img(0,0)=img(1,0); } }; void test_dynamic_views(const std::string& fileName) { ! const std::string in_dir="C:\\test\\imgtest\\"; ! const std::string out_dir=in_dir+"newimg_output\\generic\\"; ! /* rgb8_image rgb8; ! load_image(rgb8, in_dir+fileName); ! gray8_image gray8(view(rgb8).dimensions()); ! copy_and_convert_pixels(view(rgb8),view(gray8)); ! save_view(view(gray8), out_dir+"gray8_converted.jpg"); */ ! any_image anyImg; ! load_image(anyImg, in_dir+fileName); ! std::cerr <<"File: "<<in_dir+fileName<<" height:"<<get_height(view(anyImg))<<" numChannels:"<<get_num_channels(view(anyImg))<<std::endl; /* This overflows the VC compiler ! any_image anyImg2; ! anyImg2.move_in(gray8_image(get_dimensions(view(anyImg)))); ! copy_and_convert_pixels(view(anyImg),view(anyImg2)); ! save_view(view(anyImg2), out_dir+"gray8_converted.jpg"); */ ! gray8_image gray8(get_dimensions(view(anyImg))); ! //copy_and_convert_pixels(view(anyImg),view(gray8)); copy_pixels(view(anyImg),view(gray8)); ! save_view(view(gray8), out_dir+"gray8_converted.jpg"); ! save_view(fliplr_view(view(anyImg)), out_dir+"fliplr.jpg"); ! save_view(flipud_view(view(anyImg)), out_dir+"flipud.jpg"); ! any_view subimageView=subimage_view(view(anyImg),point2<ptrdiff_t>(0,0),point2<ptrdiff_t>(100,100)); ! save_view(subimageView, out_dir+"subimage.jpg"); ! save_view(subsampled_view(rotated180_view(view(anyImg)), point2<ptrdiff_t>(2,1)),out_dir+"subsampled180rot.jpg"); } --- 52,91 ---- // non-const operation struct set_firstp_fn { ! typedef void result_type; ! template <typename I> ! result_type operator()(image<I>& img) const { img(0,0)=img(1,0); } }; void test_dynamic_views(const std::string& fileName) { ! const std::string in_dir="C:\\test\\imgtest\\"; ! const std::string out_dir=in_dir+"newimg_output\\generic\\"; ! /* rgb8_image rgb8; ! load_image(rgb8, in_dir+fileName); ! gray8_image gray8(view(rgb8).dimensions()); ! copy_and_convert_pixels(view(rgb8),view(gray8)); ! save_view(view(gray8), out_dir+"gray8_converted.jpg"); */ ! any_image anyImg; ! load_image(anyImg, in_dir+fileName); ! std::cerr <<"File: "<<in_dir+fileName<<" height:"<<get_height(view(anyImg))<<" numChannels:"<<get_num_channels(view(anyImg))<<std::endl; /* This overflows the VC compiler ! any_image anyImg2; ! anyImg2.move_in(gray8_image(get_dimensions(view(anyImg)))); ! copy_and_convert_pixels(view(anyImg),view(anyImg2)); ! save_view(view(anyImg2), out_dir+"gray8_converted.jpg"); */ ! gray8_image gray8(get_dimensions(view(anyImg))); ! //copy_and_convert_pixels(view(anyImg),view(gray8)); copy_pixels(view(anyImg),view(gray8)); ! save_view(view(gray8), out_dir+"gray8_converted.jpg"); ! save_view(fliplr_view(view(anyImg)), out_dir+"fliplr.jpg"); ! save_view(flipud_view(view(anyImg)), out_dir+"flipud.jpg"); ! any_view subimageView=subimage_view(view(anyImg),point2<ptrdiff_t>(0,0),point2<ptrdiff_t>(100,100)); ! save_view(subimageView, out_dir+"subimage.jpg"); ! save_view(subsampled_view(rotated180_view(view(anyImg)), point2<ptrdiff_t>(2,1)),out_dir+"subsampled180rot.jpg"); } *************** *** 97,147 **** void test_gimage() { ! test_dynamic_views("RGB.tif"); ! test_dynamic_views("gray.jpg"); } /* void test_gimage2() { ! typedef variant<AnyImageConceptSpace> AnyImage; ! typedef variant<AnyImageViewConceptSpace> AnyImageView; ! // static bool c1=PIXELS_COMPATIBLE(rgb8_pixel, rgb8_pixel); ! BOOST_STATIC_ASSERT(PIXELS_COMPATIBLE(rgb8_pixel, rgb8_pixel)); ! BOOST_STATIC_ASSERT(PIXELS_COMPATIBLE(bgr8_pixel, rgb8c_pixel)); ! BOOST_STATIC_ASSERT(!PIXELS_COMPATIBLE(bgr8_pixel, rgba8_pixel)); ! rgb8_image img1(10,10); ! fill_pixels(view(img1),rgb8_pixel(100,50,25)); ! AnyImageView imv1=view(img1); ! bgr8_image img2(10,10); ! AnyImageView imv2=view(img2); ! copy_pixels(imv1, imv2); ! copy_pixels(imv2, view(img1)); ! copy_pixels(view(img1), imv2); ! point2<int> sz=get_size(img1); ! // const cmyk8_image img2(point_type(10,10)); ! // cmyk16_image img2(point_type(10,10)); ! rgb8_view v=view(img1); ! AnyImageView av(view(img1)); ! AnyImage defaultConstructed; ! { ! rgb8_image r8(point2<int>(8,8)); ! AnyImage anyImg(rgb8_image(point2<int>(8,8)), true); ! rgb8_image r88(point2<int>(8,8)); ! anyImg.move_in(r88); ! int stop=0; ! // sz=get_size(anyImg); ! } } */ --- 97,147 ---- void test_gimage() { ! test_dynamic_views("RGB.tif"); ! test_dynamic_views("gray.jpg"); } /* void test_gimage2() { ! typedef variant<AnyImageConceptSpace> AnyImage; ! typedef variant<AnyImageViewConceptSpace> AnyImageView; ! // static bool c1=PIXELS_COMPATIBLE(rgb8_pixel, rgb8_pixel); ! BOOST_STATIC_ASSERT(PIXELS_COMPATIBLE(rgb8_pixel, rgb8_pixel)); ! BOOST_STATIC_ASSERT(PIXELS_COMPATIBLE(bgr8_pixel, rgb8c_pixel)); ! BOOST_STATIC_ASSERT(!PIXELS_COMPATIBLE(bgr8_pixel, rgba8_pixel)); ! rgb8_image img1(10,10); ! fill_pixels(view(img1),rgb8_pixel(100,50,25)); ! AnyImageView imv1=view(img1); ! bgr8_image img2(10,10); ! AnyImageView imv2=view(img2); ! copy_pixels(imv1, imv2); ! copy_pixels(imv2, view(img1)); ! copy_pixels(view(img1), imv2); ! point2<int> sz=get_size(img1); ! // const cmyk8_image img2(point_type(10,10)); ! // cmyk16_image img2(point_type(10,10)); ! rgb8_view v=view(img1); ! AnyImageView av(view(img1)); ! AnyImage defaultConstructed; ! { ! rgb8_image r8(point2<int>(8,8)); ! AnyImage anyImg(rgb8_image(point2<int>(8,8)), true); ! rgb8_image r88(point2<int>(8,8)); ! anyImg.move_in(r88); ! int stop=0; ! // sz=get_size(anyImg); ! } } */ Index: main.cpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/test/gil/main.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** main.cpp 6 Jan 2006 18:03:03 -0000 1.1 --- main.cpp 3 Feb 2006 18:33:39 -0000 1.2 *************** *** 1,6 **** /* ! Copyright 2005-2006 Adobe Systems Incorporated ! Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt ! or a copy at http://opensource.adobe.com/licenses.html) */ // image_test.cpp : Defines the entry point for the console application. --- 1,6 ---- /* ! Copyright 2005-2006 Adobe Systems Incorporated ! Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt ! or a copy at http://opensource.adobe.com/licenses.html) */ // image_test.cpp : Defines the entry point for the console application. *************** *** 14,26 **** { #ifdef NO_ASL ! test_integral_image(); ! performance_test(); #endif ! test_pixel(); ! test_pixel_iterator(); ! // test_image_io(); ! test_image(); ! // test_image_tiler(); } --- 14,26 ---- { #ifdef NO_ASL ! test_integral_image(); ! performance_test(); #endif ! test_pixel(); ! test_pixel_iterator(); ! // test_image_io(); ! test_image(); ! // test_image_tiler(); } Index: pixel.cpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/test/gil/pixel.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pixel.cpp 24 Jan 2006 19:38:51 -0000 1.2 --- pixel.cpp 3 Feb 2006 18:33:39 -0000 1.3 *************** *** 1,6 **** /* ! Copyright 2005-2006 Adobe Systems Incorporated ! Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt ! or a copy at http://opensource.adobe.com/licenses.html) */ // image_test.cpp : Defines the entry point for the console application. --- 1,6 ---- /* ! Copyright 2005-2006 Adobe Systems Incorporated ! Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt ! or a copy at http://opensource.adobe.com/licenses.html) */ // image_test.cpp : Defines the entry point for the console application. *************** *** 37,289 **** template <typename T> struct clear_fn { ! void operator()(T& v) { v=0; } }; template <typename T> inline void ignore_unused_variable_warning(const T&){} void test_pixel() { ! gil_function_requires<MutableChannelConcept<bits8> >(); ! gil_function_requires<MutableChannelConcept<bits8&> >(); ! gil_function_requires<ChannelConcept<const bits8&> >(); ! gil_function_requires<MutableChannelConcept<bits16> >(); ! gil_function_requires<MutableChannelConcept<bits32> >(); ! gil_function_requires<MutablePixelConcept<bgr32_pixel> >(); ! gil_function_requires<MutablePixelConcept<rgb16_planar_ref> >(); ! gil_function_requires<PixelConcept<rgb8c_pixel> >(); ! gil_function_requires<PixelConvertibleConcept<rgb8_pixel,cmyk16_pixel> >(); ! gil_function_requires<PixelConvertibleConcept<rgb8_pixel,cmyk16_planar_ref> >(); ! gil_function_requires<PixelConvertibleConcept<gray8c_pixel,cmyk16_planar_ref> >(); ! BOOST_STATIC_ASSERT(rgb_tag::num_channels==3); ! BOOST_STATIC_ASSERT(bgr_tag::num_channels==3); ! // dimensions to explore ! // ! // values, references, pointers ! // color spaces (rgb,cmyk,gray) ! // channel ordering (bgr vs rgb) ! // planar vs interleaved // PIXEL VALUES // Default constructors and construct with values ! rgb8_pixel rgb8(10,100,200); ! bgr8_pixel bgr8(10,100,200); ! rgb32_pixel rgb32(0.1f, 0.5f, 0.7f); ! per_channel_set_op(std::bind2nd(std::plus<bits8>(),3),rgb8,rgb8); ! cmyk8_pixel cmyk8; ! rgba8_pixel rgba8; ! gray8_pixel gray8(11); ! rgb16_pixel rgb16; ! cmyk16_pixel cmyk16; ! rgba16_pixel rgba16; ! bits8 mv=max_channel(rgb8); ! mv=min_channel(rgb8); // Copy construct from compatible pixel ! rgb8_pixel rgb8_1(rgb8); ! cmyk16_pixel cmyk16_1(cmyk16); ! bgr8_pixel bgr8_1(rgb8); // with different channel ordering ! assert(bgr8_1==rgb8); ! // RGB8 fail1(cmyk8); // error: different color space ! // RGB8 fail2(rgb16); // error: different channel depth // Assignment to compatible pixel ! rgb8_1=rgb8; ! bgr8_1=rgb8_pixel(1,2,3); ! rgb8_1=bgr8_1; ! assert(rgb8_1.r==1); ! ! // rgb8=rgba8; // error different color space ! // rgb8=rgb16; // error different channel depth ! // rgb8_pixel result=bgr8_1+rgb8; // PIXEL REFERENCES ! // rgb8ref rgb8ref_err; // error: references have no default constructors // Assign/copy-construct reference from value ! rgb8_ref rgb8ref(rgb8); ! rgb8_planar_ref rgb8planarref(rgb8); ! rgb8planarref=rgb8_pixel(11,22,32); ! unsigned char rr=rgb8planarref[2]; ignore_unused_variable_warning(rr); ! assert(rgb8planarref[2]==32); ! assert(rgb8[2]==32); ! rgb32_pixel r32=rgb32_pixel(1,2,3); ! rgb32_planar_ref rgb32pr(r32); ! bits32 xty=rgb32pr[2]; ignore_unused_variable_warning(xty); ! assert(xty==3); ! assert(r32[2]==3); ! const rgb8_pixel& CR(rgb8); ! rgb8ref=CR; ! rgb8c_pixel rgb8c(1,2,3); ! //BOOST_STATIC_ASSERT((boost::is_same<bits8,REMOVE_CONST_AND_REFERENCE(const bits8&)>::value)); ! rgb8c_planar_ref rgb8c_ref=rgb8c; ! // rgb8=rgb8c_pixel(1,2,3); ! assert(rgb8ref.b==rgb8.b); ! assert(rgb8==rgb8ref); ! assert(rgb8planarref==rgb8ref); ! boost::add_const<iterator_traits<rgb8_ptr>::reference>::type rgb8_const_ref(rgb8); ! // rgb8_const_ref=rgb8_pixel(3,5,7); // error: setting value of const reference ! rgb8planarref.b=33; ! assert(rgb8_const_ref.b==33); ! bgr8_ref bgr8_ref(bgr8); ! gray8_ref gray8_ref(gray8); // copy-construct reference from reference ! rgb8_ref rgb8ref_1(rgb8ref); ! rgb8_planar_ref rgb8planarref_1(rgb8ref); // planar from non-planar reference is ok ! // rgb8_ref rgb8ref_1_err(rgb8planarref); // error: non-planar from planar reference ! cmyk8_planar_ref cpr(cmyk8); ! int a=5, b=6; ! const int& cr=a; ! const rgb8_planar_ref cr_(rgb8); ! int& nr=b; ! rgb8_planar_ref nr_(rgb8); ! const int& cr2(cr); ignore_unused_variable_warning(cr2); ! const rgb8_planar_ref cr2_(cr_); ! const int& cr3(nr); ignore_unused_variable_warning(cr3); ! const rgb8_planar_ref cr3_(nr_); ! // SHOULD NOT COMPILE BUT IT DOES!! Bizzare because reference class' copy constructor takes argument by non-const reference, so it should not match "const rgb8_planar_ref" ! // int& nr2(cr); ! rgb8_planar_ref _nr2(cr_); // ERROR: reference from const reference ! int& nr3(nr); ignore_unused_variable_warning(nr3); ! rgb8_planar_ref _nr3(nr_); ! // cr=nr; ! // cr_=nr_; // ERROR: assigning to const reference ! nr=cr; ! nr_=cr_; ! // cr=cr; ! // cr_=cr_; ! nr=nr; ! nr_=nr_; // Assign value or reference to reference ! rgb8ref=rgb8_pixel(3,5,7); ! rgb8ref=rgb8ref_1; ! // rgb8_const_ref=rgb8ref; // error: const from non-const ! rgb8ref=rgb8_const_ref; // non-const from const // PIXEL POINTERS ! // typedef const iterator_traits<rgb8_ptr>::pointer RGB8ConstPtr; ! typedef const rgb8_ptr RGB8ConstPtr; ! typedef const rgb8_planar_ptr RGB8ConstPlanarPtr; ! // typedef const iterator_traits<rgb8_planar_ptr>::pointer RGB8ConstPlanarPtr; // constructing from values, references and other pointers ! RGB8ConstPtr rgb8_const_ptr=NULL; ignore_unused_variable_warning(rgb8_const_ptr); ! rgb8_ptr rgb8ptr=&rgb8; ! rgb8=bgr8_pixel(30,20,10); ! rgb8_planar_ptr rgb8_pptr=&rgb8; ! ++rgb8_pptr; ! rgb8_pptr--; ! rgb8_pptr[0]=rgb8; ! RGB8ConstPlanarPtr rgb8_const_planar_ptr=&rgb8; ! // rgb8_const_planar_ptr=&rgb16p; // error: incompatible bit depth ! // iterator_traits<CMYK8>::pointer cmyk8_ptr=&rgb8; // error: incompatible pointer type ! RGB8ConstPtr rgb8_const_ptr_err=rgb8ptr; // const pointer from non-regular pointer ignore_unused_variable_warning(rgb8_const_ptr_err); // dereferencing pointers to obtain references ! rgb8_ref rgb8ref_2=*rgb8ptr; ignore_unused_variable_warning(rgb8ref_2); ! assert(rgb8ref_2==rgb8); ! // RGB8Ref rgb8ref_2_err=*rgb8_const_planar_ptr; // error: non-const reference from const pointer ! ! rgb8_planar_ref rgb8planarref_3=*rgb8_pptr; // planar reference from planar pointer ! assert(rgb8planarref_3==rgb8); ! // RGB8Ref rgb8ref_3=*rgb8_planar_ptr; // error: non-planar reference from planar pointer ! const rgb8_pixel crgb8=rgb8; ! *rgb8_pptr=rgb8; ! *rgb8_pptr=crgb8; ! byte_advance(rgb8_pptr,3); ! byte_advance(rgb8_pptr,-3); // CHANNEL OPERATIONS ! ! // on values ! bgr8.b=3; ! rgb8.g=bgr8.b; rgb8.v<0>(); bgr8.v<0>(); ! assert(rgb8.g==3); ! // on references ! rgb8ref_1.g=bgr8_ref.r; ! bgr8_ref.b=3; ! // rgb8_const_ref.b=3; // error: modifying channel of const reference // OPERATOR== ! // rgb8==cmyk8; // error: incompatible color spaces ! rgb8==bgr8; // classes with different channel ordering are OK to compare ! rgb8_planar_ref rf=*rgb8_pptr; // COLOR CONVERSION ! color_convert(rgb16, gray8); ! // typedef iterator_traits<iterator_traits<rgb8_planar_ptr>::reference*>::color_space_type cst; ! // BOOST_STATIC_ASSERT((boost::is_same<rgb_tag,cst>::value)); ! color_convert(rgb16, rf); ! color_convert(rgb16, rf=*rgb8_pptr); ! color_convert(*rgb8_const_planar_ptr, gray8_ref); ! color_convert(rgb8ref, gray8_ref); ! // color_convert(rgb8ref, *rgb8_const_ptr); // error: Destination is const // CHANNEL-LEVEL OPERATIONS ! bgr8*=2; ! bgr8=rf*2; ! rgb8_pixel rgb8_2=bgr8/3; ! rf=bgr8*2; // MATH OPERATIONS ! rgba8*=3; ! rgba8=rgba8+rgba8_pixel(1,2,3,4); ! rgb8+=bgr8_pixel(1,2,3); ! rgb8=bgr8+rgb8; ! unsigned char* xxx=0; ! xxx+=2; ! rgb8_pptr.p.v<0>()=xxx; ! set_channels(rgb8_pptr.p,xxx); } --- 37,289 ---- template <typename T> struct clear_fn { ! void operator()(T& v) { v=0; } }; template <typename T> inline void ignore_unused_variable_warning(const T&){} void test_pixel() { ! gil_function_requires<MutableChannelConcept<bits8> >(); ! gil_function_requires<MutableChannelConcept<bits8&> >(); ! gil_function_requires<ChannelConcept<const bits8&> >(); ! gil_function_requires<MutableChannelConcept<bits16> >(); ! gil_function_requires<MutableChannelConcept<bits32> >(); ! gil_function_requires<MutablePixelConcept<bgr32_pixel> >(); ! gil_function_requires<MutablePixelConcept<rgb16_planar_ref> >(); ! gil_function_requires<PixelConcept<rgb8c_pixel> >(); ! gil_function_requires<PixelConvertibleConcept<rgb8_pixel,cmyk16_pixel> >(); ! gil_function_requires<PixelConvertibleConcept<rgb8_pixel,cmyk16_planar_ref> >(); ! gil_function_requires<PixelConvertibleConcept<gray8c_pixel,cmyk16_planar_ref> >(); ! BOOST_STATIC_ASSERT(rgb_tag::num_channels==3); ! BOOST_STATIC_ASSERT(bgr_tag::num_channels==3); ! // dimensions to explore ! // ! // values, references, pointers ! // color spaces (rgb,cmyk,gray) ! // channel ordering (bgr vs rgb) ! // planar vs interleaved // PIXEL VALUES // Default constructors and construct with values ! rgb8_pixel rgb8(10,100,200); ! bgr8_pixel bgr8(10,100,200); ! rgb32_pixel rgb32(0.1f, 0.5f, 0.7f); ! per_channel_set_op(std::bind2nd(std::plus<bits8>(),3),rgb8,rgb8); ! cmyk8_pixel cmyk8; ! rgba8_pixel rgba8; ! gray8_pixel gray8(11); ! rgb16_pixel rgb16; ! cmyk16_pixel cmyk16; ! rgba16_pixel rgba16; ! bits8 mv=max_channel(rgb8); ! mv=min_channel(rgb8); // Copy construct from compatible pixel ! rgb8_pixel rgb8_1(rgb8); ! cmyk16_pixel cmyk16_1(cmyk16); ! bgr8_pixel bgr8_1(rgb8); // with different channel ordering ! assert(bgr8_1==rgb8); ! // RGB8 fail1(cmyk8); // error: different color space ! // RGB8 fail2(rgb16); // error: different channel depth // Assignment to compatible pixel ! rgb8_1=rgb8; ! bgr8_1=rgb8_pixel(1,2,3); ! rgb8_1=bgr8_1; ! assert(rgb8_1.r==1); ! ! // rgb8=rgba8; // error different color space ! // rgb8=rgb16; // error different channel depth ! // rgb8_pixel result=bgr8_1+rgb8; // PIXEL REFERENCES ! // rgb8ref rgb8ref_err; // error: references have no default constructors // Assign/copy-construct reference from value ! rgb8_ref rgb8ref(rgb8); ! rgb8_planar_ref rgb8planarref(rgb8); ! rgb8planarref=rgb8_pixel(11,22,32); ! unsigned char rr=rgb8planarref[2]; ignore_unused_variable_warning(rr); ! assert(rgb8planarref[2]==32); ! assert(rgb8[2]==32); ! rgb32_pixel r32=rgb32_pixel(1,2,3); ! rgb32_planar_ref rgb32pr(r32); ! bits32 xty=rgb32pr[2]; ignore_unused_variable_warning(xty); ! assert(xty==3); ! assert(r32[2]==3); ! const rgb8_pixel& CR(rgb8); ! rgb8ref=CR; ! rgb8c_pixel rgb8c(1,2,3); ! //BOOST_STATIC_ASSERT((boost::is_same<bits8,REMOVE_CONST_AND_REFERENCE(const bits8&)>::value)); ! rgb8c_planar_ref rgb8c_ref=rgb8c; ! // rgb8=rgb8c_pixel(1,2,3); ! assert(rgb8ref.b==rgb8.b); ! assert(rgb8==rgb8ref); ! assert(rgb8planarref==rgb8ref); ! boost::add_const<iterator_traits<rgb8_ptr>::reference>::type rgb8_const_ref(rgb8); ! // rgb8_const_ref=rgb8_pixel(3,5,7); // error: setting value of const reference ! rgb8planarref.b=33; ! assert(rgb8_const_ref.b==33); ! bgr8_ref bgr8_ref(bgr8); ! gray8_ref gray8_ref(gray8); // copy-construct reference from reference ! rgb8_ref rgb8ref_1(rgb8ref); ! rgb8_planar_ref rgb8planarref_1(rgb8ref); // planar from non-planar reference is ok ! // rgb8_ref rgb8ref_1_err(rgb8planarref); // error: non-planar from planar reference ! cmyk8_planar_ref cpr(cmyk8); ! int a=5, b=6; ! const int& cr=a; ! const rgb8_planar_ref cr_(rgb8); ! int& nr=b; ! rgb8_planar_ref nr_(rgb8); ! const int& cr2(cr); ignore_unused_variable_warning(cr2); ! const rgb8_planar_ref cr2_(cr_); ! const int& cr3(nr); ignore_unused_variable_warning(cr3); ! const rgb8_planar_ref cr3_(nr_); ! // SHOULD NOT COMPILE BUT IT DOES!! Bizzare because reference class' copy constructor takes argument by non-const reference, so it should not match "const rgb8_planar_ref" ! // int& nr2(cr); ! rgb8_planar_ref _nr2(cr_); // ERROR: reference from const reference ! int& nr3(nr); ignore_unused_variable_warning(nr3); ! rgb8_planar_ref _nr3(nr_); ! // cr=nr; ! // cr_=nr_; // ERROR: assigning to const reference ! nr=cr; ! nr_=cr_; ! // cr=cr; ! // cr_=cr_; ! nr=nr; ! nr_=nr_; // Assign value or reference to reference ! rgb8ref=rgb8_pixel(3,5,7); ! rgb8ref=rgb8ref_1; ! // rgb8_const_ref=rgb8ref; // error: const from non-const ! rgb8ref=rgb8_const_ref; // non-const from const // PIXEL POINTERS ! // typedef const iterator_traits<rgb8_ptr>::pointer RGB8ConstPtr; ! typedef const rgb8_ptr RGB8ConstPtr; ! typedef const rgb8_planar_ptr RGB8ConstPlanarPtr; ! // typedef const iterator_traits<rgb8_planar_ptr>::pointer RGB8ConstPlanarPtr; // constructing from values, references and other pointers ! RGB8ConstPtr rgb8_const_ptr=NULL; ignore_unused_variable_warning(rgb8_const_ptr); ! rgb8_ptr rgb8ptr=&rgb8; ! rgb8=bgr8_pixel(30,20,10); ! rgb8_planar_ptr rgb8_pptr=&rgb8; ! ++rgb8_pptr; ! rgb8_pptr--; ! rgb8_pptr[0]=rgb8; ! RGB8ConstPlanarPtr rgb8_const_planar_ptr=&rgb8; ! // rgb8_const_planar_ptr=&rgb16p; // error: incompatible bit depth ! // iterator_traits<CMYK8>::pointer cmyk8_ptr=&rgb8; // error: incompatible pointer type ! RGB8ConstPtr rgb8_const_ptr_err=rgb8ptr; // const pointer from non-regular pointer ignore_unused_variable_warning(rgb8_const_ptr_err); // dereferencing pointers to obtain references ! rgb8_ref rgb8ref_2=*rgb8ptr; ignore_unused_variable_warning(rgb8ref_2); ! assert(rgb8ref_2==rgb8); ! // RGB8Ref rgb8ref_2_err=*rgb8_const_planar_ptr; // error: non-const reference from const pointer ! ! rgb8_planar_ref rgb8planarref_3=*rgb8_pptr; // planar reference from planar pointer ! assert(rgb8planarref_3==rgb8); ! // RGB8Ref rgb8ref_3=*rgb8_planar_ptr; // error: non-planar reference from planar pointer ! const rgb8_pixel crgb8=rgb8; ! *rgb8_pptr=rgb8; ! *rgb8_pptr=crgb8; ! byte_advance(rgb8_pptr,3); ! byte_advance(rgb8_pptr,-3); // CHANNEL OPERATIONS ! ! // on values ! bgr8.b=3; ! rgb8.g=bgr8.b; rgb8.v<0>(); bgr8.v<0>(); ! assert(rgb8.g==3); ! // on references ! rgb8ref_1.g=bgr8_ref.r; ! bgr8_ref.b=3; ! // rgb8_const_ref.b=3; // error: modifying channel of const reference // OPERATOR== ! // rgb8==cmyk8; // error: incompatible color spaces ! rgb8==bgr8; // classes with different channel ordering are OK to compare ! rgb8_planar_ref rf=*rgb8_pptr; // COLOR CONVERSION ! color_convert(rgb16, gray8); ! // typedef iterator_traits<iterator_traits<rgb8_planar_ptr>::reference*>::color_space_type cst; ! // BOOST_STATIC_ASSERT((boost::is_same<rgb_tag,cst>::value)); ! color_convert(rgb16, rf); ! color_convert(rgb16, rf=*rgb8_pptr); ! color_convert(*rgb8_const_planar_ptr, gray8_ref); ! color_convert(rgb8ref, gray8_ref); ! // color_convert(rgb8ref, *rgb8_const_ptr); // error: Destination is const // CHANNEL-LEVEL OPERATIONS ! bgr8*=2; ! bgr8=rf*2; ! rgb8_pixel rgb8_2=bgr8/3; ! rf=bgr8*2; // MATH OPERATIONS ! rgba8*=3; ! rgba8=rgba8+rgba8_pixel(1,2,3,4); ! rgb8+=bgr8_pixel(1,2,3); ! rgb8=bgr8+rgb8; ! unsigned char* xxx=0; ! xxx+=2; ! rgb8_pptr.p.v<0>()=xxx; ! set_channels(rgb8_pptr.p,xxx); } Index: pixel_iterator.cpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/test/gil/pixel_iterator.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pixel_iterator.cpp 24 Jan 2006 19:38:51 -0000 1.2 --- pixel_iterator.cpp 3 Feb 2006 18:33:39 -0000 1.3 *************** *** 1,6 **** /* ! Copyright 2005-2006 Adobe Systems Incorporated ! Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt ! or a copy at http://opensource.adobe.com/licenses.html) */ // image_test.cpp : Defines the entry point for the console application. --- 1,6 ---- /* ! Copyright 2005-2006 Adobe Systems Incorporated ! Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt ! or a copy at http://opensource.adobe.com/licenses.html) */ // image_test.cpp : Defines the entry point for the console application. *************** *** 29,160 **** template <typename T> inline void ignore_unused_variable_warning(const T&){} void test_pixel_iterator() { ! boost::function_requires<Point2DConcept<point2<int> > >(); ! boost::function_requires<MutablePixelIteratorConcept<bgr8_ptr> >(); ! boost::function_requires<MutablePixelIteratorConcept<cmyk8_planar_ptr> >(); ! boost::function_requires<PixelIteratorConcept<rgb8c_planar_step_ptr> >(); ! boost::function_requires<MutablePixelStepIteratorConcept<rgb8_step_ptr> >(); ! boost::function_requires<MutablePixelLocatorConcept<rgb8_step_loc> >(); ! boost::function_requires<PixelLocatorConcept<rgb8c_planar_step_loc> >(); ! boost::function_requires<MutablePixelStepIteratorConcept<cmyk8_planar_step_ptr> >(); ! boost::function_requires<PixelStepIteratorConcept<gray8c_step_ptr> >(); ! rgb8_pixel rgb8(1,2,3); ! rgb8_ptr ptr1=&rgb8; ! byte_advance(ptr1, 3); ! const rgb8_ptr ptr2=byte_advanced(ptr1,10); ! byte_distance(ptr1,ptr2); ! const rgb8_pixel& ref=byte_advanced_ref(ptr1,10); ignore_unused_variable_warning(ref); ! rgb8_planar_ptr planarPtr1(&rgb8); ! rgb8_planar_ptr planarPtr2(&rgb8); ! byte_advance(planarPtr1,10); ! byte_distance(planarPtr1,planarPtr2); ! rgb8_planar_ptr planarPtr3=byte_advanced(planarPtr1,10); ! pixel<bits8&,rgb_tag> pxl=*(planarPtr1+5); ! // rgb8_pixel pv=pxl; ! // rgb8_pixel pv=*(planarPtr1+5); ! rgb8_pixel pv=planarPtr1[5]; ! assert(*(planarPtr1+5)==planarPtr1[5]); ! rgb8_planar_ref planarRef=byte_advanced_ref(planarPtr1,10); ! rgb8_step_ptr stepIt(&rgb8,5); ! stepIt++; ! rgb8_step_ptr stepIt2=stepIt+10; ! stepIt2=stepIt; ! ! rgb8_step_ptr stepIt3(&rgb8,5); ! rgb8_pixel& ref1=stepIt3[5]; ! // bool v=boost::is_POD<iterator_traits<pixel_step_iterator<rgb8_ptr> >::value_type>::value; ! // v=boost::is_POD<rgb8_pixel>::value; ! // v=boost::is_POD<int>::value; ! rgb8_step_ptr rgb8StepIt(ptr1, 10); ! rgb8_step_ptr rgb8StepIt2=rgb8StepIt; ! rgb8StepIt=rgb8StepIt2; ! ++rgb8StepIt; ! rgb8_ref reff=*rgb8StepIt; ignore_unused_variable_warning(reff); ! rgb8StepIt+=10; ! ptrdiff_t dst=rgb8StepIt2-rgb8StepIt; ignore_unused_variable_warning(dst); ! rgb8_pixel val1=ref1; ! rgb8_ptr ptr=&ref1; ! rgb8_pixel& val21=stepIt3[5]; ! rgb8_pixel val22=val21; ! rgb8_pixel val2=stepIt3[5]; ! rgb8_ptr ptr11=&(stepIt3[5]); ignore_unused_variable_warning(ptr11); ! rgb8_ptr ptr3=&*(stepIt3+5); ignore_unused_variable_warning(ptr3); ! rgb8_step_ptr stepIt4(ptr,5); ! ++stepIt4; ! rgb8_step_ptr stepIt5; ! if (stepIt4==stepIt5) { ! int st=0;ignore_unused_variable_warning(st); } ! pixel_image_iterator<rgb8_loc> pix_img_it(rgb8_loc(ptr, 20), 5); ! ++pix_img_it; ! pix_img_it+=10; ! rgb8_pixel& refr=*pix_img_it; ! refr=rgb8_pixel(1,2,3); ! *pix_img_it=rgb8_pixel(1,2,3); ! pix_img_it[3]=rgb8_pixel(1,2,3); ! *(pix_img_it+3)=rgb8_pixel(1,2,3); ! pixel_image_iterator<rgb8c_loc> pix_img_it_c(rgb8c_loc(rgb8c_ptr(ptr),20), 5); ! ++pix_img_it_c; ! pix_img_it_c+=10; ! // *pix_img_it_c=rgb8_pixel(1,2,3); // error: assigning though const iterator ! typedef pixel_image_iterator<rgb8_loc>::difference_type dif_t; ! dif_t dt=0; ! ptrdiff_t tdt=dt; ignore_unused_variable_warning(tdt); ! // pixel_step_iterator<rgb8_pixel> stepIt3Err=stepIt+10; // error: non-const from const iterator ! pixel_xy_locator<rgb8_step_ptr> xy_locator(ptr,27); ! xy_locator.x()++; ! // pixel_step_iterator<rgb8_pixel>& yit=xy_locator.y(); ! xy_locator.y()++; ! xy_locator+=point2<int>(3,4); ! //*xy_locator=(xy_locator(-1,0)+xy_locator(0,1))/2; ! rgb8_pixel& rf=*xy_locator; ignore_unused_variable_warning(rf); ! typedef COLOR_CONVERT_ITERATOR(rgb8_ptr, rgb8_pixel) CCV; ! CCV ccv_it; ! make_step_iterator(ccv_it, 3); ! make_step_iterator(rgb8_ptr(),3); ! make_step_iterator(rgb8_planar_ptr(),3); ! make_step_iterator(rgb8_planar_step_ptr(),3); ! // xy_locator.y()++; // TEST dynamic_step_type ! BOOST_STATIC_ASSERT(( boost::is_same<cmyk16_step_ptr,std::iterator_traits<cmyk16_step_ptr>::dynamic_step_type>::value )); ! BOOST_STATIC_ASSERT(( boost::is_same<cmyk16_planar_step_ptr,std::iterator_traits<cmyk16_planar_ptr>::dynamic_step_type>::value )); ! BOOST_STATIC_ASSERT(( boost::is_same<dereference_iterator_adaptor< rgb8_step_ptr ,color_convert_deref_fn< rgb8_pixel > > ,std::iterator_traits< CCV >::dynamic_step_type>::value )); // TEST has_dynamic_step ! BOOST_STATIC_ASSERT(has_dynamic_step< cmyk16_step_ptr >::value); ! BOOST_STATIC_ASSERT(has_dynamic_step< cmyk16_planar_step_ptr >::value); ! BOOST_STATIC_ASSERT(!has_dynamic_step< cmyk16_planar_ptr >::value); ! BOOST_STATIC_ASSERT(!has_dynamic_step< COLOR_CONVERT_ITERATOR(rgb8_ptr, rgb8_pixel) >::value); ! BOOST_STATIC_ASSERT( has_dynamic_step< COLOR_CONVERT_ITERATOR(rgb8_step_ptr, rgb8_pixel) >::value); } --- 29,160 ---- template <typename T> inline void ignore_unused_variable_warning(const T&){} void test_pixel_iterator() { ! boost::function_requires<Point2DConcept<point2<int> > >(); ! boost::function_requires<MutablePixelIteratorConcept<bgr8_ptr> >(); ! boost::function_requires<MutablePixelIteratorConcept<cmyk8_planar_ptr> >(); ! boost::function_requires<PixelIteratorConcept<rgb8c_planar_step_ptr> >(); ! boost::function_requires<MutablePixelStepIteratorConcept<rgb8_step_ptr> >(); ! boost::function_requires<MutablePixelLocatorConcept<rgb8_step_loc> >(); ! boost::function_requires<PixelLocatorConcept<rgb8c_planar_step_loc> >(); ! boost::function_requires<MutablePixelStepIteratorConcept<cmyk8_planar_step_ptr> >(); ! boost::function_requires<PixelStepIteratorConcept<gray8c_step_ptr> >(); ! rgb8_pixel rgb8(1,2,3); ! rgb8_ptr ptr1=&rgb8; ! byte_advance(ptr1, 3); ! const rgb8_ptr ptr2=byte_advanced(ptr1,10); ! byte_distance(ptr1,ptr2); ! const rgb8_pixel& ref=byte_advanced_ref(ptr1,10); ignore_unused_variable_warning(ref); ! rgb8_planar_ptr planarPtr1(&rgb8); ! rgb8_planar_ptr planarPtr2(&rgb8); ! byte_advance(planarPtr1,10); ! byte_distance(planarPtr1,planarPtr2); ! rgb8_planar_ptr planarPtr3=byte_advanced(planarPtr1,10); ! pixel<bits8&,rgb_tag> pxl=*(planarPtr1+5); ! // rgb8_pixel pv=pxl; ! // rgb8_pixel pv=*(planarPtr1+5); ! rgb8_pixel pv=planarPtr1[5]; ! assert(*(planarPtr1+5)==planarPtr1[5]); ! rgb8_planar_ref planarRef=byte_advanced_ref(planarPtr1,10); ! rgb8_step_ptr stepIt(&rgb8,5); ! stepIt++; ! rgb8_step_ptr stepIt2=stepIt+10; ! stepIt2=stepIt; ! ! rgb8_step_ptr stepIt3(&rgb8,5); ! rgb8_pixel& ref1=stepIt3[5]; ! // bool v=boost::is_POD<iterator_traits<pixel_step_iterator<rgb8_ptr> >::value_type>::value; ! // v=boost::is_POD<rgb8_pixel>::value; ! // v=boost::is_POD<int>::value; ! rgb8_step_ptr rgb8StepIt(ptr1, 10); ! rgb8_step_ptr rgb8StepIt2=rgb8StepIt; ! rgb8StepIt=rgb8StepIt2; ! ++rgb8StepIt; ! rgb8_ref reff=*rgb8StepIt; ignore_unused_variable_warning(reff); ! rgb8StepIt+=10; ! ptrdiff_t dst=rgb8StepIt2-rgb8StepIt; ignore_unused_variable_warning(dst); ! rgb8_pixel val1=ref1; ! rgb8_ptr ptr=&ref1; ! rgb8_pixel& val21=stepIt3[5]; ! rgb8_pixel val22=val21; ! rgb8_pixel val2=stepIt3[5]; ! rgb8_ptr ptr11=&(stepIt3[5]); ignore_unused_variable_warning(ptr11); ! rgb8_ptr ptr3=&*(stepIt3+5); ignore_unused_variable_warning(ptr3); ! rgb8_step_ptr stepIt4(ptr,5); ! ++stepIt4; ! rgb8_step_ptr stepIt5; ! if (stepIt4==stepIt5) { ! int st=0;ignore_unused_variable_warning(st); } ! pixel_image_iterator<rgb8_loc> pix_img_it(rgb8_loc(ptr, 20), 5); ! ++pix_img_it; ! pix_img_it+=10; ! rgb8_pixel& refr=*pix_img_it; ! refr=rgb8_pixel(1,2,3); ! *pix_img_it=rgb8_pixel(1,2,3); ! pix_img_it[3]=rgb8_pixel(1,2,3); ! *(pix_img_it+3)=rgb8_pixel(1,2,3); ! pixel_image_iterator<rgb8c_loc> pix_img_it_c(rgb8c_loc(rgb8c_ptr(ptr),20), 5); ! ++pix_img_it_c; ! pix_img_it_c+=10; ! // *pix_img_it_c=rgb8_pixel(1,2,3); // error: assigning though const iterator ! typedef pixel_image_iterator<rgb8_loc>::difference_type dif_t; ! dif_t dt=0; ! ptrdiff_t tdt=dt; ignore_unused_variable_warning(tdt); ! // pixel_step_iterator<rgb8_pixel> stepIt3Err=stepIt+10; // error: non-const from const iterator ! pixel_xy_locator<rgb8_step_ptr> xy_locator(ptr,27); ! xy_locator.x()++; ! // pixel_step_iterator<rgb8_pixel>& yit=xy_locator.y(); ! xy_locator.y()++; ! xy_locator+=point2<int>(3,4); ! //*xy_locator=(xy_locator(-1,0)+xy_locator(0,1))/2; ! rgb8_pixel& rf=*xy_locator; ignore_unused_variable_warning(rf); ! typedef COLOR_CONVERT_ITERATOR(rgb8_ptr, rgb8_pixel) CCV; ! CCV ccv_it; ! make_step_iterator(ccv_it, 3); ! make_step_iterator(rgb8_ptr(),3); ! make_step_iterator(rgb8_planar_ptr(),3); ! make_step_iterator(rgb8_planar_step_ptr(),3); ! // xy_locator.y()++; // TEST dynamic_step_type ! BOOST_STATIC_ASSERT(( boost::is_same<cmyk16_step_ptr,std::iterator_traits<cmyk16_step_ptr>::dynamic_step_type>::value )); ! BOOST_STATIC_ASSERT(( boost::is_same<cmyk16_planar_step_ptr,std::iterator_traits<cmyk16_planar_ptr>::dynamic_step_type>::value )); ! BOOST_STATIC_ASSERT(( boost::is_same<dereference_iterator_adaptor< rgb8_step_ptr ,color_convert_deref_fn< rgb8_pixel > > ,std::iterator_traits< CCV >::dynamic_step_type>::value )); // TEST has_dynamic_step ! BOOST_STATIC_ASSERT(has_dynamic_step< cmyk16_step_ptr >::value); ! BOOST_STATIC_ASSERT(has_dynamic_step< cmyk16_planar_step_ptr >::value); ! BOOST_STATIC_ASSERT(!has_dynamic_step< cmyk16_planar_ptr >::value); ! BOOST_STATIC_ASSERT(!has_dynamic_step< COLOR_CONVERT_ITERATOR(rgb8_ptr, rgb8_pixel) >::value); ! BOOST_STATIC_ASSERT( has_dynamic_step< COLOR_CONVERT_ITERATOR(rgb8_step_ptr, rgb8_pixel) >::value); } Index: image.cpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/test/gil/image.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** image.cpp 6 Jan 2006 18:03:03 -0000 1.1 --- image.cpp 3 Feb 2006 18:33:39 -0000 1.2 *************** *** 1,6 **** /* ! Copyright 2005-2006 Adobe Systems Incorporated ! Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt ! or a copy at http://opensource.adobe.com/licenses.html) */ // image_test.cpp : Defines the entry point for the console application. --- 1,6 ---- /* ! Copyright 2005-2006 Adobe Systems Incorporated ! Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt ! or a copy at http://opensource.adobe.com/licenses.html) */ // image_test.cpp : Defines the entry point for the console application. *************** *** 39,45 **** using namespace boost; ! const string in_dir="C:\\test\\imgtest\\"; // directory of source images ! const string out_dir=in_dir+"scratch\\"; // directory where to write output ! const string ref_dir=in_dir+"reference\\"; // reference directory to compare written with actual output // Enable checking. --- 39,45 ---- using namespace boost; ! const string in_dir="C:\\test\\imgtest\\"; // directory of source images ! const string out_dir=in_dir+"scratch\\"; // directory where to write output ! const string ref_dir=in_dir+"reference\\"; // reference directory to compare written with actual output // Enable checking. *************** *** 48,57 **** template <typename IMG_VIEW> void check_image(const IMG_VIEW& img_view, const string& imgName) { ! save_view(img_view,out_dir+imgName); ! rgb8_image img1, img2; ! load_image(img1, out_dir+imgName); #ifdef PERFORM_CHECK ! load_image(img2, ref_dir+imgName); ! io_error_if(img1!=img2,"image mismatch"); #endif } --- 48,57 ---- template <typename IMG_VIEW> void check_image(const IMG_VIEW& img_view, const string& imgName) { ! save_view(img_view,out_dir+imgName); ! rgb8_image img1, img2; ! load_image(img1, out_dir+imgName); #ifdef PERFORM_CHECK ! load_image(img2, ref_dir+imgName); ! io_error_if(img1!=img2,"image mismatch"); #endif } *************** *** 60,112 **** template <typename IMG> void test_image_basic(const std::string& prefix) { ! typedef typename IMG::view_type VIEW; ! // make a 20x20 image ! IMG img(typename VIEW::point_type(20,20)); ! const VIEW& img_view=view(img); ! // fill it with red ! rgb8_pixel red8(255,0,0), green8(0,255,0), blue8(0,0,255), white8(255,255,255); ! typename VIEW::value_type red,green,blue,white; ! color_convert(red8,red); ! red=color_converter<typename IMG::view_type::value_type>()(red8); ! color_convert(green8,green); ! color_convert(blue8,blue); ! color_convert(white8,white); ! fill(img_view.begin(),img_view.end(),red); ! // pointer to first pixel of second row typename VIEW::reference rt=img_view.at(0,0)[img_view.width()]; ! typename VIEW::x_iterator ptr=&rt; ignore_unused_variable_warning(ptr); typename VIEW::reference rt2=*(img_view.at(0,0)+img_view.width()); ! typename VIEW::x_iterator ptr2=&rt2; ignore_unused_variable_warning(ptr2); ! assert(ptr==ptr2); ! assert(img_view.x_at(0,0)+10==10+img_view.x_at(0,0)); ! // draw a blue line along the diagonal ! typename VIEW::xy_locator loc=img_view.xy_at(0,img_view.height()-1); ! for (int y=0; y<img_view.height(); ++y) { ! *loc=blue; ! ++loc.x(); ! loc.y()--; ! } ! // draw a green dotted line along the main diagonal with step of 3 ! loc=img_view.xy_at(img_view.width()-1,img_view.height()-1); ! while (loc.x()>=img_view.x_at(0,0)) { ! *loc=green; ! loc-=typename VIEW::point_type(3,3); ! } ! // Clone and make every red pixel white ! IMG imgWhite(img); ! for (typename VIEW::iterator it=view(imgWhite).end(); (it-1)!=view(imgWhite).begin(); --it) { ! if (*(it-1)==red) ! *(it-1)=white; ! } ! check_image(img_view,prefix+"red_x.jpg"); ! check_image(view(imgWhite),prefix+"white_x.jpg"); } --- 60,112 ---- template <typename IMG> void test_image_basic(const std::string& prefix) { ! typedef typename IMG::view_type VIEW; ! // make a 20x20 image ! IMG img(typename VIEW::point_type(20,20)); ! const VIEW& img_view=view(img); ! // fill it with red ! rgb8_pixel red8(255,0,0), green8(0,255,0), blue8(0,0,255), white8(255,255,255); ! typename VIEW::value_type red,green,blue,white; ! color_convert(red8,red); ! red=color_converter<typename IMG::view_type::value_type>()(red8); ! color_convert(green8,green); ! color_convert(blue8,blue); ! color_convert(white8,white); ! fill(img_view.begin(),img_view.end(),red); ! // pointer to first pixel of second row typename VIEW::reference rt=img_view.at(0,0)[img_view.width()]; ! typename VIEW::x_iterator ptr=&rt; ignore_unused_variable_warning(ptr); typename VIEW::reference rt2=*(img_view.at(0,0)+img_view.width()); ! typename VIEW::x_iterator ptr2=&rt2; ignore_unused_variable_warning(ptr2); ! assert(ptr==ptr2); ! assert(img_view.x_at(0,0)+10==10+img_view.x_at(0,0)); ! // draw a blue line along the diagonal ! typename VIEW::xy_locator loc=img_view.xy_at(0,img_view.height()-1); ! for (int y=0; y<img_view.height(); ++y) { ! *loc=blue; ! ++loc.x(); ! loc.y()--; ! } ! // draw a green dotted line along the main diagonal with step of 3 ! loc=img_view.xy_at(img_view.width()-1,img_view.height()-1); ! while (loc.x()>=img_view.x_at(0,0)) { ! *loc=green; ! loc-=typename VIEW::point_type(3,3); ! } ! // Clone and make every red pixel white ! IMG imgWhite(img); ! for (typename VIEW::iterator it=view(imgWhite).end(); (it-1)!=view(imgWhite).begin(); --it) { ! if (*(it-1)==red) ! *(it-1)=white; ! } ! check_image(img_view,prefix+"red_x.jpg"); ! check_image(view(imgWhite),prefix+"white_x.jpg"); } *************** *** 116,127 **** template <bool ON_REAL_DATA> struct test_nth_channel_view { ! template <typename VIEW> static void apply(const VIEW& img_view, const string& prefix) { ! check_image(nth_channel_view(img_view,0),prefix+"0th_channel.jpg"); ! } }; template <> struct test_nth_channel_view<false> { ! template <typename VIEW> static void apply(const VIEW& img_view, const string& prefix) {} }; --- 116,127 ---- template <bool ON_REAL_DATA> struct test_nth_channel_view { ! template <typename VIEW> static void apply(const VIEW& img_view, const string& prefix) { ! check_image(nth_channel_view(img_view,0),prefix+"0th_channel.jpg"); ! } }; template <> struct test_nth_channel_view<false> { ! template <typename VIEW> static void apply(const VIEW& img_view, const string& prefix) {} }; *************** *** 129,187 **** template <typename VIEW> void test_image_views(const VIEW& img_view, const string& prefix) { ! check_image(img_view,prefix+"original.jpg"); ! check_image(subimage_view(img_view, round(img_view.dimensions()/4), round(img_view.dimensions()/2)),prefix+"cropped.jpg"); ! check_image(color_convert_view<gray8_pixel>(img_view),prefix+"gray8.jpg"); ! // check_image(transpose_view(img_view),prefix+"transpose.jpg"); ! check_image(rotated180_view(img_view),prefix+"rot180.jpg"); ! check_image(rotated90cw_view(img_view),prefix+"90cw.jpg"); ! check_image(rotated90ccw_view(img_view),prefix+"90ccw.jpg"); ! check_image(flipud_view(img_view),prefix+"flipped_ud.jpg"); ! check_image(fliplr_view(img_view),prefix+"flipped_lr.jpg"); ! check_image(subsampled_view(img_view,typename VIEW::point_type(2,1)),prefix+"subsampled.jpg"); ! test_nth_channel_view<std::iterator_traits<typename VIEW::x_iterator>::pixel_data_is_real>::apply(img_view,prefix+"0th_channel.jpg"); ! // some iterator math ! ptrdiff_t dst=(img_view.end()-(img_view.begin()+4500))+4500; ignore_unused_variable_warning(dst); ! ptrdiff_t dst2=img_view.end()-img_view.begin(); ignore_unused_variable_warning(dst2); ! ptrdiff_t sz=img_view.size(); ignore_unused_variable_warning(sz); ! //assert(dst==dst2);//does not work for empty images ! assert(sz==dst2); ! // histogram ! test_histogram(img_view); } template <typename GRAY_VIEW, typename R> void gray_image_hist(const GRAY_VIEW& img_view, R& hist) { ! //for_each_pixel(img_view,++lambda::var(hist)[lambda::_1]); ! for (typename GRAY_VIEW::iterator it=img_view.begin(); it!=img_view.end(); ++it) ! ++hist[*it]; } template <typename V, typename R> void get_hist(const V& img_view, R& hist) { ! gray_image_hist(color_convert_view<gray8_pixel>(img_view), hist); } template <typename VIEW> void test_histogram(const VIEW& img_view) { ! // std::vector<int> histogram(255,0); ! // get_hist(cropped,histogram.begin()); ! int histogram[255]; ! fill(histogram,histogram+255,0); ! get_hist(img_view,histogram); ! std::cout<<endl; ! std::for_each(histogram, histogram+255, std::cout << lambda::_1 << ' '); } template <typename IMG> void test_image_all(const string& prefix) { ! test_image_basic<IMG>(prefix+"basic_"); ! IMG img; ! load_jpeg_image(img,in_dir+"monkey.jpg"); ! test_image_views(view(img), prefix+"views_"); } --- 129,187 ---- template <typename VIEW> void test_image_views(const VIEW& img_view, const string& prefix) { ! check_image(img_view,prefix+"original.jpg"); ! check_image(subimage_view(img_view, round(img_view.dimensions()/4), round(img_view.dimensions()/2)),prefix+"cropped.jpg"); ! check_image(color_convert_view<gray8_pixel>(img_view),prefix+"gray8.jpg"); ! // check_image(transpose_view(img_view),prefix+"transpose.jpg"); ! check_image(rotated180_view(img_view),prefix+"rot180.jpg"); ! check_image(rotated90cw_view(img_view),prefix+"90cw.jpg"); ! check_image(rotated90ccw_view(img_view),prefix+"90ccw.jpg"); ! check_image(flipud_view(img_view),prefix+"flipped_ud.jpg"); ! check_image(fliplr_view(img_view),prefix+"flipped_lr.jpg"); ! check_image(subsampled_view(img_view,typename VIEW::point_type(2,1)),prefix+"subsampled.jpg"); ! test_nth_channel_view<std::iterator_traits<typename VIEW::x_iterator>::pixel_data_is_real>::apply(img_view,prefix+"0th_channel.jpg"); ! // some iterator math ! ptrdiff_t dst=(img_view.end()-(img_view.begin()+4500))+4500; ignore_unused_variable_warning(dst); ! ptrdiff_t dst2=img_view.end()-img_view.begin(); ignore_unused_variable_warning(dst2); ! ptrdiff_t sz=img_view.size(); ignore_unused_variable_warning(sz); ! //assert(dst==dst2);//does not work for empty images ! assert(sz==dst2); ! // histogram ! test_histogram(img_view); } template <typename GRAY_VIEW, typename R> void gray_image_hist(const GRAY_VIEW& img_view, R& hist) { ! //for_each_pixel(img_view,++lambda::var(hist)[lambda::_1]); ! for (typename GRAY_VIEW::iterator it=img_view.begin(); it!=img_view.end(); ++it) ! ++hist[*it]; } template <typename V, typename R> void get_hist(const V& img_view, R& hist) { ! gray_image_hist(color_convert_view<gray8_pixel>(img_view), hist); } template <typename VIEW> void test_histogram(const VIEW& img_view) { ! // std::vector<int> histogram(255,0); ! // get_hist(cropped,histogram.begin()); ! int histogram[255]; ! fill(histogram,histogram+255,0); ! get_hist(img_view,histogram); ! std::cout<<endl; ! std::for_each(histogram, histogram+255, std::cout << lambda::_1 << ' '); } template <typename IMG> void test_image_all(const string& prefix) { ! test_image_basic<IMG>(prefix+"basic_"); ! IMG img; ! load_jpeg_image(img,in_dir+"monkey.jpg"); ! test_image_views(view(img), prefix+"views_"); } *************** *** 190,202 **** template <typename IMG> void my_const_test(const IMG& img) { ! typename IMG::const_view_type v=const_view(img); ! // v(0,0)=pixel<T,CS>(); } template <typename T, typename CS> void my_test() { ! typename image_type<T,CS,true>::type imgs(100,100); ! typename view_type<T,CS,true>::type v=view(imgs); ! my_const_test(imgs); } --- 190,202 ---- template <typename IMG> void my_const_test(const IMG& img) { ! typename IMG::const_view_type v=const_view(img); ! // v(0,0)=pixel<T,CS>(); } template <typename T, typename CS> void my_test() { ! typename image_type<T,CS,true>::type imgs(100,100); ! typename view_type<T,CS,true>::type v=view(imgs); ! my_const_test(imgs); } *************** *** 211,273 **** void test_resample() { ! gil_function_requires<MutableImageViewConcept<rgb8_view> >(); ! gil_function_requires<ImageViewConcept<cmyk8c_planar_step_view> >(); ! gil_function_requires<MutableImageConcept<rgb8_image> >(); ! rgb8_image img; ! load_jpeg_image(img,in_dir+"monkey.jpg"); ! rgb8_image transf(rgb8_image::point_type(round(view(img).dimensions()/2))); #ifdef NO_ASL real_matrix ctm=real_matrix::get_rotate(15*3.14/180.0f); ! ctm*=real_matrix::get_translate(real_point(100,50)); ! resample_view(view(transf),const_view(img), ctm); ! save_view(view(transf), out_dir+"transformedBC.jpg"); ! resample_view(view(transf),const_view(img), ctm, kBilinear); ! save_view(view(transf), out_dir+"transformedBL.jpg"); ! resample_view(view(transf),const_view(img), ctm, kNearestNeighbor); ! save_view(view(transf), out_dir+"transformedNN.jpg"); #endif } void test_image() { ! gil_function_requires<ImageConcept<rgb8_image> >(); ! test_resample(); #ifdef NO_ASL ! CreateDirectory(in_dir.c_str(), NULL); ! CreateDirectory(out_dir.c_str(), NULL); ! CreateDirectory(ref_dir.c_str(), NULL); #endif ! // my_test<bits8,rgb_tag>(); ! // rgb8_planar_image im(point_type(10,10)); ! // for_each_pixel(view(im), planarOp()); ! test_image_all<bgr8_image>("bgr8_"); ! test_image_all<rgb8_image>("rgb8_"); ! test_image_all<rgb8_planar_image>("planarrgb8_"); ! test_image_all<gray8_image>("gray8_"); ! rgb8_image img; ! load_jpeg_image(img,in_dir+"monkey.jpg"); ! rgb8_image img2(view(img).dimensions()); ! copy(img.rbegin(),img.rend(), img2.begin()); ! save_view(view(img2),out_dir+"reversedMonkey.jpg"); ! // rgb8_image imgWithMargin; ! // create_with_margin(view(img), 100, imgWithMargin); ! // save_view(view(imgWithMargin),in_dir+"monkeyWithMargin.jpg"); ! test_image_views(subsampled_view(view(img),point_type(1,2)),"subsampled_"); ! BOOST_STATIC_ASSERT((!std::iterator_traits<COLOR_CONVERT_ITERATOR(rgb8_view::x_iterator,gray8_pixel) >::pixel_data_is_real)); ! test_image_views(color_convert_view<gray8_pixel>(view(img)),"color_converted_"); } --- 211,273 ---- void test_resample() { ! gil_function_requires<MutableImageViewConcept<rgb8_view> >(); ! gil_function_requires<ImageViewConcept<cmyk8c_planar_step_view> >(); ! gil_function_requires<MutableImageConcept<rgb8_image> >(); ! rgb8_image img; ! load_jpeg_image(img,in_dir+"monkey.jpg"); ! rgb8_image transf(rgb8_image::point_type(round(view(img).dimensions()/2))); #ifdef NO_ASL real_matrix ctm=real_matrix::get_rotate(15*3.14/180.0f); ! ctm*=real_matrix::get_translate(real_point(100,50)); ! resample_view(view(transf),const_view(img), ctm); ! save_view(view(transf), out_dir+"transformedBC.jpg"); ! resample_view(view(transf),const_view(img), ctm, kBilinear); ! save_view(view(transf), out_dir+"transformedBL.jpg"); ! resample_view(view(transf),const_view(img), ctm, kNearestNeighbor); ! save_view(view(transf), out_dir+"transformedNN.jpg"); #endif } void test_image() { ! gil_function_requires<ImageConcept<rgb8_image> >(); ! test_resample(); #ifdef NO_ASL ! CreateDirectory(in_dir.c_str(), NULL); ! CreateDirectory(out_dir.c_str(), NULL); ! CreateDirectory(ref_dir.c_str(), NULL); #endif ! // my_test<bits8,rgb_tag>(); ! // rgb8_planar_image im(point_type(10,10)); ! // for_each_pixel(view(im), planarOp()); ! test_image_all<bgr8_image>("bgr8_"); ! test_image_all<rgb8_image>("rgb8_"); ! test_image_all<rgb8_planar_image>("planarrgb8_"); ! test_image_all<gray8_image>("gray8_"); ! rgb8_image img; ! load_jpeg_image(img,in_dir+"monkey.jpg"); ! rgb8_image img2(view(img).dimensions()); ! copy(img.rbegin(),img.rend(), img2.begin()); ! save_view(view(img2),out_dir+"reversedMonkey.jpg"); ! // rgb8_image imgWithMargin; ! // create_with_margin(view(img), 100, imgWithMargin); ! // save_view(view(imgWithMargin),in_dir+"monkeyWithMargin.jpg"); ! test_image_views(subsampled_view(view(img),point_type(1,2)),"subsampled_"); ! BOOST_STATIC_ASSERT((!std::iterator_traits<COLOR_CONVERT_ITERATOR(rgb8_view::x_iterator,gray8_pixel) >::pixel_data_is_real)); ! test_image_views(color_convert_view<gray8_pixel>(view(img)),"color_converted_"); } *************** *** 281,313 **** typedef typename parent_type::reference reference; typedef typename parent_type::difference_type difference_type; ! typedef C color_space_type; ! myIterator() : _x(0),_y(0){} ! myIterator(int x, int y) : _x(x), _y(y) {} ! template <typename T1,typename C1> myIterator(const myIterator<T1,C1>& ptr) : _x(ptr._x), _y(ptr._y) {} ! /// For some reason operator[] provided by boost::iterator_facade returns a custom class that is convertible to reference ! /// We require our own reference because it is registered in iterator_traits ! reference operator[](difference_type d) const { return dereference(d);} ! ! myIterator(const myIterator& ptr) : parent_type(ptr) {} ! myIterator& operator=(const myIterator& ptr) { this->_x=ptr._x; this->_y=ptr._y; return *this; } ! reference dereference(int dx=0) const { ! return reference(_x+dx+_y); ! } private: ! friend class boost::iterator_core_access; ! int _x,_y; ! void increment() { ++_x; } ! void decrement() { --_x; } ! void advance(ptrdiff_t d) { _x+=d; } ! ptrdiff_t distance_to(const myIterator& it) const { return it._x-_x; } // THIS IS WRONG! ! bool equal(const myIterator& it) const { return _x==p._x && _y==p._y; } }; --- 281,313 ---- typedef typename parent_type::reference reference; typedef typename parent_type::difference_type difference_type; ! typedef C color_space_type; ! myIterator() : _x(0),_y(0){} ! myIterator(int x, int y) : _x(x), _y(y) {} ! template <typename T1,typename C1> myIterator(const myIterator<T1,C1>& ptr) : _x(ptr._x), _y(ptr._y) {} ! /// For some reason operator[] provided by boost::iterator_facade returns a custom class that is convertible to reference ! /// We require our own reference because it is registered in iterator_traits ! reference operator[](difference_type d) const { return dereference(d);} ! ! myIterator(const myIterator& ptr) : parent_type(ptr) {} ! myIterator& operator=(const myIterator& ptr) { this->_x=ptr._x; this->_y=ptr._y; return *this; } ! reference dereference(int dx=0) const { ! return reference(_x+dx+_y); ! } private: ! friend class boost::iterator_core_access; ! int _x,_y; ! void increment() { ++_x; } ! void decrement() { --_x; } ! void advance(ptrdiff_t d) { _x+=d; } ! ptrdiff_t distance_to(const myIterator& it) const { return it._x-_x; } // THIS IS WRONG! ! bool equal(const myIterator& it) const { return _x==p._x && _y==p._y; } }; *************** *** 316,373 **** class myXYLocator { public: ! typedef X_IT x_iterator; ! typedef pixel_step_iterator<X_IT> y_iterator; ! typedef typename std::iterator_traits<X_IT>::value_type value_type; ! typedef typename std::iterator_traits<X_IT>::reference reference; ! typedef typename std::iterator_traits<X_IT>::pointer pointer; ! typedef point2<typename std::iterator_traits<X_IT>::difference_type> difference_type; ! typedef ptrdiff_t cached_location; ! typedef myXYLocator<typename std::iterator_traits<X_IT>::dynamic_step_type> dynamic_step_type; ! typedef myXYLocator<typename std::iterator_traits<X_IT>::const_type> const_type; ! typedef typename std::iterator_traits<x_iterator>::channel_type channel_type; ! typedef typename std::iterator_traits<x_iterator>::color_space_type color_space_type; ! myXYLocator(){} ! myXYLocator(x_iterator x_it, ptrdiff_t row_bytes) : _p(x_it,row_bytes) {} ! template <typename X> myXYLocator(const myXYLocator<X>& pl) : _p(pl._p) {} ! x_iterator& x() { return _p.base(); } ! x_iterator const& x() const { return _p.base(); } ! y_iterator& y() { return _p; } ! y_iterator const& y() const { return _p; } ! ptrdiff_t row_bytes() const { return byte_step(y()); } // row bytes ! ptrdiff_t pix_bytestep() const { return byte_step(x()); } // distance in bytes between adjacent pixels on the same row ! reference operator()(ptrdiff_t dx, ptrdiff_t dy) const { return byte_advanced_ref(x(),byte_offset(dx,dy)); } ! reference operator[](const difference_type& d) const { return byte_advanced_ref(x(),byte_offset(d.x,d.y)); } ! reference operator*() const { return *_p; } ! cached_location cache_location(const difference_type& d) const { return byte_offset(d.x,d.y); } ! cached_location cache_location(ptrdiff_t dx, ptrdiff_t dy) const { return byte_offset(dx,dy); } ! ! reference operator[](const cached_location& loc) const { return byte_advanced_ref(x(),loc); } ! x_iterator x_at(ptrdiff_t dx, ptrdiff_t dy) const { return byte_advanced(x(), byte_offset(dx,dy)); } ! x_iterator x_at(const difference_type& d) const { return byte_advanced(x(), byte_offset(d.x,d.y)); } ! x_iterator row_begin(ptrdiff_t y) const { return byte_advanced(x(), y*row_bytes()); } ! myXYLocator& operator+=(const difference_type& d) { byte_advance(x(),byte_offset(d.x,d.y)); return *this; } ! myXYLocator& operator-=(const difference_type& d) { byte_advance(x(),byte_offset(-d.x,-d.y)); return *this; } ! // add is faster than += because there is no need to construct a point ! myXYLocator& add(ptrdiff_t dx, ptrdiff_t dy) { byte_advance(x(),byte_offset(dx,dy)); return *this; } ! ! myXYLocator operator+(const difference_type& d) const { return myXYLocator(x_at( d.x, d.y), row_bytes()); } ! myXYLocator operator-(const difference_type& d) const { return myXYLocator(x_at(-d.x,-d.y), row_bytes()); } ! bool operator==(const myXYLocator& p) const { return _p==p._p; } ! bool operator!=(const myXYLocator& p) const { return _p!=p._p; } private: ! template <typename X> friend class myXYLocator; ! ptrdiff_t byte_offset(ptrdiff_t x, ptrdiff_t y) const { return y*row_bytes() + x*pix_bytestep(); } ! pixel_step_iterator<X_IT> _p; }; */ --- 316,373 ---- class myXYLocator { public: ! type... [truncated message content] |