Skip to content
Browse files

Remove obsolete Boost.Gil code.

There's no longer any reason to carry around the Boost.Gil code (it's
been in mainline Boost for years), except for the numeric extension,
which we still provide.  However, this change organizes the #include
directories so that a system-provided numeric extension should be
automatically used if available.
  • Loading branch information...
1 parent c9eceee commit ce0064ec618678859e69e3063c9eeb6f7fb5bb93 Timothy M. Shead committed May 26, 2010
Showing with 30 additions and 11,955 deletions.
  1. +9 −7 k3dsdk/CMakeLists.txt
  2. +4 −23 k3dsdk/bitmap.h
  3. +0 −813 k3dsdk/gil/boost/gil/algorithm.hpp
  4. +0 −498 k3dsdk/gil/boost/gil/channel.hpp
  5. +0 −295 k3dsdk/gil/boost/gil/channel_algorithm.hpp
  6. +0 −60 k3dsdk/gil/boost/gil/cmyk.hpp
  7. +0 −393 k3dsdk/gil/boost/gil/color_base.hpp
  8. +0 −535 k3dsdk/gil/boost/gil/color_base_algorithm.hpp
  9. +0 −312 k3dsdk/gil/boost/gil/color_convert.hpp
  10. +0 −61 k3dsdk/gil/boost/gil/deprecated.hpp
  11. +0 −84 k3dsdk/gil/boost/gil/device_n.hpp
  12. +0 −170 k3dsdk/gil/boost/gil/extension/dynamic_image/algorithm.hpp
  13. +0 −122 k3dsdk/gil/boost/gil/extension/dynamic_image/any_image.hpp
  14. +0 −111 k3dsdk/gil/boost/gil/extension/dynamic_image/any_image_view.hpp
  15. +0 −57 k3dsdk/gil/boost/gil/extension/dynamic_image/apply_operation.hpp
  16. +0 −158 k3dsdk/gil/boost/gil/extension/dynamic_image/apply_operation_base.hpp
  17. +0 −126 k3dsdk/gil/boost/gil/extension/dynamic_image/dynamic_at_c.hpp
  18. +0 −28 k3dsdk/gil/boost/gil/extension/dynamic_image/dynamic_image_all.hpp
  19. +0 −208 k3dsdk/gil/boost/gil/extension/dynamic_image/image_view_factory.hpp
  20. +0 −786 k3dsdk/gil/boost/gil/extension/dynamic_image/reduce.hpp
  21. +0 −189 k3dsdk/gil/boost/gil/extension/dynamic_image/variant.hpp
  22. +0 −76 k3dsdk/gil/boost/gil/extension/io/dynamic_io.hpp
  23. +0 −48 k3dsdk/gil/boost/gil/extension/io/io_error.hpp
  24. +0 −126 k3dsdk/gil/boost/gil/extension/io/jpeg_dynamic_io.hpp
  25. +0 −198 k3dsdk/gil/boost/gil/extension/io/jpeg_io.hpp
  26. +0 −221 k3dsdk/gil/boost/gil/extension/io/jpeg_io_private.hpp
  27. +0 −137 k3dsdk/gil/boost/gil/extension/io/png_dynamic_io.hpp
  28. +0 −210 k3dsdk/gil/boost/gil/extension/io/png_io.hpp
  29. +0 −350 k3dsdk/gil/boost/gil/extension/io/png_io_private.hpp
  30. +0 −131 k3dsdk/gil/boost/gil/extension/io/tiff_dynamic_io.hpp
  31. +0 −489 k3dsdk/gil/boost/gil/extension/io/tiff_io.hpp
  32. +1 −1 k3dsdk/gil/boost/gil/extension/numeric/affine.hpp
  33. +3 −3 k3dsdk/gil/boost/gil/extension/numeric/algorithm.hpp
  34. +2 −2 k3dsdk/gil/boost/gil/extension/numeric/channel_numeric_operations.hpp
  35. +4 −4 k3dsdk/gil/boost/gil/extension/numeric/convolve.hpp
  36. +2 −2 k3dsdk/gil/boost/gil/extension/numeric/kernel.hpp
  37. +3 −3 k3dsdk/gil/boost/gil/extension/numeric/pixel_numeric_operations.hpp
  38. +1 −1 k3dsdk/gil/boost/gil/extension/numeric/resample.hpp
  39. +1 −1 k3dsdk/gil/boost/gil/extension/numeric/sampler.hpp
  40. +0 −41 k3dsdk/gil/boost/gil/gil_all.hpp
  41. +0 −2,163 k3dsdk/gil/boost/gil/gil_concept.hpp
  42. +0 −39 k3dsdk/gil/boost/gil/gil_config.hpp
  43. +0 −41 k3dsdk/gil/boost/gil/gray.hpp
  44. +0 −268 k3dsdk/gil/boost/gil/image.hpp
  45. +0 −220 k3dsdk/gil/boost/gil/image_view.hpp
  46. +0 −376 k3dsdk/gil/boost/gil/image_view_factory.hpp
  47. +0 −168 k3dsdk/gil/boost/gil/iterator_from_2d.hpp
  48. +0 −357 k3dsdk/gil/boost/gil/locator.hpp
  49. +0 −330 k3dsdk/gil/boost/gil/metafunctions.hpp
  50. +0 −175 k3dsdk/gil/boost/gil/packed_pixel.hpp
  51. +0 −166 k3dsdk/gil/boost/gil/pixel.hpp
  52. +0 −162 k3dsdk/gil/boost/gil/pixel_iterator.hpp
  53. +0 −201 k3dsdk/gil/boost/gil/pixel_iterator_adaptor.hpp
  54. +0 −209 k3dsdk/gil/boost/gil/planar_pixel_iterator.hpp
Sorry, we could not display the entire diff because it was too big.
View
16 k3dsdk/CMakeLists.txt
@@ -18,13 +18,15 @@ CONFIGURE_FILE(${k3dsdk_SOURCE_DIR}/k3d-path-config.h.in ${k3dsdk_BINARY_DIR}/k3
CONFIGURE_FILE(${k3dsdk_SOURCE_DIR}/k3d-platform-config.h.in ${k3dsdk_BINARY_DIR}/k3d-platform-config.h)
CONFIGURE_FILE(${k3dsdk_SOURCE_DIR}/k3d-version-config.h.in ${k3dsdk_BINARY_DIR}/k3d-version-config.h)
-INCLUDE_DIRECTORIES(${k3d_SOURCE_DIR})
-INCLUDE_DIRECTORIES(${k3dsdk_SOURCE_DIR}/gil)
-INCLUDE_DIRECTORIES(${k3dsdk_BINARY_DIR})
-INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
-INCLUDE_DIRECTORIES(${K3D_GLIBMM_INCLUDE_DIRS})
-INCLUDE_DIRECTORIES(${K3D_SIGC_INCLUDE_DIRS})
-INCLUDE_DIRECTORIES(${K3D_OPENGL_INCLUDE_DIR})
+INCLUDE_DIRECTORIES(
+ ${k3d_SOURCE_DIR}
+ ${k3dsdk_BINARY_DIR}
+ ${Boost_INCLUDE_DIRS}
+ ${k3dsdk_SOURCE_DIR}/gil
+ ${K3D_GLIBMM_INCLUDE_DIRS}
+ ${K3D_SIGC_INCLUDE_DIRS}
+ ${K3D_OPENGL_INCLUDE_DIR}
+ )
IF(K3D_ENABLE_PARALLEL)
INCLUDE_DIRECTORIES(${K3D_TBB_INCLUDE_DIR})
View
27 k3dsdk/bitmap.h
@@ -41,10 +41,8 @@ namespace boost
namespace gil
{
-typedef half bits16f;
-
template<>
-struct channel_traits<bits16f>
+struct channel_traits<half>
{
typedef half value_type;
typedef half& reference;
@@ -55,32 +53,15 @@ struct channel_traits<bits16f>
static value_type min_value()
{
- return bits16f(0.0f);
+ return half(0.0f);
}
static value_type max_value()
{
- return bits16f(1.0f);
+ return half(1.0f);
}
};
-GIL_DEFINE_BASE_TYPEDEFS(16f,gray)
-GIL_DEFINE_BASE_TYPEDEFS(16f,bgr)
-GIL_DEFINE_BASE_TYPEDEFS(16f,argb)
-GIL_DEFINE_BASE_TYPEDEFS(16f,abgr)
-GIL_DEFINE_BASE_TYPEDEFS(16f,bgra)
-
-GIL_DEFINE_ALL_TYPEDEFS(16f,rgb)
-GIL_DEFINE_ALL_TYPEDEFS(16f,rgba)
-GIL_DEFINE_ALL_TYPEDEFS(16f,cmyk)
-
-template <int N> struct devicen_t;
-template <int N> struct devicen_layout_t;
-GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16f,dev2n, devicen_t<2>, devicen_layout_t<2>)
-GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16f,dev3n, devicen_t<3>, devicen_layout_t<3>)
-GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16f,dev4n, devicen_t<4>, devicen_layout_t<4>)
-GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16f,dev5n, devicen_t<5>, devicen_layout_t<5>)
-
} // namespace gil
} // namespace boost
@@ -89,7 +70,7 @@ namespace k3d
{
/// Defines a standard pixel as half-precision floating-point RGBA
-typedef boost::gil::pixel<boost::gil::bits16f, boost::gil::rgba_layout_t> pixel;
+typedef boost::gil::pixel<half, boost::gil::rgba_layout_t> pixel;
/// Defines a standard bitmap as half-precision floating-point RGBA
typedef boost::gil::image<pixel, false> bitmap;
/// Define storage for a pixel coordinate
View
813 k3dsdk/gil/boost/gil/algorithm.hpp
@@ -1,813 +0,0 @@
-/*
- Copyright 2005-2007 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)
-*/
-
-/*************************************************************************************************/
-
-#ifndef GIL_ALGORITHM_HPP
-#define GIL_ALGORITHM_HPP
-
-#include <cassert>
-#include <cstddef>
-#include <typeinfo>
-#include <algorithm>
-#include <iterator>
-#include <memory>
-#include "gil_config.hpp"
-#include "gil_concept.hpp"
-#include "color_base_algorithm.hpp"
-#include "image_view.hpp"
-#include "image_view_factory.hpp"
-
-////////////////////////////////////////////////////////////////////////////////////////
-/// \file
-/// \brief Some basic STL-style algorithms when applied to image views
-/// \author Lubomir Bourdev and Hailin Jin \n
-/// Adobe Systems Incorporated
-/// \date 2005-2007 \n Last updated on February 16, 2007
-///
-////////////////////////////////////////////////////////////////////////////////////////
-
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable : 4244) // conversion from 'gil::image<V,Alloc>::coord_t' to 'int', possible loss of data (visual studio compiler doesn't realize that the two types are the same)
-#endif
-
-namespace boost { namespace gil {
-
-//forward declarations
-template <typename ChannelPtr, typename ColorSpace>
-struct planar_pixel_iterator;
-template <typename Iterator>
-class byte_addressable_step_iterator;
-template <typename StepIterator>
-class byte_addressable_2d_locator;
-
-// a tag denoting incompatible arguments
-struct error_t {};
-
-/// \defgroup ImageViewSTLAlgorithms STL-like Algorithms
-/// \ingroup ImageViewAlgorithm
-/// \brief Image view-equivalents of STL algorithms
-///
-/// Image views provide 1D iteration of their pixels via \p begin() and \p end() methods,
-/// which makes it possible to use STL algorithms with them. However, using nested loops
-/// over X and Y is in many cases more efficient. The algorithms in this section resemble
-/// STL algorithms, but they abstract away the nested loops and take views (as opposed to ranges) as input.
-///
-/// Most algorithms check whether the image views are 1D-traversable. A 1D-traversable image view has no gaps
-/// at the end of the rows. In other words, if an x_iterator of that view is advanced past the last pixel in a row
-/// it will move to the first pixel of the next row. When image views are 1D-traversable, the algorithms use
-/// a single loop and run more efficiently. If one or more of the input views are not 1D-traversable, the algorithms
-/// fall-back to an X-loop nested inside a Y-loop.
-///
-/// The algorithms typically delegate the work to their corresponding STL algorithms. For example, \p copy_pixels calls
-/// \p std::copy either for each row, or, when the images are 1D-traversable, once for all pixels.
-///
-/// In addition, overloads are sometimes provided for the STL algorithms. For example, std::copy for planar iterators
-/// is overloaded to perform \p std::copy for each of the planes. \p std::copy over bitwise-copiable pixels results in
-/// std::copy over unsigned char, which STL typically implements via \p memmove.
-///
-/// As a result \p copy_pixels may result in a single call to \p memmove for interleaved 1D-traversable views,
-/// or one per each plane of planar 1D-traversable views, or one per each row of interleaved non-1D-traversable images, etc.
-
-
-/// \defgroup STLOptimizations Performance overloads of STL algorithms
-/// \ingroup ImageViewAlgorithm
-/// \brief overloads of STL algorithms allowing more efficient implementation when used with GIL constructs
-
-/// \brief A generic binary operation on views
-/// \ingroup ImageViewSTLAlgorithms
-///
-/// Use this class as a convenience superclass when defining an operation for any image views.
-/// Many operations have different behavior when the two views are compatible. This class checks
-/// for compatibility and invokes apply_compatible(V1,V2) or apply_incompatible(V1,V2) of the subclass.
-/// You must provide apply_compatible(V1,V2) method in your subclass, but apply_incompatible(V1,V2)
-/// is not required and the default throws std::bad_cast.
-template <typename Derived, typename Result=void>
-struct binary_operation_obj {
- typedef Result result_type;
-
- template <typename V1, typename V2> GIL_FORCEINLINE
- result_type operator()(const std::pair<const V1*,const V2*>& p) const {
- return apply(*p.first, *p.second, typename views_are_compatible<V1,V2>::type());
- }
-
- template <typename V1, typename V2> GIL_FORCEINLINE
- result_type operator()(const V1& v1, const V2& v2) const {
- return apply(v1, v2, typename views_are_compatible<V1,V2>::type());
- }
-
- result_type operator()(const error_t&) const { throw std::bad_cast(); }
-private:
-
- // dispatch from apply overload to a function with distinct name
- template <typename V1, typename V2>
- GIL_FORCEINLINE result_type apply(const V1& v1, const V2& v2, mpl::false_) const {
- return ((const Derived*)this)->apply_incompatible(v1,v2);
- }
-
- // dispatch from apply overload to a function with distinct name
- template <typename V1, typename V2>
- GIL_FORCEINLINE result_type apply(const V1& v1, const V2& v2, mpl::true_) const {
- return ((const Derived*)this)->apply_compatible(v1,v2);
- }
-
- // function with distinct name - it can be overloaded by subclasses
- template <typename V1, typename V2>
- GIL_FORCEINLINE result_type apply_incompatible(const V1& v1, const V2& v2) const {
- throw std::bad_cast();
- }
-};
-} } // namespace boost::gil
-
-//////////////////////////////////////////////////////////////////////////////////////
-///
-/// std::copy and gil::copy_pixels
-///
-//////////////////////////////////////////////////////////////////////////////////////
-
-/// \defgroup ImageViewSTLAlgorithmsCopyPixels copy_pixels
-/// \ingroup ImageViewSTLAlgorithms
-/// \brief std::copy for image views
-
-namespace std {
-
-/// \ingroup STLOptimizations
-/// \brief Copy when both src and dst are interleaved and of the same type can be just memmove
-template<typename T, typename Cs>
-GIL_FORCEINLINE boost::gil::pixel<T,Cs>*
-copy(boost::gil::pixel<T,Cs>* first, boost::gil::pixel<T,Cs>* last,
- boost::gil::pixel<T,Cs>* dst) {
- return (boost::gil::pixel<T,Cs>*)std::copy((unsigned char*)first,(unsigned char*)last, (unsigned char*)dst);
-}
-
-/// \ingroup STLOptimizations
-/// \brief Copy when both src and dst are interleaved and of the same type can be just memmove
-template<typename T, typename Cs>
-GIL_FORCEINLINE boost::gil::pixel<T,Cs>*
-copy(const boost::gil::pixel<T,Cs>* first, const boost::gil::pixel<T,Cs>* last,
- boost::gil::pixel<T,Cs>* dst) {
- return (boost::gil::pixel<T,Cs>*)std::copy((unsigned char*)first,(unsigned char*)last, (unsigned char*)dst);
-}
-} // namespace std
-
-namespace boost { namespace gil {
-namespace detail {
-template <typename I, typename O> struct copy_fn {
- GIL_FORCEINLINE I operator()(I first, I last, O dst) const { return std::copy(first,last,dst); }
-};
-} // namespace detail
-} } // namespace boost::gil
-
-namespace std {
-/// \ingroup STLOptimizations
-/// \brief Copy when both src and dst are planar pointers is copy for each channel
-template<typename Cs, typename IC1, typename IC2> GIL_FORCEINLINE
-boost::gil::planar_pixel_iterator<IC2,Cs> copy(boost::gil::planar_pixel_iterator<IC1,Cs> first, boost::gil::planar_pixel_iterator<IC1,Cs> last, boost::gil::planar_pixel_iterator<IC2,Cs> dst) {
- boost::gil::gil_function_requires<boost::gil::ChannelsCompatibleConcept<typename std::iterator_traits<IC1>::value_type,typename std::iterator_traits<IC2>::value_type> >();
- static_for_each(first,last,dst,boost::gil::detail::copy_fn<IC1,IC2>());
- return dst+(last-first);
-}
-} // namespace std
-
-namespace boost { namespace gil {
-namespace detail {
-/// Does a copy-n. If the inputs contain image iterators, performs a copy at each row using the row iterators
-/// \ingroup CopyPixels
-template <typename I, typename O>
-struct copier_n {
- GIL_FORCEINLINE void operator()(I src, typename std::iterator_traits<I>::difference_type n, O dst) const { std::copy(src,src+n, dst); }
-};
-
-/// Source range is delimited by image iterators
-template <typename IL, typename O> // IL Models ConstPixelLocatorConcept, O Models PixelIteratorConcept
-struct copier_n<iterator_from_2d<IL>,O> {
- typedef typename std::iterator_traits<iterator_from_2d<IL> >::difference_type diff_t;
- GIL_FORCEINLINE void operator()(iterator_from_2d<IL> src, diff_t n, O dst) const {
- gil_function_requires<PixelLocatorConcept<IL> >();
- gil_function_requires<MutablePixelIteratorConcept<O> >();
- while (n>0) {
- typedef typename iterator_from_2d<IL>::difference_type diff_t;
- diff_t l=src.width()-src.x_pos();
- diff_t numToCopy=(n<l ? n:l);
- detail::copy_n(src.x(), numToCopy, dst);
- dst+=numToCopy;
- src+=numToCopy;
- n-=numToCopy;
- }
- }
-};
-
-/// Destination range is delimited by image iterators
-template <typename I, typename OL> // I Models ConstPixelIteratorConcept, OL Models PixelLocatorConcept
-struct copier_n<I,iterator_from_2d<OL> > {
- typedef typename std::iterator_traits<I>::difference_type diff_t;
- GIL_FORCEINLINE void operator()(I src, diff_t n, iterator_from_2d<OL> dst) const {
- gil_function_requires<PixelIteratorConcept<I> >();
- gil_function_requires<MutablePixelLocatorConcept<OL> >();
- while (n>0) {
- diff_t l=dst.width()-dst.x_pos();
- diff_t numToCopy=(n<l ? n:l);
- detail::copy_n(src, numToCopy, dst.x());
- dst+=numToCopy;
- src+=numToCopy;
- n-=numToCopy;
- }
- }
-};
-
-/// Both source and destination ranges are delimited by image iterators
-template <typename IL, typename OL>
-struct copier_n<iterator_from_2d<IL>,iterator_from_2d<OL> > {
- typedef typename iterator_from_2d<IL>::difference_type diff_t;
- GIL_FORCEINLINE void operator()(iterator_from_2d<IL> src, diff_t n, iterator_from_2d<OL> dst) const {
- gil_function_requires<PixelLocatorConcept<IL> >();
- gil_function_requires<MutablePixelLocatorConcept<OL> >();
- if (src.x_pos()!=dst.x_pos() || src.width()!=dst.width()) {
- while(n-->0) {
- *dst++=*src++;
- }
- }
- while (n>0) {
- diff_t l=dst.width()-dst.x_pos();
- diff_t numToCopy=(n<l ? n : l);
- detail::copy_n(src.x(), numToCopy, dst.x());
- dst+=numToCopy;
- src+=numToCopy;
- n-=numToCopy;
- }
- }
-};
-} // namespace detail
-} } // namespace boost::gil
-
-namespace std {
-/// \ingroup STLOptimizations
-/// \brief std::copy(I1,I1,I2) with I1 and I2 being a iterator_from_2d
-template <typename IL, typename OL>
-GIL_FORCEINLINE boost::gil::iterator_from_2d<OL> copy(boost::gil::iterator_from_2d<IL> first, boost::gil::iterator_from_2d<IL> last, boost::gil::iterator_from_2d<OL> dst) {
- boost::gil::gil_function_requires<boost::gil::PixelLocatorConcept<IL> >();
- boost::gil::gil_function_requires<boost::gil::MutablePixelLocatorConcept<OL> >();
- typedef typename boost::gil::iterator_from_2d<IL>::difference_type diff_t;
- diff_t n=diff_t(last-first);
- if (first.is_1d_traversable()) {
- if (dst.is_1d_traversable())
- boost::gil::detail::copier_n<typename IL::x_iterator,typename OL::x_iterator>()(first.x(),n, dst.x());
- else
- boost::gil::detail::copier_n<typename IL::x_iterator,boost::gil::iterator_from_2d<OL> >()(first.x(),n, dst);
- } else {
- if (dst.is_1d_traversable())
- boost::gil::detail::copier_n<boost::gil::iterator_from_2d<IL>,typename OL::x_iterator>()(first,n, dst.x());
- else
- boost::gil::detail::copier_n<boost::gil::iterator_from_2d<IL>,boost::gil::iterator_from_2d<OL> >()(first,n,dst);
- }
- return dst+n;
-}
-} // namespace std
-
-namespace boost { namespace gil {
-
-
-/// \ingroup ImageViewSTLAlgorithmsCopyPixels
-/// \brief std::copy for image views
-template <typename View1, typename View2> GIL_FORCEINLINE
-void copy_pixels(const View1& src, const View2& dst) {
- assert(src.dimensions()==dst.dimensions());
- std::copy(src.begin(),src.end(),dst.begin()); // std::copy will choose the optimal method (see stl_override.h)
-}
-
-//////////////////////////////////////////////////////////////////////////////////////
-///
-/// copy_and_convert_pixels
-///
-//////////////////////////////////////////////////////////////////////////////////////
-
-/// \defgroup ImageViewSTLAlgorithmsCopyAndConvertPixels copy_and_convert_pixels
-/// \ingroup ImageViewSTLAlgorithms
-/// \brief copies src view into dst view, color converting if necessary.
-///
-/// Versions taking static and runtime views are provided. Versions taking user-defined color convered are provided.
-
-namespace detail {
-template <typename CC>
-class copy_and_convert_pixels_fn : public binary_operation_obj<copy_and_convert_pixels_fn<CC> > {
-private:
- CC _cc;
-public:
- typedef typename binary_operation_obj<copy_and_convert_pixels_fn<CC> >::result_type result_type;
- copy_and_convert_pixels_fn() {}
- copy_and_convert_pixels_fn(CC cc_in) : _cc(cc_in) {}
- // when the two color spaces are incompatible, a color conversion is performed
- template <typename V1, typename V2> GIL_FORCEINLINE
- result_type apply_incompatible(const V1& src, const V2& dst) const {
- copy_pixels(color_converted_view<typename V2::value_type>(src,_cc),dst);
- }
-
- // If the two color spaces are compatible, copy_and_convert is just copy
- template <typename V1, typename V2> GIL_FORCEINLINE
- result_type apply_compatible(const V1& src, const V2& dst) const {
- copy_pixels(src,dst);
- }
-};
-} // namespace detail
-
-/// \ingroup ImageViewSTLAlgorithmsCopyAndConvertPixels
-template <typename V1, typename V2,typename CC>
-GIL_FORCEINLINE
-void copy_and_convert_pixels(const V1& src, const V2& dst,CC cc) {
- detail::copy_and_convert_pixels_fn<CC> ccp(cc);
- ccp(src,dst);
-}
-
-struct default_color_converter;
-
-/// \ingroup ImageViewSTLAlgorithmsCopyAndConvertPixels
-template <typename View1, typename View2>
-GIL_FORCEINLINE
-void copy_and_convert_pixels(const View1& src, const View2& dst) {
- detail::copy_and_convert_pixels_fn<default_color_converter> ccp;
- ccp(src,dst);
-}
-
-} } // namespace boost::gil
-
-//////////////////////////////////////////////////////////////////////////////////////
-//
-// std::fill and gil::fill_pixels
-//
-//////////////////////////////////////////////////////////////////////////////////////
-
-/// \defgroup ImageViewSTLAlgorithmsFillPixels fill_pixels
-/// \ingroup ImageViewSTLAlgorithms
-/// \brief std::fill for image views
-
-
-namespace std {
-/// \ingroup STLOptimizations
-/// \brief std::fill(I,I,V) with I being a iterator_from_2d
-///
-/// Invoked when one calls std::fill(I,I,V) with I being a iterator_from_2d (which is
-/// a 1D iterator over the pixels in an image). For contiguous images (i.e. images that have
-/// no alignment gap at the end of each row) it is more efficient to use the underlying
-/// pixel iterator that does not check for the end of rows. For non-contiguous images fill
-/// resolves to fill of each row using the underlying pixel iterator, which is still faster
-template <typename IL, typename V>
-void fill(boost::gil::iterator_from_2d<IL> first, boost::gil::iterator_from_2d<IL> last, const V& val) {
- boost::gil::gil_function_requires<boost::gil::MutablePixelLocatorConcept<IL> >();
- if (first.is_1d_traversable()) {
- std::fill(first.x(), last.x(), val);
- } else {
- // fill row by row
- std::ptrdiff_t n=last-first;
- while (n>0) {
- std::ptrdiff_t numToDo=std::min<const std::ptrdiff_t>(n,(std::ptrdiff_t)(first.width()-first.x_pos()));
- fill_n(first.x(), numToDo, val);
- first+=numToDo;
- n-=numToDo;
- }
- }
-}
-} // namespace std
-
-namespace boost { namespace gil {
-
-namespace detail {
-/// struct to do std::fill
-struct std_fill_t {
- template <typename It, typename P>
- void operator()(It first, It last, const P& p_in) {
- std::fill(first,last,p_in);
- }
-};
-/// std::fill for planar iterators
-template <typename It, typename P>
-GIL_FORCEINLINE
-void fill_aux(It first, It last, const P& p, mpl::true_) {
- static_for_each(first,last,p,std_fill_t());
-}
-/// std::fill for interleaved iterators
-template <typename It, typename P>
-GIL_FORCEINLINE
-void fill_aux(It first, It last, const P& p,mpl::false_) {
- std::fill(first,last,p);
-}
-} // namespace detail
-
-/// \ingroup ImageViewSTLAlgorithmsFillPixels
-/// \brief std::fill for image views
-template <typename View, typename Value> GIL_FORCEINLINE
-void fill_pixels(const View& img_view, const Value& val) {
- if (img_view.is_1d_traversable())
- detail::fill_aux(img_view.begin().x(), img_view.end().x(),
- val,is_planar<View>());
- else
- for (std::ptrdiff_t y=0; y<img_view.height(); ++y)
- detail::fill_aux(img_view.row_begin(y),img_view.row_end(y),
- val,is_planar<View>());
-}
-
-//////////////////////////////////////////////////////////////////////////////////////
-///
-/// uninitialized_fill_pixels
-///
-//////////////////////////////////////////////////////////////////////////////////////
-
-/// \defgroup ImageViewSTLAlgorithmsUninitializedFillPixels uninitialized_fill_pixels
-/// \ingroup ImageViewSTLAlgorithms
-/// \brief std::uninitialized_fill for image views
-
-
-namespace detail {
-
-/// struct to do std::uninitialized_fill
-struct std_uninitialized_fill_t {
- template <typename It, typename P>
- void operator()(It first, It last, const P& p_in) {
- std::uninitialized_fill(first,last,p_in);
- }
-};
-/// std::uninitialized_fill for planar iterators
-template <typename It, typename P>
-GIL_FORCEINLINE
-void uninitialized_fill_aux(It first, It last,
- const P& p, mpl::true_) {
- static_for_each(first,last,p,std_uninitialized_fill_t());
-}
-/// std::uninitialized_fill for interleaved iterators
-template <typename It, typename P>
-GIL_FORCEINLINE
-void uninitialized_fill_aux(It first, It last,
- const P& p,mpl::false_) {
- std::uninitialized_fill(first,last,p);
-}
-
-} // namespace detail
-
-/// \ingroup ImageViewSTLAlgorithmsUninitializedFillPixels
-/// \brief std::uninitialized_fill for image views
-template <typename View, typename Value> GIL_FORCEINLINE
-void uninitialized_fill_pixels(const View& img_view, const Value& val) {
- if (img_view.is_1d_traversable())
- detail::uninitialized_fill_aux(img_view.begin().x(), img_view.end().x(),
- val,is_planar<View>());
- else
- for (std::ptrdiff_t y=0; y<img_view.height(); ++y)
- detail::uninitialized_fill_aux(img_view.row_begin(y),img_view.row_end(y),
- val,is_planar<View>());
-}
-
-//////////////////////////////////////////////////////////////////////////////////////
-///
-/// uninitialized_copy_pixels
-///
-//////////////////////////////////////////////////////////////////////////////////////
-
-/// \defgroup ImageViewSTLAlgorithmsUninitializedCopyPixels uninitialized_copy_pixels
-/// \ingroup ImageViewSTLAlgorithms
-/// \brief std::uninitialized_copy for image views
-
-namespace detail {
-/// struct to do std::uninitialized_copy
-struct std_uninitialized_copy_t {
- template <typename It1, typename It2>
- void operator()(It1 first1, It1 last1, It2 first2) {
- std::uninitialized_copy(first1,last1,first2);
- }
-};
-/// std::uninitialized_copy for pairs of planar iterators
-template <typename It1, typename It2>
-GIL_FORCEINLINE
-void uninitialized_copy_aux(It1 first1, It1 last1,
- It2 first2, mpl::true_) {
- static_for_each(first1,last1,first2,std_uninitialized_copy_t());
-}
-/// std::uninitialized_copy for interleaved or mixed iterators
-template <typename It1, typename It2>
-GIL_FORCEINLINE
-void uninitialized_copy_aux(It1 first1, It1 last1,
- It2 first2,mpl::false_) {
- std::uninitialized_copy(first1,last1,first2);
-}
-} // namespace detail
-
-/// \ingroup ImageViewSTLAlgorithmsUninitializedCopyPixels
-/// \brief std::uninitialized_copy for image views
-template <typename View1, typename View2> GIL_FORCEINLINE
-void uninitialized_copy_pixels(const View1& view1, const View2& view2) {
- typedef mpl::bool_<is_planar<View1>::value && is_planar<View2>::value> is_planar;
- assert(view1.dimensions()==view2.dimensions());
- if (view1.is_1d_traversable() && view2.is_1d_traversable())
- detail::uninitialized_copy_aux(view1.begin().x(), view1.end().x(),
- view2.begin().x(),
- is_planar());
- else
- for (std::ptrdiff_t y=0; y<view1.height(); ++y)
- detail::uninitialized_copy_aux(view1.row_begin(y), view1.row_end(y),
- view2.row_begin(y),
- is_planar());
-}
-
-//////////////////////////////////////////////////////////////////////////////////////
-///
-/// for_each_pixel
-///
-//////////////////////////////////////////////////////////////////////////////////////
-
-/// \defgroup ImageViewSTLAlgorithmsForEachPixel for_each_pixel
-/// \ingroup ImageViewSTLAlgorithms
-/// \brief std::for_each for image views
-///
-/// For contiguous images (i.e. images that have no alignment gap at the end of each row) it is
-/// more efficient to use the underlying pixel iterator that does not check for the end of rows.
-/// For non-contiguous images for_each_pixel resolves to for_each of each row using the underlying
-/// pixel iterator, which is still faster
-
-/// \ingroup ImageViewSTLAlgorithmsForEachPixel
-template <typename V, typename F>
-F for_each_pixel(const V& img, F fun) {
- if (img.is_1d_traversable()) {
- return std::for_each(img.begin().x(), img.end().x(), fun);
- } else {
- for (std::ptrdiff_t y=0; y<img.height(); ++y)
- fun = std::for_each(img.row_begin(y),img.row_end(y),fun);
- return fun;
- }
-}
-
-/// \defgroup ImageViewSTLAlgorithmsForEachPixelPosition for_each_pixel_position
-/// \ingroup ImageViewSTLAlgorithms
-/// \brief adobe::for_each_position for image views (passes locators, instead of pixel references, to the function object)
-
-/// \ingroup ImageViewSTLAlgorithmsForEachPixelPosition
-template <typename View, typename F>
-F for_each_pixel_position(const View& img, F fun) {
- typename View::xy_locator loc=img.xy_at(0,0);
- for (std::ptrdiff_t y=0; y<img.height(); ++y) {
- for (std::ptrdiff_t x=0; x<img.width(); ++x, ++loc.x())
- fun(loc);
- loc.x()-=img.width(); ++loc.y();
- }
- return fun;
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-///
-/// generate_pixels
-///
-//////////////////////////////////////////////////////////////////////////////////////
-
-/// \defgroup ImageViewSTLAlgorithmsGeneratePixels generate_pixels
-/// \ingroup ImageViewSTLAlgorithms
-/// \brief std::generate for image views
-
-/// \ingroup ImageViewSTLAlgorithmsGeneratePixels
-/// \brief std::generate for image views
-template <typename View, typename F>
-void generate_pixels(const View& v, F fun) {
- if (v.is_1d_traversable()) {
- std::generate(v.begin().x(), v.end().x(), fun);
- } else {
- for (std::ptrdiff_t y=0; y<v.height(); ++y)
- std::generate(v.row_begin(y),v.row_end(y),fun);
- }
-}
-
-//////////////////////////////////////////////////////////////////////////////////////
-///
-/// std::equal and gil::equal_pixels for GIL constructs
-///
-//////////////////////////////////////////////////////////////////////////////////////
-
-/// \defgroup ImageViewSTLAlgorithmsEqualPixels equal_pixels
-/// \ingroup ImageViewSTLAlgorithms
-/// \brief std::equal for image views
-
-template <typename I1, typename I2> GIL_FORCEINLINE bool equal_n(I1 i1, std::ptrdiff_t n, I2 i2);
-
-namespace detail {
-
-template <typename I1, typename I2>
-struct equal_n_fn {
- GIL_FORCEINLINE bool operator()(I1 i1, std::ptrdiff_t n, I2 i2) const { return std::equal(i1,i1+n, i2); }
-};
-
-/// Equal when both ranges are interleaved and of the same type.
-/// GIL pixels are bitwise comparable, so memcmp is used. User-defined pixels that are not bitwise comparable need to provide an overload
-template<typename T, typename Cs>
-struct equal_n_fn<const pixel<T,Cs>*, const pixel<T,Cs>*> {
- GIL_FORCEINLINE bool operator()(const pixel<T,Cs>* i1, std::ptrdiff_t n, const pixel<T,Cs>* i2) const {
- return memcmp(i1, i2, n*sizeof(pixel<T,Cs>))==0;
- }
-};
-template<typename T, typename Cs>
-struct equal_n_fn<pixel<T,Cs>*, pixel<T,Cs>*> : equal_n_fn<const pixel<T,Cs>*, const pixel<T,Cs>*> {};
-
-/// EqualPixels
-/// Equal when both ranges are planar pointers of the same type. memcmp is invoked for each channel plane
-/// User-defined channels that are not bitwise comparable need to provide an overload
-template<typename IC, typename Cs>
-struct equal_n_fn<planar_pixel_iterator<IC,Cs>, planar_pixel_iterator<IC,Cs> > {
- GIL_FORCEINLINE bool operator()(const planar_pixel_iterator<IC,Cs> i1, std::ptrdiff_t n, const planar_pixel_iterator<IC,Cs> i2) const {
- ptrdiff_t numBytes=n*sizeof(typename std::iterator_traits<IC>::value_type);
-
- for (std::ptrdiff_t i=0; i<mpl::size<Cs>::value; ++i)
- if (memcmp(dynamic_at_c(i1,i), dynamic_at_c(i2,i), numBytes)!=0)
- return false;
- return true;
- }
-};
-
-
-/// Source range is delimited by image iterators
-template <typename Loc, typename I2> // IL Models ConstPixelLocatorConcept, O Models PixelIteratorConcept
-struct equal_n_fn<boost::gil::iterator_from_2d<Loc>,I2> {
- GIL_FORCEINLINE bool operator()(boost::gil::iterator_from_2d<Loc> i1, std::ptrdiff_t n, I2 i2) const {
- gil_function_requires<boost::gil::PixelLocatorConcept<Loc> >();
- gil_function_requires<boost::gil::PixelIteratorConcept<I2> >();
- while (n>0) {
- std::ptrdiff_t num=std::min<const std::ptrdiff_t>(n, i1.width()-i1.x_pos());
- if (!equal_n(i1.x(), num, i2))
- return false;
- i1+=num;
- i2+=num;
- n-=num;
- }
- return true;
- }
-};
-
-/// Destination range is delimited by image iterators
-template <typename I1, typename Loc> // I Models PixelIteratorConcept, OL Models PixelLocatorConcept
-struct equal_n_fn<I1,boost::gil::iterator_from_2d<Loc> > {
- GIL_FORCEINLINE bool operator()(I1 i1, std::ptrdiff_t n, boost::gil::iterator_from_2d<Loc> i2) const {
- gil_function_requires<boost::gil::PixelIteratorConcept<I1> >();
- gil_function_requires<boost::gil::PixelLocatorConcept<Loc> >();
- while (n>0) {
- std::ptrdiff_t num=std::min<const std::ptrdiff_t>(n,i2.width()-i2.x_pos());
- if (!equal_n(i1, num, i2.x()))
- return false;
- i1+=num;
- i2+=num;
- n-=num;
- }
- return true;
- }
-};
-
-/// Both source and destination ranges are delimited by image iterators
-template <typename Loc1, typename Loc2>
-struct equal_n_fn<boost::gil::iterator_from_2d<Loc1>,boost::gil::iterator_from_2d<Loc2> > {
- GIL_FORCEINLINE bool operator()(boost::gil::iterator_from_2d<Loc1> i1, std::ptrdiff_t n, boost::gil::iterator_from_2d<Loc2> i2) const {
- gil_function_requires<boost::gil::PixelLocatorConcept<Loc1> >();
- gil_function_requires<boost::gil::PixelLocatorConcept<Loc2> >();
- if (i1.x_pos()!=i2.x_pos() || i1.width()!=i2.width()) {
- while(n-->0) {
- if (*i1++!=*i2++) return false;
- }
- }
- while (n>0) {
- std::ptrdiff_t num=std::min<const std::ptrdiff_t>(n,i2.width()-i2.x_pos());
- if (!equal_n(i1.x(), num, i2.x()))
- return false;
- i1+=num;
- i2+=num;
- n-=num;
- }
- return true;
- }
-};
-} // namespace detail
-
-template <typename I1, typename I2> GIL_FORCEINLINE
-bool equal_n(I1 i1, std::ptrdiff_t n, I2 i2) {
- return detail::equal_n_fn<I1,I2>()(i1,n,i2);
-}
-} } // namespace boost::gil
-
-namespace std {
-/// \ingroup STLOptimizations
-/// \brief std::equal(I1,I1,I2) with I1 and I2 being a iterator_from_2d
-///
-/// Invoked when one calls std::equal(I1,I1,I2) with I1 and I2 being a iterator_from_2d (which is
-/// a 1D iterator over the pixels in an image). Attempts to demote the source and destination
-/// iterators to simpler/faster types if the corresponding range is contiguous.
-/// For contiguous images (i.e. images that have
-/// no alignment gap at the end of each row) it is more efficient to use the underlying
-/// pixel iterator that does not check for the end of rows. If the underlying pixel iterator
-/// happens to be a fundamental planar/interleaved pointer, the call may further resolve
-/// to memcmp. Otherwise it resolves to copying each row using the underlying pixel iterator
-template <typename Loc1, typename Loc2> GIL_FORCEINLINE
-bool equal(boost::gil::iterator_from_2d<Loc1> first, boost::gil::iterator_from_2d<Loc1> last, boost::gil::iterator_from_2d<Loc2> first2) {
- boost::gil::gil_function_requires<boost::gil::PixelLocatorConcept<Loc1> >();
- boost::gil::gil_function_requires<boost::gil::PixelLocatorConcept<Loc2> >();
- std::ptrdiff_t n=last-first;
- if (first.is_1d_traversable()) {
- if (first2.is_1d_traversable())
- return boost::gil::detail::equal_n_fn<typename Loc1::x_iterator,typename Loc2::x_iterator>()(first.x(),n, first2.x());
- else
- return boost::gil::detail::equal_n_fn<typename Loc1::x_iterator,boost::gil::iterator_from_2d<Loc2> >()(first.x(),n, first2);
- } else {
- if (first2.is_1d_traversable())
- return boost::gil::detail::equal_n_fn<boost::gil::iterator_from_2d<Loc1>,typename Loc2::x_iterator>()(first,n, first2.x());
- else
- return boost::gil::detail::equal_n_fn<boost::gil::iterator_from_2d<Loc1>,boost::gil::iterator_from_2d<Loc2> >()(first,n,first2);
- }
-}
-} // namespace std
-
-namespace boost { namespace gil {
-
-/// \ingroup ImageViewSTLAlgorithmsEqualPixels
-/// \brief std::equal for image views
-template <typename View1, typename View2> GIL_FORCEINLINE
-bool equal_pixels(const View1& v1, const View2& v2) {
- assert(v1.dimensions()==v2.dimensions());
- return std::equal(v1.begin(),v1.end(),v2.begin()); // std::equal has overloads with GIL iterators for optimal performance
-}
-
-//////////////////////////////////////////////////////////////////////////////////////
-///
-/// transform_pixels
-///
-//////////////////////////////////////////////////////////////////////////////////////
-
-/// \defgroup ImageViewSTLAlgorithmsTransformPixels transform_pixels
-/// \ingroup ImageViewSTLAlgorithms
-/// \brief std::transform for image views
-
-/// \ingroup ImageViewSTLAlgorithmsTransformPixels
-/// \brief std::transform for image views
-template <typename View1, typename View2, typename F> GIL_FORCEINLINE
-F transform_pixels(const View1& src,const View2& dst, F fun) {
- assert(src.dimensions()==dst.dimensions());
- for (std::ptrdiff_t y=0; y<src.height(); ++y) {
- typename View1::x_iterator srcIt=src.row_begin(y);
- typename View2::x_iterator dstIt=dst.row_begin(y);
- for (std::ptrdiff_t x=0; x<src.width(); ++x)
- dstIt[x]=fun(srcIt[x]);
- }
- return fun;
-}
-
-/// \ingroup ImageViewSTLAlgorithmsTransformPixels
-/// \brief transform_pixels with two sources
-template <typename View1, typename View2, typename View3, typename F> GIL_FORCEINLINE
-F transform_pixels(const View1& src1, const View2& src2,const View3& dst, F fun) {
- for (std::ptrdiff_t y=0; y<dst.height(); ++y) {
- typename View1::x_iterator srcIt1=src1.row_begin(y);
- typename View2::x_iterator srcIt2=src2.row_begin(y);
- typename View3::x_iterator dstIt=dst.row_begin(y);
- for (std::ptrdiff_t x=0; x<dst.width(); ++x)
- dstIt[x]=fun(srcIt1[x],srcIt2[x]);
- }
- return fun;
-}
-
-/// \defgroup ImageViewSTLAlgorithmsTransformPixelPositions transform_pixel_positions
-/// \ingroup ImageViewSTLAlgorithms
-/// \brief adobe::transform_positions for image views (passes locators, instead of pixel references, to the function object)
-
-/// \ingroup ImageViewSTLAlgorithmsTransformPixelPositions
-/// \brief Like transform_pixels but passes to the function object pixel locators instead of pixel references
-template <typename View1, typename View2, typename F> GIL_FORCEINLINE
-F transform_pixel_positions(const View1& src,const View2& dst, F fun) {
- assert(src.dimensions()==dst.dimensions());
- typename View1::xy_locator loc=src.xy_at(0,0);
- for (std::ptrdiff_t y=0; y<src.height(); ++y) {
- typename View2::x_iterator dstIt=dst.row_begin(y);
- for (std::ptrdiff_t x=0; x<src.width(); ++x, ++loc.x())
- dstIt[x]=fun(loc);
- loc.x()-=src.width(); ++loc.y();
- }
- return fun;
-}
-
-/// \ingroup ImageViewSTLAlgorithmsTransformPixelPositions
-/// \brief transform_pixel_positions with two sources
-template <typename View1, typename View2, typename View3, typename F> GIL_FORCEINLINE
-F transform_pixel_positions(const View1& src1,const View2& src2,const View3& dst, F fun) {
- assert(src1.dimensions()==dst.dimensions());
- assert(src2.dimensions()==dst.dimensions());
- typename View1::xy_locator loc1=src1.xy_at(0,0);
- typename View2::xy_locator loc2=src2.xy_at(0,0);
- for (std::ptrdiff_t y=0; y<src1.height(); ++y) {
- typename View3::x_iterator dstIt=dst.row_begin(y);
- for (std::ptrdiff_t x=0; x<src1.width(); ++x, ++loc1.x(), ++loc2.x())
- dstIt[x]=fun(loc1,loc2);
- loc1.x()-=src1.width(); ++loc1.y();
- loc2.x()-=src2.width(); ++loc2.y();
- }
- return fun;
-}
-
-} } // namespace boost::gil
-
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
-
-#endif
View
498 k3dsdk/gil/boost/gil/channel.hpp
@@ -1,498 +0,0 @@
-/*
- Copyright 2005-2007 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)
-*/
-
-/*************************************************************************************************/
-
-#ifndef GIL_CHANNEL_HPP
-#define GIL_CHANNEL_HPP
-
-////////////////////////////////////////////////////////////////////////////////////////
-/// \file
-/// \brief Channel utilities
-/// \author Lubomir Bourdev and Hailin Jin \n
-/// Adobe Systems Incorporated
-/// \date 2005-2007 \n Last updated on September 18, 2006
-///
-/// Definitions of standard GIL channel models
-///
-////////////////////////////////////////////////////////////////////////////////////////
-
-#include <limits>
-#include <cassert>
-#include <boost/cstdint.hpp>
-#include "gil_config.hpp"
-#include "utilities.hpp"
-
-namespace boost { namespace gil {
-
-
-///////////////////////////////////////////
-//// channel_traits
-////
-//// \ingroup ChannelModel
-//// \class channel_traits
-//// \brief defines properties of channels, such as their range and associated types
-////
-//// The channel traits must be defined for every model of ChannelConcept
-//// Default traits are provided. For built-in types the default traits use
-//// built-in pointer and reference and the channel range is the physical
-//// range of the type. For classes, the default traits forward the associated types
-//// and range to the class.
-////
-///////////////////////////////////////////
-
-namespace detail {
- template <typename T, bool is_class> struct channel_traits_impl;
-
- /// \brief channel traits for custom class
- /// \ingroup ChannelModel
- template <typename T>
- struct channel_traits_impl<T, true> {
- typedef typename T::value_type value_type;
- typedef typename T::reference reference;
- typedef typename T::pointer pointer;
- typedef typename T::const_reference const_reference;
- typedef typename T::const_pointer const_pointer;
- BOOST_STATIC_CONSTANT(bool, is_mutable=T::is_mutable);
- static value_type min_value() { return T::min_value(); }
- static value_type max_value() { return T::max_value(); }
- };
-
- /// \brief channel traits implementation for built-in scalar or floating point channel type
- /// \ingroup ChannelModel
- template <typename T>
- struct channel_traits_impl<T, false> {
- typedef T value_type;
- typedef T& reference;
- typedef T* pointer;
- typedef const T& const_reference;
- typedef T const* const_pointer;
- BOOST_STATIC_CONSTANT(bool, is_mutable=true);
- static value_type min_value() { return std::numeric_limits<T>::min(); }
- static value_type max_value() { return std::numeric_limits<T>::max(); }
- };
-
- /// \brief channel traits implementation for constant built-in scalar or floating point type
- /// \ingroup ChannelModel
- template <typename T>
- struct channel_traits_impl<const T, false> : public channel_traits_impl<T, false> {
- typedef const T& reference;
- typedef const T* pointer;
- BOOST_STATIC_CONSTANT(bool, is_mutable=false);
- };
-}
-
-template <typename T>
-struct channel_traits : public detail::channel_traits_impl<T, is_class<T>::value> {};
-
-/// \ingroup ChannelModel
-/// \brief Channel traits for C++ reference type - remove the reference
-template <typename T> struct channel_traits< T&> : public channel_traits<T> {};
-
-/// \ingroup ChannelModel
-/// \brief Channel traits for constant C++ reference type
-template <typename T> struct channel_traits<const T&> : public channel_traits<T> {
- typedef typename channel_traits<T>::const_reference reference;
- typedef typename channel_traits<T>::const_pointer pointer;
- BOOST_STATIC_CONSTANT(bool, is_mutable=false);
-};
-
-///////////////////////////////////////////
-////
-//// scoped_channel_value
-////
-///////////////////////////////////////////
-
-/// \defgroup ScopedChannelValue scoped_channel_value
-/// \ingroup ChannelModel
-/// \brief A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept
-
-/// \ingroup ScopedChannelValue
-/// \brief A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept
-template <typename BaseChannelValue, // base channel (models ChannelValueConcept)
- typename MinVal, typename MaxVal> // classes with a static apply() function returning the minimum/maximum channel values
-struct scoped_channel_value {
- typedef scoped_channel_value value_type;
- typedef value_type& reference;
- typedef value_type* pointer;
- typedef const value_type& const_reference;
- typedef const value_type* const_pointer;
- BOOST_STATIC_CONSTANT(bool, is_mutable=channel_traits<BaseChannelValue>::is_mutable);
-
- static value_type min_value() { return MinVal::apply(); }
- static value_type max_value() { return MaxVal::apply(); }
-
- scoped_channel_value() {}
- scoped_channel_value(const scoped_channel_value& c) : _value(c._value) {}
- scoped_channel_value(BaseChannelValue val) : _value(val) {}
-
- scoped_channel_value& operator++() { ++_value; return *this; }
- scoped_channel_value& operator--() { --_value; return *this; }
-
- scoped_channel_value operator++(int) { scoped_channel_value tmp=*this; this->operator++(); return tmp; }
- scoped_channel_value operator--(int) { scoped_channel_value tmp=*this; this->operator--(); return tmp; }
-
- template <typename Scalar2> scoped_channel_value& operator+=(Scalar2 v) { _value+=v; return *this; }
- template <typename Scalar2> scoped_channel_value& operator-=(Scalar2 v) { _value-=v; return *this; }
- template <typename Scalar2> scoped_channel_value& operator*=(Scalar2 v) { _value*=v; return *this; }
- template <typename Scalar2> scoped_channel_value& operator/=(Scalar2 v) { _value/=v; return *this; }
-
- scoped_channel_value& operator=(BaseChannelValue v) { _value=v; return *this; }
- operator BaseChannelValue() const { return _value; }
-private:
- BaseChannelValue _value;
-};
-
-struct float_zero { static float apply() { return 0.0f; } };
-struct float_one { static float apply() { return 1.0f; } };
-
-
-///////////////////////////////////////////
-////
-//// Support for sub-byte channels. These are integral channels whose value is contained in a range of bits inside an integral type
-////
-///////////////////////////////////////////
-
-// It is necessary for packed channels to have their own value type. They cannot simply use an integral large enough to store the data. Here is why:
-// - Any operation that requires returning the result by value will otherwise return the built-in integral type, which will have incorrect range
-// That means that after getting the value of the channel we cannot properly do channel_convert, channel_invert, etc.
-// - Two channels are declared compatible if they have the same value type. That means that a packed channel is incorrectly declared compatible with an integral type
-namespace detail {
- // returns the smallest fast unsigned integral type that has at least NumBits bits
- template <int NumBits>
- struct min_fast_uint : public mpl::if_c< (NumBits<8),
- uint_least8_t,
- typename mpl::if_c< (NumBits<16), uint_least16_t,
- uint_least32_t>::type > {};
-}
-/// \defgroup PackedChannelValueModel packed_channel_value
-/// \ingroup ChannelModel
-/// \brief Represents the value of an unsigned integral channel operating over a bit range. Models: ChannelValueConcept
-
-/// \ingroup PackedChannelValueModel
-/// \brief The value of a subbyte channel. Models: ChannelValueConcept
-template <int NumBits>
-class packed_channel_value {
- static const std::size_t num_values = 1<<NumBits;
-public:
- typedef typename detail::min_fast_uint<NumBits>::type integer_t;
-
- typedef packed_channel_value value_type;
- typedef value_type& reference;
- typedef const value_type& const_reference;
- typedef value_type* pointer;
- typedef const value_type* const_pointer;
-
- static value_type min_value() { return value_type(0); }
- static value_type max_value() { return value_type(num_values-1); }
- BOOST_STATIC_CONSTANT(bool, is_mutable=true);
-
- packed_channel_value() {}
- packed_channel_value(integer_t v) : _value(v % num_values) {}
- packed_channel_value(const packed_channel_value& v) : _value(v._value) {}
- template <typename Scalar> packed_channel_value(Scalar v) : _value(integer_t(v) % num_values) {} // suppress GCC implicit conversion warnings in channel regression file
-
- operator integer_t() const { return _value; }
-private:
- integer_t _value;
-};
-
-namespace detail {
-template <typename Derived, typename BitField, int NumBits, bool Mutable>
-class packed_channel_reference_base {
-protected:
- typedef typename mpl::if_c<Mutable,BitField&,const BitField&>::type data_ref_t;
- data_ref_t _data;
-
- static const BitField max_val = (1<<NumBits) - 1;
-public:
- typedef packed_channel_value<NumBits> value_type;
- typedef const Derived reference;
- typedef value_type* pointer;
- typedef const value_type* const_pointer;
- BOOST_STATIC_CONSTANT(bool, is_mutable=Mutable);
-
- static value_type min_value() { return channel_traits<value_type>::min_value(); }
- static value_type max_value() { return channel_traits<value_type>::max_value(); }
-
- typedef typename value_type::integer_t integer_t;
-
- packed_channel_reference_base(data_ref_t data) : _data(data) {}
- packed_channel_reference_base(const packed_channel_reference_base& ref) : _data(ref._data) {}
- const Derived& operator=(integer_t v) const { set(v); return derived(); }
-
- const Derived& operator++() const { set(get()+1); return derived(); }
- const Derived& operator--() const { set(get()-1); return derived(); }
-
- Derived operator++(int) const { Derived tmp=derived(); this->operator++(); return tmp; }
- Derived operator--(int) const { Derived tmp=derived(); this->operator--(); return tmp; }
-
- template <typename Scalar2> const Derived& operator+=(Scalar2 v) const { set(get()+v); return derived(); }
- template <typename Scalar2> const Derived& operator-=(Scalar2 v) const { set(get()-v); return derived(); }
- template <typename Scalar2> const Derived& operator*=(Scalar2 v) const { set(get()*v); return derived(); }
- template <typename Scalar2> const Derived& operator/=(Scalar2 v) const { set(get()/v); return derived(); }
-
- operator integer_t() const { return get(); }
- BitField* operator &() const {return &_data;}
-private:
- void set(integer_t value) const { // can this be done faster??
- const integer_t num_values = max_val+1;
- this->derived().set_unsafe(((value % num_values) + num_values) % num_values);
- }
- integer_t get() const { return derived().get(); }
- const Derived& derived() const { return static_cast<const Derived&>(*this); }
-};
-} // namespace detail
-
-/// \defgroup PackedChannelReferenceModel packed_channel_reference
-/// \ingroup ChannelModel
-/// \brief Represents a reference proxy to a channel operating over a bit range whose offset is fixed at compile time. Models ChannelConcept
-
-template <typename BitField, // An integral type (the data type containing the bits of interest). Models unsigned integer
- int FirstBit, int NumBits,// Defines the sequence of bits in the data value that contain the channel
- bool Mutable> // true if the reference is mutable
-class packed_channel_reference;
-
-/// \ingroup PackedChannelReferenceModel
-/// \brief A constant subbyte channel reference whose bit offset is fixed at compile time. Models ChannelConcept
-template <typename BitField, int FirstBit, int NumBits>
-class packed_channel_reference<BitField,FirstBit,NumBits,false>
- : public detail::packed_channel_reference_base<packed_channel_reference<BitField,FirstBit,NumBits,false>,BitField,NumBits,false> {
- typedef detail::packed_channel_reference_base<packed_channel_reference<BitField,FirstBit,NumBits,false>,BitField,NumBits,false> parent_t;
- static const BitField channel_mask = parent_t::max_val<<FirstBit;
- typedef typename parent_t::integer_t integer_t;
-
- typedef packed_channel_reference<BitField,FirstBit,NumBits,true> mutable_reference;
- friend class packed_channel_reference<BitField,FirstBit,NumBits,true>;
-public:
- typedef const packed_channel_reference const_reference;
-
- explicit packed_channel_reference(const BitField& data) : parent_t(data) {}
- packed_channel_reference(const packed_channel_reference& ref) : parent_t(ref._data) {}
- packed_channel_reference(const mutable_reference& ref) : parent_t(ref._data) {}
-
- integer_t get() const { return (this->_data&(parent_t::max_val<<FirstBit)) >> FirstBit; }
-};
-
-/// \ingroup PackedChannelReferenceModel
-/// \brief A mutable subbyte channel reference whose bit offset is fixed at compile time. Models ChannelConcept
-template <typename BitField, int FirstBit, int NumBits>
-class packed_channel_reference<BitField,FirstBit,NumBits,true>
- : public detail::packed_channel_reference_base<packed_channel_reference<BitField,FirstBit,NumBits,true>,BitField,NumBits,true> {
- typedef detail::packed_channel_reference_base<packed_channel_reference<BitField,FirstBit,NumBits,true>,BitField,NumBits,true> parent_t;
- static const BitField channel_mask = parent_t::max_val<<FirstBit;
-
- typedef typename parent_t::integer_t integer_t;
- friend class packed_channel_reference<BitField,FirstBit,NumBits,false>;
-public:
- typedef packed_channel_reference<BitField,FirstBit,NumBits,false> const_reference;
-
- explicit packed_channel_reference(BitField& data) : parent_t(data) {}
- packed_channel_reference(const packed_channel_reference& ref) : parent_t(ref._data) {}
-
- const packed_channel_reference& operator=(integer_t value) const { assert(value<=parent_t::max_val); set_unsafe(value); return *this; }
- const packed_channel_reference& operator=(const packed_channel_reference& ref) const { set_from_reference(ref._data); return *this; }
- const packed_channel_reference& operator=(const const_reference& ref) const { set_from_reference(ref._data); return *this; }
-
- integer_t get() const { return (this->_data&channel_mask) >> FirstBit; }
- void set_unsafe(integer_t value) const { this->_data = (this->_data & ~channel_mask) | (value<<FirstBit); }
-private:
- void set_from_reference(const BitField& data) const { this->_data = (this->_data & ~channel_mask) | (data & channel_mask); }
-};
-
-} } // namespace boost::gil
-
-namespace std {
-// We are forced to define swap inside std namespace because on some platforms (Visual Studio 8) STL calls swap qualified.
-// swap with 'left bias':
-// - swap between proxy and anything
-// - swap between value type and proxy
-// - swap between proxy and proxy
-
-/// \ingroup PackedChannelReferenceModel
-/// \brief swap for packed_channel_reference
-template <typename BF, int FB, int NB, bool M, typename R> inline
-void swap(boost::gil::packed_channel_reference<BF,FB,NB,M> x, R& y) {
- boost::gil::swap_proxy<typename boost::gil::packed_channel_reference<BF,FB,NB,M>::value_type>(x,y);
-}
-
-
-/// \ingroup PackedChannelReferenceModel
-/// \brief swap for packed_channel_reference
-template <typename BF, int FB, int NB, bool M> inline
-void swap(typename boost::gil::packed_channel_reference<BF,FB,NB,M>::value_type& x, boost::gil::packed_channel_reference<BF,FB,NB,M> y) {
- boost::gil::swap_proxy<typename boost::gil::packed_channel_reference<BF,FB,NB,M>::value_type>(x,y);
-}
-
-
-/// \ingroup PackedChannelReferenceModel
-/// \brief swap for packed_channel_reference
-template <typename BF, int FB, int NB, bool M> inline
-void swap(boost::gil::packed_channel_reference<BF,FB,NB,M> x, boost::gil::packed_channel_reference<BF,FB,NB,M> y) {
- boost::gil::swap_proxy<typename boost::gil::packed_channel_reference<BF,FB,NB,M>::value_type>(x,y);
-}
-} // namespace std
-
-namespace boost { namespace gil {
-
-
-
-/// \defgroup PackedChannelDynamicReferenceModel packed_dynamic_channel_reference
-/// \ingroup ChannelModel
-/// \brief Represents a reference proxy to a channel operating over a bit range whose offset is specified at run time. Models ChannelConcept
-
-template <typename BitField, // An integral type (the data type containing the bits of interest). Models unsigned integer
- int NumBits, // Defines the sequence of bits in the data value that contain the channel
- bool Mutable> // true if the reference is mutable
-class packed_dynamic_channel_reference;
-
-/// \brief Models a constant subbyte channel reference whose bit offset is a runtime parameter. Models ChannelConcept
-/// Same as packed_channel_reference, except that the offset is a runtime parameter
-/// \ingroup PackedChannelDynamicReferenceModel
-template <typename BitField, int NumBits>
-class packed_dynamic_channel_reference<BitField,NumBits,false>
- : public detail::packed_channel_reference_base<packed_dynamic_channel_reference<BitField,NumBits,false>,BitField,NumBits,false> {
- typedef detail::packed_channel_reference_base<packed_dynamic_channel_reference<BitField,NumBits,false>,BitField,NumBits,false> parent_t;
- int _first_bit;
-
- typedef packed_dynamic_channel_reference<BitField,NumBits,true> mutable_reference;
- typedef typename parent_t::integer_t integer_t;
-public:
- typedef packed_dynamic_channel_reference<BitField,NumBits,false> const_reference;
-
- packed_dynamic_channel_reference(typename parent_t::data_ref_t data, int first_bit) : parent_t(data), _first_bit(first_bit) {}
- packed_dynamic_channel_reference(const packed_dynamic_channel_reference& ref) : parent_t(ref._data), _first_bit(ref._first_bit) {}
- packed_dynamic_channel_reference(const mutable_reference& ref) : parent_t(ref._data), _first_bit(ref._first_bit) {}
-
- integer_t get() const {
- const BitField channel_mask = parent_t::max_val<<_first_bit;
- return (this->_data&channel_mask) >> _first_bit;
- }
-};
-
-/// \brief Models a mutable subbyte channel reference whose bit offset is a runtime parameter. Models ChannelConcept
-/// Same as packed_channel_reference, except that the offset is a runtime parameter
-/// \ingroup PackedChannelDynamicReferenceModel
-template <typename BitField, int NumBits>
-class packed_dynamic_channel_reference<BitField,NumBits,true>
- : public detail::packed_channel_reference_base<packed_dynamic_channel_reference<BitField,NumBits,true>,BitField,NumBits,true> {
- typedef detail::packed_channel_reference_base<packed_dynamic_channel_reference<BitField,NumBits,true>,BitField,NumBits,true> parent_t;
- int _first_bit;
-
- typedef typename parent_t::integer_t integer_t;
-public:
- typedef packed_dynamic_channel_reference<BitField,NumBits,false> const_reference;
-
- packed_dynamic_channel_reference(typename parent_t::data_ref_t data, int first_bit) : parent_t(data), _first_bit(first_bit) {}
- packed_dynamic_channel_reference(const packed_dynamic_channel_reference& ref) : parent_t(ref._data), _first_bit(ref._first_bit) {}
-
- const packed_dynamic_channel_reference& operator=(integer_t value) const { assert(value<=parent_t::max_val); set_unsafe(value); return *this; }
- const packed_dynamic_channel_reference& operator=(const packed_dynamic_channel_reference& ref) const { set_unsafe(ref.get()); return *this; }
- const packed_dynamic_channel_reference& operator=(const const_reference& ref) const { set_unsafe(ref.get()); return *this; }
-
- integer_t get() const {
- const BitField channel_mask = parent_t::max_val<<_first_bit;
- return (this->_data&channel_mask) >> _first_bit;
- }
- void set_unsafe(integer_t value) const {
- const BitField channel_mask = parent_t::max_val<<_first_bit;
- this->_data = (this->_data & ~channel_mask) | value<<_first_bit;
- }
-};
-} } // namespace boost::gil
-
-namespace std {
-// We are forced to define swap inside std namespace because on some platforms (Visual Studio 8) STL calls swap qualified.
-// swap with 'left bias':
-// - swap between proxy and anything
-// - swap between value type and proxy
-// - swap between proxy and proxy
-
-
-/// \ingroup PackedChannelDynamicReferenceModel
-/// \brief swap for packed_dynamic_channel_reference
-template <typename BF, int NB, bool M, typename R> inline
-void swap(boost::gil::packed_dynamic_channel_reference<BF,NB,M> x, R& y) {
- boost::gil::swap_proxy<typename boost::gil::packed_dynamic_channel_reference<BF,NB,M>::value_type>(x,y);
-}
-
-
-/// \ingroup PackedChannelDynamicReferenceModel
-/// \brief swap for packed_dynamic_channel_reference
-template <typename BF, int NB, bool M> inline
-void swap(typename boost::gil::packed_dynamic_channel_reference<BF,NB,M>::value_type& x, boost::gil::packed_dynamic_channel_reference<BF,NB,M> y) {
- boost::gil::swap_proxy<typename boost::gil::packed_dynamic_channel_reference<BF,NB,M>::value_type>(x,y);
-}
-
-
-/// \ingroup PackedChannelDynamicReferenceModel
-/// \brief swap for packed_dynamic_channel_reference
-template <typename BF, int NB, bool M> inline
-void swap(boost::gil::packed_dynamic_channel_reference<BF,NB,M> x, boost::gil::packed_dynamic_channel_reference<BF,NB,M> y) {
- boost::gil::swap_proxy<typename boost::gil::packed_dynamic_channel_reference<BF,NB,M>::value_type>(x,y);
-}
-} // namespace std
-
-namespace boost { namespace gil {
-///////////////////////////////////////////
-////
-//// Built-in channel models
-////
-///////////////////////////////////////////
-
-/// \defgroup bits8 bits8
-/// \ingroup ChannelModel
-/// \brief 8-bit unsigned integral channel type. Models ChannelValueConcept
-
-/// \ingroup bits8
-typedef uint8_t bits8;
-
-/// \defgroup bits16 bits16
-/// \ingroup ChannelModel
-/// \brief 16-bit unsigned integral channel type. Models ChannelValueConcept
-
-/// \ingroup bits16
-typedef uint16_t bits16;
-
-/// \defgroup bits32 bits32
-/// \ingroup ChannelModel
-/// \brief 32-bit unsigned integral channel type. Models ChannelValueConcept
-
-/// \ingroup bits32
-typedef uint32_t bits32;
-
-/// \defgroup bits8s bits8s
-/// \ingroup ChannelModel
-/// \brief 8-bit signed integral channel type. Models ChannelValueConcept
-
-/// \ingroup bits8s
-typedef int8_t bits8s;
-
-/// \defgroup bits16s bits16s
-/// \ingroup ChannelModel
-/// \brief 16-bit signed integral channel type. Models ChannelValueConcept
-
-/// \ingroup bits16s
-typedef int16_t bits16s;
-
-/// \defgroup bits32s bits32s
-/// \ingroup ChannelModel
-/// \brief 32-bit signed integral channel type. Models ChannelValueConcept
-
-/// \ingroup bits32s
-typedef int32_t bits32s;
-
-/// \defgroup bits32f bits32f
-/// \ingroup ChannelModel
-/// \brief 32-bit floating point channel type with range [0.0f ... 1.0f]. Models ChannelValueConcept
-
-/// \ingroup bits32f
-typedef scoped_channel_value<float,float_zero,float_one> bits32f;
-
-} } // namespace boost::gil
-
-
-#endif
View
295 k3dsdk/gil/boost/gil/channel_algorithm.hpp
@@ -1,295 +0,0 @@
-/*
- Copyright 2005-2007 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)
-*/
-
-/*************************************************************************************************/
-
-#ifndef GIL_CHANNEL_ALGORITHM_HPP
-#define GIL_CHANNEL_ALGORITHM_HPP
-
-////////////////////////////////////////////////////////////////////////////////////////
-/// \file
-/// \brief Channel algorithms
-/// \author Lubomir Bourdev and Hailin Jin \n
-/// Adobe Systems Incorporated
-/// \date 2005-2007 \n Last updated on September 18, 2006
-///
-/// Definitions of standard GIL 8-bit, 16-bit, 32-bit channels
-///
-////////////////////////////////////////////////////////////////////////////////////////
-
-#include "gil_config.hpp"
-#include "channel.hpp"
-
-namespace boost { namespace gil {
-
-/**
-\defgroup ChannelConvertAlgorithm channel_convert
-\brief Converting from one channel type to another
-\ingroup ChannelAlgorithm
-
-Conversion is done as a simple linear mapping of one channel range to the other,
-such that the minimum/maximum value of the source maps to the minimum/maximum value of the destination.
-One implication of this is that the value 0 of signed channels may not be preserved!
-
-When creating new channel models, it is often a good idea to provide specializations for the channel conversion algorithms, for
-example, for performance optimizations. If the new model is an integral type that can be signed, it is easier to define the conversion
-only for the unsigned type (\p channel_converter_unsigned) and provide specializations of \p channel_convert_to_unsigned and \p channel_convert_to_signed
-to convert between the signed and unsigned type.
-*/
-
-/**
-\defgroup ChannelConvertUnsignedAlgorithm channel_converter_unsigned
-\ingroup ChannelConvertAlgorithm
-\brief Convert one unsigned/floating point channel to another. Converts both the channel type and range
- @{
- */
-
-/// \brief This is the default implementation. Performance specializatons are provided
-template <typename SrcChannelV, typename DstChannelV> // Model ChannelValueConcept
-struct channel_converter_unsigned : public std::unary_function<DstChannelV,SrcChannelV> {
- DstChannelV operator()(SrcChannelV src) const {
- return DstChannelV(src / channel_range<SrcChannelV>() * channel_range<DstChannelV>());
- }
-private:
- template <typename C>
- static double channel_range() {
- return double(channel_traits<C>::max_value()) - double(channel_traits<C>::min_value());
- }
-};
-
-/// \brief Converting a channel to itself - identity operation
-template <typename T> struct channel_converter_unsigned<T,T> : public detail::identity<T> {};
-
-/// \brief 8 bit <-> 16 bit channel conversion
-template <> struct channel_converter_unsigned<bits16,bits8> : public std::unary_function<bits16,bits8> {
- bits8 operator()(bits16 x) const { return static_cast<bits8>(x/257); }
-};
-/// \brief 8 bit <-> 16 bit channel conversion
-template <> struct channel_converter_unsigned<bits8,bits16> : public std::unary_function<bits8,bits16> {
- bits16 operator()(bits8 x) const { return static_cast<bits16>(x*257); }
-};
-
-/// \brief 8 bit <-> 32 bit channel conversion
-template <> struct channel_converter_unsigned<bits32,bits8> : public std::unary_function<bits32,bits8> {
- bits8 operator()(bits32 x) const { return static_cast<bits8>(x/16843009); }
-};
-/// \brief 8 bit <-> 32 bit channel conversion
-template <> struct channel_converter_unsigned<bits8,bits32> : public std::unary_function<bits8,bits32> {
- bits32 operator()(bits8 x) const { return static_cast<bits32>(x*16843009); }
-};
-
-/// \brief 8 bit <-> float0..1 channel conversion
-template <> struct channel_converter_unsigned<bits32f,bits8> : public std::unary_function<bits32f,bits8> {
- bits8 operator()(bits32f x) const { return static_cast<bits8>(x*255+0.5f); }
-};
-/// \brief 8 bit <-> float0..1 channel conversion
-template <> struct channel_converter_unsigned<bits8,bits32f> : public std::unary_function<bits8,bits32f> {
- bits32f operator()(bits8 x) const { return static_cast<bits32f>(x/255.0f); }
-};
-
-/// \brief 16 bit <-> float0..1 channel conversion
-template <> struct channel_converter_unsigned<bits32f,bits16> : public std::unary_function<bits32f,bits16> {
- bits16 operator()(bits32f x) const { return static_cast<bits16>(x*65535+0.5f); }
-};
-/// \brief 16 bit <-> float0..1 channel conversion
-template <> struct channel_converter_unsigned<bits16,bits32f> : public std::unary_function<bits16,bits32f> {
- bits32f operator()(bits16 x) const { return static_cast<bits32f>(x/65535.0f); }
-};
-
-/// \brief 16 bit <-> 32 bit channel conversion
-template <> struct channel_converter_unsigned<bits32,bits16> : public std::unary_function<bits32,bits16> {
- bits16 operator()(bits32 x) const { return static_cast<bits16>(x/65537); }
-};
-/// \brief 16 bit <-> 32 bit channel conversion
-template <> struct channel_converter_unsigned<bits16,bits32> : public std::unary_function<bits16,bits32> {
- bits32 operator()(bits16 x) const { return static_cast<bits32>(x*65537); }
-};
-
-/// \brief 32 bit <-> float channel conversion
-template <> struct channel_converter_unsigned<bits32,bits32f> : public std::unary_function<bits32,bits32f> {
- bits32f operator()(bits32 x) const {
- // unfortunately without an explicit check it is possible to get a round-off error. We must ensure that max_value of bits32 matches max_value of bits32f
- if (x>=channel_traits<bits32>::max_value()) return channel_traits<bits32f>::max_value();
- return float(x) / float(channel_traits<bits32>::max_value());
- }
-};
-/// \brief 32 bit <-> float channel conversion
-template <> struct channel_converter_unsigned<bits32f,bits32> : public std::unary_function<bits32f,bits32> {
- bits32 operator()(bits32f x) const {
- // unfortunately without an explicit check it is possible to get a round-off error. We must ensure that max_value of bits32 matches max_value of bits32f
- if (x>=channel_traits<bits32f>::max_value()) return channel_traits<bits32>::max_value();
- return bits32(x * channel_traits<bits32>::max_value() + 0.5f);
- }
-};
-/// @}
-
-/**
-\defgroup ChannelConvertToUnsignedAlgorithm channel_convert_to_unsigned
-\brief Convert signed channel to unsigned. By default it is an identity operation. Specializations are provided for signed integral channels
-\ingroup ChannelConvertAlgorithm
-
-@{
-*/
-
-/// \brief Converting from signed to unsigned integral channel.
-/// It is both a unary function, and a metafunction (thus requires the 'type' nested typedef, which equals result_type)
-template <typename ChannelValue> // Model ChannelValueConcept
-struct channel_convert_to_unsigned : public detail::identity<ChannelValue> {
- typedef ChannelValue type;
-};
-
-/// \brief Converting from 8-bit signed to 8-bit unsigned integral channel
-template <> struct channel_convert_to_unsigned<bits8s> : public std::unary_function<bits8s,bits8> {
- typedef bits8 type;
- type operator()(bits8s val) const { return val+128; }
-};
-
-/// \brief Converting from 16-bit signed to 16-bit unsigned integral channel
-template <> struct channel_convert_to_unsigned<bits16s> : public std::unary_function<bits16s,bits16> {
- typedef bits16 type;
- type operator()(bits16s val) const { return val+32768; }
-};
-
-/// \brief Converting from 32-bit signed to 32-bit unsigned integral channel
-template <> struct channel_convert_to_unsigned<bits32s> : public std::unary_function<bits32s,bits32> {
- typedef bits32 type;
- type operator()(bits32s x) const { return static_cast<bits32>(x+(1<<31)); }
-};
-/// @}
-
-/**
-\defgroup ChannelConvertToSignedAlgorithm channel_convert_to_signed
-\brief Convert unsigned channel to signed. By default it is an identity operation. Specializations are provided for signed integral channels
-\ingroup ChannelConvertAlgorithm
-
-@{
-*/
-
-/// \brief Converting from unsigned to signed integral channel
-/// It is both a unary function, and a metafunction (thus requires the 'type' nested typedef, which equals result_type)
-template <typename ChannelValue> // Model ChannelValueConcept
-struct channel_convert_to_signed : public detail::identity<ChannelValue> {
- typedef ChannelValue type;
-};
-
-/// \brief Converting from 8-bit unsigned to 8-bit signed integral channel
-template <> struct channel_convert_to_signed<bits8s> : public std::unary_function<bits8,bits8s> {
- typedef bits8s type;
- type operator()(bits8 val) const { return val-128; }
-};
-
-/// \brief Converting from 16-bit unsigned to 16-bit signed integral channel
-template <> struct channel_convert_to_signed<bits16s> : public std::unary_function<bits16,bits16s> {
- typedef bits16s type;
- type operator()(bits16 val) const { return val-32768; }
-};
-
-/// \brief Converting from 32-bit unsigned to 32-bit signed integral channel
-template <> struct channel_convert_to_signed<bits32s> : public std::unary_function<bits32,bits32s> {
- typedef bits32s type;
- type operator()(bits32 x) const { return static_cast<bits32s>(x-(1<<31)); }
-};
-/// @}
-
-/// \ingroup ChannelConvertAlgorithm
-/// \brief A unary function object converting between channel types
-template <typename SrcChannelV, typename DstChannelV> // Model ChannelValueConcept
-struct channel_converter : public std::unary_function<SrcChannelV,DstChannelV> {
- DstChannelV operator()(SrcChannelV src) const {
- typedef channel_convert_to_unsigned<SrcChannelV> to_unsigned;
- typedef channel_convert_to_signed<DstChannelV> to_signed;
- typedef channel_converter_unsigned<typename to_unsigned::result_type, typename to_signed::argument_type> converter_unsigned;
- return to_signed()(converter_unsigned()(to_unsigned()(src)));
- }
-};
-
-/// \ingroup ChannelConvertAlgorithm
-/// \brief Converting from one channel type to another.
-template <typename DstChannel, typename SrcChannel> // Model ChannelConcept (could be channel references)
-inline typename channel_traits<DstChannel>::value_type channel_convert(SrcChannel src) {
- return channel_converter<typename channel_traits<SrcChannel>::value_type,
- typename channel_traits<DstChannel>::value_type>()(src);
-}
-
-/// \ingroup ChannelConvertAlgorithm
-/// \brief Same as channel_converter, except it takes the destination channel by reference, which allows
-/// us to move the templates from the class level to the method level. This is important when invoking it
-/// on heterogeneous pixels.
-struct default_channel_converter {
- template <typename Ch1, typename Ch2>
- void operator()(const Ch1& src, Ch2& dst) const {
- dst=channel_convert<Ch2>(src);
- }
-};
-
-namespace detail {
- // fast integer division by 255
- inline uint32_t div255(uint32_t in) { uint32_t tmp=in+128; return (tmp + (tmp>>8))>>8; }
-
- // fast integer divison by 32768
- inline uint32_t div32768(uint32_t in) { return (in+16384)>>15; }
-}
-
-/// \defgroup ChannelMultiplyAlgorithm channel_multiply
-/// \ingroup ChannelAlgorithm
-/// \brief Multiplying unsigned channel values of the same type. Performs scaled multiplication result = a * b / max_value
-/// @{
-
-/// \brief This is the default implementation. Performance specializatons are provided
-template <typename ChannelValue>
-struct channel_multiplier_unsigned : public std::binary_function<ChannelValue,ChannelValue,ChannelValue> {
- ChannelValue operator()(ChannelValue a, ChannelValue b) const {
- return ChannelValue(a / double(channel_traits<ChannelValue>::max_value()) * b);
- }
-};
-
-/// \brief Specialization of channel_multiply for 8-bit unsigned channels
-template<> struct channel_multiplier_unsigned<bits8> : public std::binary_function<bits8,bits8,bits8> {
- bits8 operator()(bits8 a, bits8 b) const { return bits8(detail::div255(uint32_t(a) * uint32_t(b))); }
-};
-
-/// \brief Specialization of channel_multiply for 16-bit unsigned channels
-template<> struct channel_multiplier_unsigned<bits16> : public std::binary_function<bits16,bits16,bits16> {
- bits16 operator()(bits16 a, bits16 b) const { return bits16((uint32_t(a) * uint32_t(b))/65535); }
-};
-
-/// \brief Specialization of channel_multiply for float 0..1 channels
-template<> struct channel_multiplier_unsigned<bits32f> : public std::binary_function<bits32f,bits32f,bits32f> {
- bits32f operator()(bits32f a, bits32f b) const { return a*b; }
-};
-
-/// \brief A function object to multiply two channels. result = a * b / max_value
-template <typename ChannelValue>
-struct channel_multiplier : public std::binary_function<ChannelValue, ChannelValue, ChannelValue> {
- ChannelValue operator()(ChannelValue a, ChannelValue b) const {
- typedef channel_convert_to_unsigned<ChannelValue> to_unsigned;
- typedef channel_convert_to_signed<ChannelValue> to_signed;
- typedef channel_multiplier_unsigned<typename to_unsigned::result_type> multiplier_unsigned;
- return to_signed()(multiplier_unsigned()(to_unsigned()(a), to_unsigned()(b)));
- }
-};
-
-/// \brief A function multiplying two channels. result = a * b / max_value
-template <typename Channel> // Models ChannelConcept (could be a channel reference)
-inline typename channel_traits<Channel>::value_type channel_multiply(Channel a, Channel b) {
- return channel_multiplier<typename channel_traits<Channel>::value_type>()(a,b);
-}
-/// @}
-
-/// \defgroup ChannelInvertAlgorithm channel_invert
-/// \ingroup ChannelAlgorithm
-/// \brief Returns the inverse of a channel. result = max_value - x + min_value
-
-/// \brief Default implementation. Provide overloads for performance
-/// \ingroup ChannelInvertAlgorithm channel_invert
-template <typename Channel> // Models ChannelConcept (could be a channel reference)
-inline typename channel_traits<Channel>::value_type channel_invert(Channel x) {
- return channel_traits<Channel>::max_value()-x + channel_traits<Channel>::min_value();
-}
-
-} } // namespace boost::gil
-
-#endif
View
60 k3dsdk/gil/boost/gil/cmyk.hpp
@@ -1,60 +0,0 @@
-/*
- Copyright 2005-2007 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)
-*/
-
-/*************************************************************************************************/
-
-#ifndef GIL_CMYK_H
-#define GIL_CMYK_H
-
-////////////////////////////////////////////////////////////////////////////////////////
-/// \file
-/// \brief Support for CMYK color space and variants
-/// \author Lubomir Bourdev and Hailin Jin \n
-/// Adobe Systems Incorporated
-/// \date 2005-2007 \n Last updated on September 18, 2006
-////////////////////////////////////////////////////////////////////////////////////////
-
-#include "gil_config.hpp"
-#include "metafunctions.hpp"
-#include <boost/mpl/range_c.hpp>
-#include <boost/mpl/vector_c.hpp>
-
-namespace boost { namespace gil {
-
-
-/// \addtogroup ColorNameModel
-/// \{
-
-/// \brief Cyan
-struct cyan_t {};
-
-/// \brief Magenta
-struct magenta_t {};
-
-/// \brief Yellow
-struct yellow_t {};
-
-/// \brief Black
-struct black_t {};
-/// \}
-
-/// \ingroup ColorSpaceModel
-typedef mpl::vector4<cyan_t,magenta_t,yellow_t,black_t> cmyk_t;
-
-/// \ingroup LayoutModel
-typedef layout<cmyk_t> cmyk_layout_t;
-
-/// \ingroup ImageViewConstructors
-/// \brief from raw CMYK planar data
-template <typename IC>
-inline typename type_from_x_iterator<planar_pixel_iterator<IC,cmyk_t> >::view_t planar_cmyk_view(int width, int height, IC c, IC m, IC y, IC k, std::ptrdiff_t rowsize_in_bytes) {
- typedef typename type_from_x_iterator<planar_pixel_iterator<IC,cmyk_t> >::view_t RVIEW;
- return RVIEW(width, height, typename RVIEW::locator(planar_pixel_iterator<IC,cmyk_t>(c,m,y,k), rowsize_in_bytes));
-}
-
-} } // namespace gil
-
-#endif
View
393 k3dsdk/gil/boost/gil/color_base.hpp
@@ -1,393 +0,0 @@
-/*
- Copyright 2005-2007 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)
-*/
-
-/*************************************************************************************************/
-
-#ifndef GIL_COLOR_BASE_HPP
-#define GIL_COLOR_BASE_HPP
-
-////////////////////////////////////////////////////////////////////////////////////////
-/// \file
-/// \brief pixel class and related utilities
-/// \author Lubomir Bourdev and Hailin Jin \n
-/// Adobe Systems Incorporated
-/// \date 2005-2007 \n Last updated on September 28, 2006
-///
-////////////////////////////////////////////////////////////////////////////////////////
-
-#include <cassert>
-#include <boost/mpl/range_c.hpp>
-#include <boost/mpl/size.hpp>
-#include <boost/mpl/vector_c.hpp>
-#include <boost/type_traits.hpp>
-#include <boost/utility/enable_if.hpp>
-
-#include "gil_config.hpp"
-#include "utilities.hpp"
-#include "gil_concept.hpp"
-
-namespace boost { namespace gil {
-
-// Forward-declare semantic_at_c
-template <int K, typename ColorBase>
-typename disable_if<is_const<ColorBase>,typename kth_semantic_element_reference_type<ColorBase,K>::type>::type semantic_at_c(ColorBase& p);
-template <int K, typename ColorBase>
-typename kth_semantic_element_const_reference_type<ColorBase,K>::type semantic_at_c(const ColorBase& p);
-
-// Forward declare element_reference_type
-template <typename ColorBase> struct element_reference_type;
-template <typename ColorBase> struct element_const_reference_type;
-
-namespace detail {
-
-template <typename DstLayout, typename SrcLayout, int K>
-struct mapping_transform
- : public mpl::at<typename SrcLayout::channel_mapping_t,
- typename detail::type_to_index<typename DstLayout::channel_mapping_t,mpl::integral_c<int,K> >::type
- >::type {};
-
-/// \defgroup ColorBaseModelHomogeneous detail::homogeneous_color_base
-/// \ingroup ColorBaseModel
-/// \brief A homogeneous color base holding one color element. Models HomogeneousColorBaseConcept or HomogeneousColorBaseValueConcept
-/// If the element type models Regular, this class models HomogeneousColorBaseValueConcept.
-
-
-template <typename Element, typename Layout>
-struct homogeneous_color_base_impl {
- typedef Layout layout_t;
-
- template <int K> struct kth_element_type { typedef Element type; };
- template <int K> struct kth_element_reference_type : public add_reference<Element> {};
- template <int K> struct kth_element_const_reference_type : public add_reference<typename add_const<Element>::type> {};
-};
-
-
-template <typename Element, typename Layout, int K> struct homogeneous_color_base;
-
-/// \brief A homogeneous color base holding one color element. Models HomogeneousColorBaseConcept or HomogeneousColorBaseValueConcept
-/// \ingroup ColorBaseModelHomogeneous
-template <typename Element, typename Layout>
-struct homogeneous_color_base<Element,Layout,1> : public homogeneous_color_base_impl<Element,Layout> {
-private:
- Element _v0;
-public:
- typename element_reference_type<homogeneous_color_base>::type at(mpl::int_<0>) { return _v0; }
- typename element_const_reference_type<homogeneous_color_base>::type at(mpl::int_<0>) const { return _v0; }
-
- homogeneous_color_base() {}
- homogeneous_color_base(Element v) : _v0(v) {}
-
- // grayscale pixel values are convertible to channel type
- operator Element () const { return _v0; }
-
- template <typename E2, typename L2> homogeneous_color_base(const homogeneous_color_base<E2,L2,1>& c) : _v0(at_c<0>(c)) {}
-};
-
-
-/// \brief A homogeneous color base holding two color elements. Models HomogeneousColorBaseConcept or HomogeneousColorBaseValueConcept
-/// \ingroup ColorBaseModelHomogeneous
-template <typename Element, typename Layout>
-struct homogeneous_color_base<Element,Layout,2> : public homogeneous_color_base_impl<Element,Layout> {
-private:
- Element _v0, _v1;
-public:
- typename element_reference_type<homogeneous_color_base>::type at(mpl::int_<0>) { return _v0; }
- typename element_const_reference_type<homogeneous_color_base>::type at(mpl::int_<0>) const { return _v0; }
- typename element_reference_type<homogeneous_color_base>::type at(mpl::int_<1>) { return _v1; }
- typename element_const_reference_type<homogeneous_color_base>::type at(mpl::int_<1>) const { return _v1; }
-
- homogeneous_color_base() {}
- explicit homogeneous_color_base(Element v) : _v0(v), _v1(v) {}
- homogeneous_color_base(Element v0, Element v1) : _v0(v0), _v1(v1) {}
-
- template <typename E2, typename L2> homogeneous_color_base(const homogeneous_color_base<E2,L2,2>& c) :
- _v0(at_c<mapping_transform<Layout,L2,0>::value>(c)),
- _v1(at_c<mapping_transform<Layout,L2,1>::value>(c)) {}
-
- // Support for l-value reference proxy copy construction
- template <typename E2, typename L2> homogeneous_color_base( homogeneous_color_base<E2,L2,2>& c) :
- _v0(at_c<mapping_transform<Layout,L2,0>::value>(c)),
- _v1(at_c<mapping_transform<Layout,L2,1>::value>(c)) {}
-
- // Support for planar_pixel_iterator construction and dereferencing
- template <typename P> homogeneous_color_base(P* p,bool) :
- _v0(&semantic_at_c<0>(*p)),
- _v1(&semantic_at_c<1>(*p)) {}
- template <typename Ref> Ref deref() const {
- return Ref(*semantic_at_c<0>(*this),
- *semantic_at_c<1>(*this)); }
-
- // Support for planar_pixel_reference offset constructor
- template <typename Ptr> homogeneous_color_base(const Ptr& ptr, std::ptrdiff_t diff)
- : _v0(*byte_advanced(semantic_at_c<0>(ptr),diff)),
- _v1(*byte_advanced(semantic_at_c<1>(ptr),diff)) {}
-
- // Support for planar_pixel_reference operator[]
- Element at_c_dynamic(size_t i) const {
- if (i==0) return _v0;
- return _v1;
- }
-};
-
-/// \brief A homogeneous color base holding three color elements. Models HomogeneousColorBaseConcept or HomogeneousColorBaseValueConcept
-/// \ingroup ColorBaseModelHomogeneous
-template <typename Element, typename Layout>
-struct homogeneous_color_base<Element,Layout,3> : public homogeneous_color_base_impl<Element,Layout> {
-private:
- Element _v0, _v1, _v2;
-public:
- typename element_reference_type<homogeneous_color_base>::type at(mpl::int_<0>) { return _v0; }
- typename element_const_reference_type<homogeneous_color_base>::type at(mpl::int_<0>) const { return _v0; }
- typename element_reference_type<homogeneous_color_base>::type at(mpl::int_<1>) { return _v1; }
- typename element_const_reference_type<homogeneous_color_base>::type at(mpl::int_<1>) const { return _v1; }
- typename element_reference_type<homogeneous_color_base>::type at(mpl::int_<2>) { return _v2; }
- typename element_const_reference_type<homogeneous_color_base>::type at(mpl::int_<2>) const { return _v2; }
-
- homogeneous_color_base() {}
- explicit homogeneous_color_base(Element v) : _v0(v), _v1(v), _v2(v) {}
- homogeneous_color_base(Element v0, Element v1, Element v2) : _v0(v0), _v1(v1), _v2(v2) {}
-
- template <typename E2, typename L2> homogeneous_color_base(const homogeneous_color_base<E2,L2,3>& c) :
- _v0(at_c<mapping_transform<Layout,L2,0>::value>(c)),
- _v1(at_c<mapping_transform<Layout,L2,1>::value>(c)),
- _v2(at_c<mapping_transform<Layout,L2,2>::value>(c)) {}
-
- // Support for l-value reference proxy copy construction
- template <typename E2, typename L2> homogeneous_color_base( homogeneous_color_base<E2,L2,3>& c) :
- _v0(at_c<mapping_transform<Layout,L2,0>::value>(c)),
- _v1(at_c<mapping_transform<Layout,L2,1>::value>(c)),
- _v2(at_c<mapping_transform<Layout,L2,2>::value>(c)) {}
-
- // Support for planar_pixel_iterator construction and dereferencing
- template <typename P> homogeneous_color_base(P* p,bool) :
- _v0(&semantic_at_c<0>(*p)),
- _v1(&semantic_at_c<1>(*p)),
- _v2(&semantic_at_c<2>(*p)) {}
- template <typename Ref> Ref deref() const {
- return Ref(*semantic_at_c<0>(*this),
- *semantic_at_c<1>(*this),
- *semantic_at_c<2>(*this)); }
-
- // Support for planar_pixel_reference offset constructor
- template <typename Ptr> homogeneous_color_base(const Ptr& ptr, std::ptrdiff_t diff)
- : _v0(*byte_advanced(semantic_at_c<0>(ptr),diff)),
- _v1(*byte_advanced(semantic_at_c<1>(ptr),diff)),
- _v2(*byte_advanced(semantic_at_c<2>(ptr),diff)) {}
-
- // Support for planar_pixel_reference operator[]
- Element at_c_dynamic(size_t i) const {
- switch (i) {
- case 0: return _v0;
- case 1: return _v1;
- }
- return _v2;
- }
-};
-
-/// \brief A homogeneous color base holding four color elements. Models HomogeneousColorBaseConcept or HomogeneousColorBaseValueConcept
-/// \ingroup ColorBaseModelHomogeneous
-template <typename Element, typename Layout>
-struct homogeneous_color_base<Element,Layout,4> : public homogeneous_color_base_impl<Element,Layout> {
-private:
- Element _v0, _v1, _v2, _v3;
-public:
- typename element_reference_type<homogeneous_color_base>::type at(mpl::int_<0>) { return _v0; }
- typename element_const_reference_type<homogeneous_color_base>::type at(mpl::int_<0>) const { return _v0; }
- typename element_reference_type<homogeneous_color_base>::type at(mpl::int_<1>) { return _v1; }
- typename element_const_reference_type<homogeneous_color_base>::type at(mpl::int_<1>) const { return _v1; }
- typename element_reference_type<homogeneous_color_base>::type at(mpl::int_<2>) { return _v2; }
- typename element_const_reference_type<homogeneous_color_base>::type at(mpl::int_<2>) const { return _v2; }
- typename element_reference_type<homogeneous_color_base>::type at(mpl::int_<3>) { return _v3; }
- typename element_const_reference_type<homogeneous_color_base>::type at(mpl::int_<3>) const { return _v3; }
- homogeneous_color_base() {}
- explicit homogeneous_color_base(Element v) : _v0(v), _v1(v), _v2(v), _v3(v) {}
- homogeneous_color_base(Element v0, Element v1, Element v2, Element v3) : _v0(v0), _v1(v1), _v2(v2), _v3(v3) {}
-
- template <typename E2, typename L2> homogeneous_color_base(const homogeneous_color_base<E2,L2,4>& c) :
- _v0(at_c<mapping_transform<Layout,L2,0>::value>(c)),
- _v1(at_c<mapping_transform<Layout,L2,1>::value>(c)),
- _v2(at_c<mapping_transform<Layout,L2,2>::value>(c)),
- _v3(at_c<mapping_transform<Layout,L2,3>::value>(c)) {}
-
- // Support for l-value reference proxy copy construction
- template <typename E2, typename L2> homogeneous_color_base( homogeneous_color_base<E2,L2,4>& c) :
- _v0(at_c<mapping_transform<Layout,L2,0>::value>(c)),
- _v1(at_c<mapping_transform<Layout,L2,1>::value>(c)),
- _v2(at_c<mapping_transform<Layout,L2,2>::value>(c)),
- _v3(at_c<mapping_transform<Layout,L2,3>::value>(c)) {}
-
- // Support for planar_pixel_iterator construction and dereferencing
- template <typename P> homogeneous_color_base(P* p,bool) :
- _v0(&semantic_at_c<0>(*p)),
- _v1(&semantic_at_c<1>(*p)),
- _v2(&semantic_at_c<2>(*p)),
- _v3(&semantic_at_c<3>(*p)) {}
-
- template <typename Ref> Ref deref() const {
- return Ref(*semantic_at_c<0>(*this),
- *semantic_at_c<1>(*this),
- *semantic_at_c<2>(*this),
- *semantic_at_c<3>(*this)); }
-
- // Support for planar_pixel_reference offset constructor
- template <typename Ptr> homogeneous_color_base(const Ptr& ptr, std::ptrdiff_t diff)
- : _v0(*byte_advanced(semantic_at_c<0>(ptr),diff)),
- _v1(*byte_advanced(semantic_at_c<1>(ptr),diff)),
- _v2(*byte_advanced(semantic_at_c<2>(ptr),diff)),
- _v3(*byte_advanced(semantic_at_c<3>(ptr),diff)) {}
-
- // Support for planar_pixel_reference operator[]
- Element at_c_dynamic(size_t i) const {
- switch (i) {
- case 0: return _v0;
- case 1: return _v1;
- case 2: return _v2;
- }
- return _v3;
- }
-};
-
-/// \brief A homogeneous color base holding five color elements. Models HomogeneousColorBaseConcept or HomogeneousColorBaseValueConcept
-/// \ingroup ColorBaseModelHomogeneous
-template <typename Element, typename Layout>
-struct homogeneous_color_base<Element,Layout,5> : public homogeneous_color_base_impl<Element,Layout> {
-private:
- Element _v0, _v1, _v2, _v3, _v4;
-public:
- typename element_reference_type<homogeneous_color_base>::type at(mpl::int_<0>) { return _v0; }
- typename element_const_reference_type<homogeneous_color_base>::type at(mpl::int_<0>) const { return _v0; }
- typename element_reference_type<homogeneous_color_base>::type at(mpl::int_<1>) { return _v1; }
- typename element_const_reference_type<homogeneous_color_base>::type at(mpl::int_<1>) const { return _v1; }
- typename element_reference_type<homogeneous_color_base>::type at(mpl::int_<2>) { return _v2; }
- typename element_const_reference_type<homogeneous_color_base>::type at(mpl::int_<2>) const { return _v2; }
- typename element_reference_type<homogeneous_color_base>::type at(mpl::int_<3>) { return _v3; }
- typename element_const_reference_type<homogeneous_color_base>::type at(mpl::int_<3>) const { return _v3; }
- typename element_reference_type<homogeneous_color_base>::type at(mpl::int_<4>) { return _v4; }
- typename element_const_reference_type<homogeneous_color_base>::type at(mpl::int_<4>) const { return _v4; }
- homogeneous_color_base() {}
- explicit homogeneous_color_base(Element v) : _v0(v), _v1(v), _v2(v), _v3(v), _v4(v) {}
- homogeneous_color_base(Element v0, Element v1, Element v2, Element v3, Element v4) : _v0(v0), _v1(v1), _v2(v2), _v3(v3), _v4(v4) {}
-
- template <typename E2, typename L2> homogeneous_color_base(const homogeneous_color_base<E2,L2,5>& c) :
- _v0(at_c<mapping_transform<Layout,L2,0>::value>(c)),
- _v1(at_c<mapping_transform<Layout,L2,1>::value>(c)),
- _v2(at_c<mapping_transform<Layout,L2,2>::value>(c)),
- _v3(at_c<mapping_transform<Layout,L2,3>::value>(c)),
- _v4(at_c<mapping_transform<Layout,L2,4>::value>(c)) {}
-
- // Support for l-value reference proxy copy construction
- template <typename E2, typename L2> homogeneous_color_base( homogeneous_color_base<E2,L2,5>& c) :
- _v0(at_c<mapping_transform<Layout,L2,0>::value>(c)),
- _v1(at_c<mapping_transform<Layout,L2,1>::value>(c)),
- _v2(at_c<mapping_transform<Layout,L2,2>::value>(c)),
- _v3(at_c<mapping_transform<Layout,L2,3>::value>(c)),
- _v4(at_c<mapping_transform<Layout,L2,4>::value>(c)) {}
-
- // Support for planar_pixel_iterator construction and dereferencing
- template <typename P> homogeneous_color_base(P* p,bool) :
- _v0(&semantic_at_c<0>(*p)),
- _v1(&semantic_at_c<1>(*p)),
- _v2(&semantic_at_c<2>(*p)),
- _v3(&semantic_at_c<3>(*p)),
- _v4(&semantic_at_c<4>(*p)) {}
-
- template <typename Ref> Ref deref() const {
- return Ref(*semantic_at_c<0>(*this),
- *semantic_at_c<1>(*this),
- *semantic_at_c<2>(*this),
- *semantic_at_c<3>(*this),
- *semantic_at_c<4>(*this)); }
-
- // Support for planar_pixel_reference offset constructor
- template <typename Ptr> homogeneous_color_base(const Ptr& ptr, std::ptrdiff_t diff)
- : _v0(*byte_advanced(semantic_at_c<0>(ptr),diff)),
- _v1(*byte_advanced(semantic_at_c<1>(ptr),diff)),
- _v2(*byte_advanced(semantic_at_c<2>(ptr),diff)),
- _v3(*byte_advanced(semantic_at_c<3>(ptr),diff)),
- _v4(*byte_advanced(semantic_at_c<4>(ptr),diff)) {}
-
- // Support for planar_pixel_reference operator[]
- Element at_c_dynamic(size_t i) const {
- switch (i) {
- case 0: return _v0;
- case 1: return _v1;
- case 2: return _v2;
- case 3: return _v3;
- }
- return _v4;
- }
-};
-
-// The following way of casting adjacent channels (the contents of color_base) into an array appears to be unsafe
-// -- there is no guarantee that the compiler won't add any padding between adjacent channels.
-// Note, however, that GIL _must_ be compiled with compiler settings ensuring there is no padding in the color base structs.
-// This is because the color base structs must model the interleaved organization in memory. In other words, the client may
-// have existing RGB image in the form "RGBRGBRGB..." and we must be able to represent it with an array of RGB color bases (i.e. RGB pixels)
-// with no padding. We have tested with char/int/float/double channels on gcc and VC and have so far discovered no problem.
-// We have even tried using strange channels consisting of short + char (3 bytes). With the default 4-byte alignment on VC, the size
-// of this channel is padded to 4 bytes, so an RGB pixel of it will be 4x3=12 bytes. The code below will still work properly.
-// However, the client must nevertheless ensure that proper compiler settings are used for their compiler and their channel types.
-
-template <typename Element, typename Layout, int K>
-typename element_reference_type<homogeneous_color_base<Element,Layout,K> >::type
-dynamic_at_c(homogeneous_color_base<Element,Layout,K>& cb, std::size_t i) {
- assert(i<K);
- return (gil_reinterpret_cast<Element*>(&cb))[i];
-}
-
-template <typename Element, typename Layout, int K>
-typename element_const_reference_type<homogeneous_color_base<Element,Layout,K> >::type
-dynamic_at_c(const homogeneous_color_base<Element,Layout,K>& cb, std::size_t i) {
- assert(i<K);
- return (gil_reinterpret_cast_c<const Element*>(&cb))[i];
-}
-
-template <typename Element, typename Layout, int K>
-typename element_reference_type<homogeneous_color_base<Element&,Layout,K> >::type
-dynamic_at_c(const homogeneous_color_base<Element&,Layout,K>& cb, std::size_t i) {
- assert(i<K);
- return cb.at_c_dynamic(i);
-}
-
-template <typename Element, typename Layout, int K>
-typename element_const_reference_type<homogeneous_color_base<const Element&,Layout,K> >::type
-dynamic_at_c(const homogeneous_color_base<const Element&,Layout,K>& cb, std::size_t i) {
- assert(i<K);
- return cb.at_c_dynamic(i);
-}
-
-
-} // namespace detail
-
-/// \brief Provides mutable access to the K-th element, in physical order
-/// \ingroup ColorBaseModelHomogeneous
-template <int K, typename E, typename L, int N> inline
-typename add_reference<E>::type
-at_c( detail::homogeneous_color_base<E,L,N>& p) { return p.at(mpl::int_<K>()); };
-
-/// \brief Provides constant access to the K-th element, in physical order
-/// \ingroup ColorBaseModelHomogeneous
-template <int K, typename E, typename L, int N> inline
-typename add_reference<typename add_const<E>::type>::type
-at_c(const detail::homogeneous_color_base<E,L,N>& p) { return p.at(mpl::int_<K>()); };
-
-namespace detail {
- struct swap_fn {
- template <typename T> void operator()(T& x, T& y) const {
- using std::swap;
- swap(x,y);
- }
- };
-}
-template <typename E, typename L, int N> inline
-void swap(detail::homogeneous_color_base<E,L,N>& x, detail::homogeneous_color_base<E,L,N>& y) {
- static_for_each(x,y,detail::swap_fn());
-};
-
-
-} } // namespace boost::gil
-
-#endif
View
535 k3dsdk/gil/boost/gil/color_base_algorithm.hpp
@@ -1,535 +0,0 @@
-/*
- Copyright 2005-2007 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)
-*/
-
-/*************************************************************************************************/
-
-#ifndef GIL_COLOR_BASE_ALGORITHM_HPP
-#define GIL_COLOR_BASE_ALGORITHM_HPP
-
-////////////////////////////////////////////////////////////////////////////////////////
-/// \file
-/// \brief pixel related algorithms
-/// \author Lubomir Bourdev and Hailin Jin \n
-/// Adobe Systems Incorporated
-/// \date 2005-2007 \n Last updated on February 16, 2007
-///
-////////////////////////////////////////////////////////////////////////////////////////
-
-#include <algorithm>
-#include <boost/type_traits.hpp>
-#include <boost/utility/enable_if.hpp>
-#include <boost/mpl/contains.hpp>
-#include <boost/mpl/at.hpp>
-#include "gil_config.hpp"
-#include "gil_concept.hpp"
-#include "utilities.hpp"
-
-namespace boost { namespace gil {
-
-
-///////////////////////////////////////
-///
-/// size: Semantic channel size
-///
-///////////////////////////////////////
-
-/// \defgroup ColorBaseAlgorithmSize size
-/// \ingroup ColorBaseAlgorithm
-/// \brief Returns an MPL integral type specifying the number of elements in a color base
-
-/// \brief Returns an MPL integral type specifying the number of elements in a color base
-/// \ingroup ColorBaseAlgorithmSize
-template <typename ColorBase>
-struct size : public mpl::size<typename ColorBase::layout_t::color_space_t> {};
-
-///////////////////////////////////////
-///
-/// semantic_at_c: Semantic channel accessors
-///
-///////////////////////////////////////
-
-/// \defgroup ColorBaseAlgorithmSemanticAtC kth_semantic_element_type, kth_semantic_element_reference_type, kth_semantic_element_const_reference_type, semantic_at_c
-/// \ingroup ColorBaseAlgorithm
-/// \brief Support for accessing the elements of a color base by semantic index
-/// The semantic index of an element is the index of its color in the color space. Semantic indexing allows for proper pairing of elements of color bases
-/// independent on their layout. For example, red is the first semantic element of a color base regardless of whether it has an RGB layout or a BGR layout.
-/// All GIL color base algorithms taking multiple color bases use semantic indexing to access their elements.
-
-/// \brief Specifies the type of the K-th semantic element of a color base
-/// \ingroup ColorBaseAlgorithmSemanticAtC
-template <typename ColorBase, int K> struct kth_semantic_element_type {
- BOOST_STATIC_CONSTANT(int, semantic_index = (mpl::at_c<typename ColorBase::layout_t::channel_mapping_t,K>::type::value));
- typedef typename ColorBase::template kth_element_type<semantic_index>::type type;
-};
-
-/// \brief Specifies the return type of the mutable semantic_at_c<K>(color_base);
-/// \ingroup ColorBaseAlgorithmSemanticAtC
-template <typename ColorBase, int K> struct kth_semantic_element_reference_type {
- BOOST_STATIC_CONSTANT(int, semantic_index = (mpl::at_c<typename ColorBase::layout_t::channel_mapping_t,K>::type::value));
- typedef typename ColorBase::template kth_element_reference_type<semantic_index>::type type;
- static type get(ColorBase& cb) { return boost::gil::at_c<semantic_index>(cb); }
-};
-
-/// \brief Specifies the return type of the constant semantic_at_c<K>(color_base);
-/// \ingroup ColorBaseAlgorithmSemanticAtC
-template <typename ColorBase, int K> struct kth_semantic_element_const_reference_type {
- BOOST_STATIC_CONSTANT(int, semantic_index = (mpl::at_c<typename ColorBase::layout_t::channel_mapping_t,K>::type::value));
- typedef typename ColorBase::template kth_element_const_reference_type<semantic_index>::type type;
- static type get(const ColorBase& cb) { return boost::gil::at_c<semantic_index>(cb); }
-};
-
-/// \brief A mutable accessor to the K-th semantic element of a color base
-/// \ingroup ColorBaseAlgorithmSemanticAtC
-template <int K, typename ColorBase> inline
-typename disable_if<is_const<ColorBase>,typename kth_semantic_element_reference_type<ColorBase,K>::type>::type
-semantic_at_c(ColorBase& p) {
- return kth_semantic_element_reference_type<ColorBase,K>::get(p);
-};
-
-/// \brief A constant accessor to the K-th semantic element of a color base
-/// \ingroup ColorBaseAlgorithmSemanticAtC
-template <int K, typename ColorBase> inline
-typename kth_semantic_element_const_reference_type<ColorBase,K>::type
-semantic_at_c(const ColorBase& p) {
- return kth_semantic_element_const_reference_type<ColorBase,K>::get(p);
-};
-
-///////////////////////////////////////
-///
-/// get_color: Named channel accessors
-///
-///////////////////////////////////////
-
-/// \defgroup ColorBaseAlgorithmColor color_element_type, color_element_reference_type, color_element_const_reference_type, get_color
-/// \ingroup ColorBaseAlgorithm
-/// \brief Support for accessing the elements of a color base by color name
-
-template <typename ColorBase, typename Color>
-struct color_index_type : public detail::type_to_index<typename ColorBase::layout_t::color_space_t,Color> {};
-
-/// \brief Specifies the type of the element associated with a given color tag
-/// \ingroup ColorBaseAlgorithmColor
-template <typename Color, typename ColorBase>
-struct color_element_type : public kth_semantic_element_type<ColorBase,color_index_type<ColorBase,Color>::value> {};
-
-/// \brief Specifies the return type of the mutable element accessor by color name, get_color(color_base, Color());
-/// \ingroup ColorBaseAlgorithmColor
-template <typename Color, typename ColorBase>
-struct color_element_reference_type : public kth_semantic_element_reference_type<ColorBase,color_index_type<ColorBase,Color>::value> {};
-
-/// \brief Specifies the return type of the constant element accessor by color name, get_color(color_base, Color());
-/// \ingroup ColorBaseAlgorithmColor
-template <typename Color, typename ColorBase>
-struct color_element_const_reference_type : public kth_semantic_element_const_reference_type<ColorBase,color_index_type<ColorBase,Color>::value> {};
-
-/// \brief Mutable accessor to the element associated with a given color name
-/// \ingroup ColorBaseAlgorithmColor
-template <typename CB, typename Color>
-typename color_element_reference_type<Color,CB>::type get_color(CB& cb, Color=Color()) {
- return color_element_reference_type<Color,CB>::get(cb);
-}
-
-/// \brief Constant accessor to the element associated with a given color name
-/// \ingroup ColorBaseAlgorithmColor
-template <typename CB, typename Color>
-typename color_element_const_reference_type<Color,CB>::type get_color(const CB& cb, Color=Color()) {
- return color_element_const_reference_type<Color,CB>::get(cb);
-}
-
-///////////////////////////////////////
-///
-/// element_type, element_reference_type, element_const_reference_type: Support for homogeneous color bases
-///
-///////////////////////////////////////
-