Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r73405 - in sandbox/gil/boost/gil/extension/io2: . backends backends/detail backends/libtiff backends/wic detail devices
From: dsaritz_at_[hidden]
Date: 2011-07-27 18:19:02


Author: psiha
Date: 2011-07-27 18:18:58 EDT (Wed, 27 Jul 2011)
New Revision: 73405
URL: http://svn.boost.org/trac/boost/changeset/73405

Log:
Renamed the formatted_image* classes and modules to backend*.
Added a separate directory for backends and normalized source file names for individual backends.

Removed redundant include directives.
Fixed the LibTIFF writer module.
Minor other refactoring and stylistic changes.
Added:
   sandbox/gil/boost/gil/extension/io2/backends/ (props changed)
   sandbox/gil/boost/gil/extension/io2/backends/detail/ (props changed)
   sandbox/gil/boost/gil/extension/io2/backends/detail/backend.hpp
      - copied, changed from r73403, /sandbox/gil/boost/gil/extension/io2/formatted_image.hpp
   sandbox/gil/boost/gil/extension/io2/backends/detail/extern_lib_guard.hpp
      - copied, changed from r73384, /sandbox/gil/boost/gil/extension/io2/detail/extern_lib.hpp
   sandbox/gil/boost/gil/extension/io2/backends/detail/reader.hpp
      - copied, changed from r73403, /sandbox/gil/boost/gil/extension/io2/backend_reader.hpp
   sandbox/gil/boost/gil/extension/io2/backends/detail/reader_for.hpp
      - copied, changed from r73403, /sandbox/gil/boost/gil/extension/io2/reader.hpp
   sandbox/gil/boost/gil/extension/io2/backends/detail/writer.hpp
      - copied, changed from r73403, /sandbox/gil/boost/gil/extension/io2/backend_writer.hpp
   sandbox/gil/boost/gil/extension/io2/backends/detail/writer_for.hpp
      - copied, changed from r73403, /sandbox/gil/boost/gil/extension/io2/writer.hpp
   sandbox/gil/boost/gil/extension/io2/backends/libtiff/ (props changed)
   sandbox/gil/boost/gil/extension/io2/backends/libtiff/backend.hpp
      - copied, changed from r73403, /sandbox/gil/boost/gil/extension/io2/libtiff_image.hpp
   sandbox/gil/boost/gil/extension/io2/backends/libtiff/reader.hpp
      - copied, changed from r73404, /sandbox/gil/boost/gil/extension/io2/libtiff_reader.hpp
   sandbox/gil/boost/gil/extension/io2/backends/libtiff/writer.hpp
      - copied, changed from r73403, /sandbox/gil/boost/gil/extension/io2/libtiff_writer.hpp
   sandbox/gil/boost/gil/extension/io2/backends/wic/ (props changed)
   sandbox/gil/boost/gil/extension/io2/backends/wic/backend.hpp
      - copied, changed from r73403, /sandbox/gil/boost/gil/extension/io2/wic_image.hpp
   sandbox/gil/boost/gil/extension/io2/backends/wic/extern_lib_guard.hpp
      - copied, changed from r73403, /sandbox/gil/boost/gil/extension/io2/detail/wic_extern_lib_guard.hpp
   sandbox/gil/boost/gil/extension/io2/backends/wic/reader.hpp
      - copied, changed from r73403, /sandbox/gil/boost/gil/extension/io2/wic_reader.hpp
   sandbox/gil/boost/gil/extension/io2/backends/wic/writer.hpp
      - copied, changed from r73403, /sandbox/gil/boost/gil/extension/io2/wic_writer.hpp
Removed:
   sandbox/gil/boost/gil/extension/io2/backend_reader.hpp
   sandbox/gil/boost/gil/extension/io2/backend_writer.hpp
   sandbox/gil/boost/gil/extension/io2/detail/extern_lib.hpp
   sandbox/gil/boost/gil/extension/io2/detail/wic_extern_lib_guard.hpp
   sandbox/gil/boost/gil/extension/io2/formatted_image.hpp
   sandbox/gil/boost/gil/extension/io2/libtiff_image.hpp
   sandbox/gil/boost/gil/extension/io2/libtiff_reader.hpp
   sandbox/gil/boost/gil/extension/io2/libtiff_writer.hpp
   sandbox/gil/boost/gil/extension/io2/reader.hpp
   sandbox/gil/boost/gil/extension/io2/wic_image.hpp
   sandbox/gil/boost/gil/extension/io2/wic_reader.hpp
   sandbox/gil/boost/gil/extension/io2/wic_writer.hpp
   sandbox/gil/boost/gil/extension/io2/writer.hpp
Text files modified:
   sandbox/gil/boost/gil/extension/io2/backends/detail/backend.hpp | 46 +++++++++++++----------------
   sandbox/gil/boost/gil/extension/io2/backends/detail/extern_lib_guard.hpp | 16 +++++-----
   sandbox/gil/boost/gil/extension/io2/backends/detail/reader.hpp | 50 ++++++++++++++++---------------
   sandbox/gil/boost/gil/extension/io2/backends/detail/reader_for.hpp | 25 +++++++--------
   sandbox/gil/boost/gil/extension/io2/backends/detail/writer.hpp | 24 ++++++++-------
   sandbox/gil/boost/gil/extension/io2/backends/detail/writer_for.hpp | 23 ++++++--------
   sandbox/gil/boost/gil/extension/io2/backends/libtiff/backend.hpp | 32 ++++++++++---------
   sandbox/gil/boost/gil/extension/io2/backends/libtiff/reader.hpp | 28 +++++++++--------
   sandbox/gil/boost/gil/extension/io2/backends/libtiff/writer.hpp | 62 +++++++++++++++++++++++----------------
   sandbox/gil/boost/gil/extension/io2/backends/wic/backend.hpp | 30 ++++++++++---------
   sandbox/gil/boost/gil/extension/io2/backends/wic/extern_lib_guard.hpp | 18 ++++++-----
   sandbox/gil/boost/gil/extension/io2/backends/wic/reader.hpp | 26 +++++++---------
   sandbox/gil/boost/gil/extension/io2/backends/wic/writer.hpp | 25 +++++++--------
   sandbox/gil/boost/gil/extension/io2/devices/device.hpp | 2
   sandbox/gil/boost/gil/extension/io2/dynamic_image.hpp | 6 +--
   sandbox/gil/boost/gil/extension/io2/format_tags.hpp | 2
   16 files changed, 213 insertions(+), 202 deletions(-)

Deleted: sandbox/gil/boost/gil/extension/io2/backend_reader.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/backend_reader.hpp 2011-07-27 18:18:58 EDT (Wed, 27 Jul 2011)
+++ (empty file)
@@ -1,729 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \file backend_reader.hpp
-/// ------------------------
-///
-/// Base CRTP class for backend readers.
-///
-/// Copyright (c) Domagoj Saric 2010.-2011.
-///
-/// Use, modification and distribution is subject to the Boost Software License, Version 1.0.
-/// (See accompanying file LICENSE_1_0.txt or copy at
-/// http://www.boost.org/LICENSE_1_0.txt)
-///
-/// For more information, see http://www.boost.org
-///
-////////////////////////////////////////////////////////////////////////////////
-//------------------------------------------------------------------------------
-#ifndef backend_reader_hpp__3E2ACB3B_F45F_404B_A603_0396518B183C
-#define backend_reader_hpp__3E2ACB3B_F45F_404B_A603_0396518B183C
-#pragma once
-//------------------------------------------------------------------------------
-#include "format_tags.hpp"
-#include "detail/platform_specifics.hpp"
-#include "detail/io_error.hpp"
-#include "detail/switch.hpp"
-
-#include "boost/gil/planar_pixel_iterator.hpp"
-#include "boost/gil/planar_pixel_reference.hpp"
-#include "boost/gil/typedefs.hpp"
-
-#include <boost/compressed_pair.hpp>
-#include <boost/mpl/for_each.hpp>
-#include <boost/mpl/size_t_fwd.hpp>
-#include <boost/static_assert.hpp>
-#include <boost/type_traits/decay.hpp>
-//------------------------------------------------------------------------------
-namespace boost
-{
-//------------------------------------------------------------------------------
-namespace gil
-{
-//------------------------------------------------------------------------------
-namespace io
-{
-//------------------------------------------------------------------------------
-
-struct assert_dimensions_match {};
-struct ensure_dimensions_match {};
-struct synchronize_dimensions {};
-
-struct assert_formats_match {};
-struct ensure_formats_match {};
-struct synchronize_formats {};
-
-
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \class offset_view_t
-/// \todo document properly...
-///
-////////////////////////////////////////////////////////////////////////////////
-
-template <class View, typename Offset>
-class offset_view_t
-{
-public:
- typedef View view_t ;
- typedef Offset offset_t;
-
-public:
- offset_view_t( View const & view, Offset const & offset ) : view_( view ), offset_( offset ) {}
-
- typename View::point_t dimensions() const
- {
- return offset_dimensions( original_view().dimensions(), offset() );
- }
-
- View const & original_view() const { return view_ ; }
- Offset const & offset () const { return offset_; }
-
-private:
- static typename View::point_t offset_dimensions
- (
- typename View::point_t view_dimensions,
- typename View::point_t::value_type const offset
- )
- {
- //return typename View::point_t( view_dimensions.x, view_dimensions.y + offset );
- view_dimensions.y += offset;
- return view_dimensions;
- }
-
- static typename View::point_t offset_dimensions
- (
- typename View::point_t view_dimensions,
- typename View::point_t const & offset
- )
- {
- return view_dimensions += offset;
- }
-
-private:
- View const & view_ ;
- Offset offset_;
-};
-
-
-////////////////////////////////////////////////////////////////////////////////
-/// \class formatted_image_traits
-/// ( forward declaration )
-////////////////////////////////////////////////////////////////////////////////
-
-template <class Impl>
-struct formatted_image_traits;
-
-namespace detail
-{
-//------------------------------------------------------------------------------
-
-template <class View, typename Offset>
-View const & original_view( offset_view_t<View, Offset> const & offset_view ) { return offset_view.original_view(); }
-
-template <class View>
-View const & original_view( View const & view ) { return view; }
-
-template <typename Offset, class View>
-Offset get_offset( View const & ) { return Offset(); }
-template <typename Offset, class View>
-Offset const & get_offset( offset_view_t<View, Offset> const & offset_view ) { return offset_view.offset(); }
-
-template <typename Offset>
-Offset get_offset_x( Offset const & ) { return Offset(); }
-template <typename Offset>
-Offset const & get_offset_x( point2<Offset> const & offset ) { return offset.x; }
-
-template <typename Offset>
-Offset get_offset_y( Offset const & offset ) { return offset; }
-template <typename Offset>
-Offset const & get_offset_y( point2<Offset> const & offset ) { return offset.y; }
-
-
-template <class NewView, class View, typename Offset>
-offset_view_t<NewView, Offset> offset_new_view( NewView const & new_view, offset_view_t<View, Offset> const & offset_view )
-{
- return offset_view_t<NewView, Offset>( new_view, offset_view.offset() );
-}
-
-template <class NewView, class View>
-NewView const & offset_new_view( NewView const & new_view, View const & ) { return new_view; }
-
-
-template <class View>
-struct is_offset_view : mpl::false_ {};
-
-template <class View, typename Offset>
-struct is_offset_view<offset_view_t<View, Offset> > : mpl::true_ {};
-
-
-template <typename View > struct get_original_view_t;
-template <typename Locator > struct get_original_view_t<image_view<Locator> > { typedef image_view<Locator> type; };
-template <typename View, typename Offset> struct get_original_view_t<offset_view_t<View, Offset> > { typedef View type; };
-
-class backend_reader_base
-{
-public:
- typedef point2<std::ptrdiff_t> dimensions_t;
-
- typedef unsigned int image_type_id;
- static image_type_id const unsupported_format = static_cast<image_type_id>( -1 );
-
-protected:
- static bool dimensions_mismatch( dimensions_t const & mine, dimensions_t const & other ) { return mine != other; }
- template <class View>
- static bool dimensions_mismatch( dimensions_t const & mine, View const & view ) { return dimensions_mismatch( mine, view.dimensions() ); }
-
- template <class View, typename Offset>
- static bool dimensions_mismatch( dimensions_t const & mine, offset_view_t<View, Offset> const & offset_view )
- {
- // Implementation note:
- // For offset target views all dimensions are allowed as they are
- // intended to load an image in steps so they must be allowed to be
- // smaller. They are also allowed to be bigger to allow GIL users to use
- // fixed 'sub' view, while loading an image in steps, whose size is not
- // an exact divisor of the source image dimensions.
- // The exception is for backends that support only vertical 'ROIs'/
- // offsets, for those the horizontal dimensions must match.
- // (19.09.2010.) (Domagoj Saric)
- //dimensions_t const other( offset_view.dimensions() );
- //return ( other.x < mine.x ) || ( other.y < mine.y );
- return is_pod<Offset>::value ? ( mine.x != offset_view.dimensions().x ) : false;
- }
-
- static void do_ensure_dimensions_match( dimensions_t const & mine, dimensions_t const & other )
- {
- io_error_if( dimensions_mismatch( mine, other ), "input view size does not match source image size" );
- }
-
- template <class View>
- static void do_ensure_dimensions_match( dimensions_t const & mine, View const & view )
- {
- do_ensure_dimensions_match( mine, view.dimensions() );
- }
-
- template <class View, typename Offset>
- static void do_ensure_dimensions_match( dimensions_t const & mine, offset_view_t<View, Offset> const & offset_view )
- {
- io_error_if( dimensions_mismatch( mine, offset_view ), "input view size does not match source image size" );
- }
-
- static void do_ensure_formats_match( bool const formats_mismatch )
- {
- io_error_if( formats_mismatch, "input view format does not match source image format" );
- }
-
- template <typename Image>
- static void do_synchronize_dimensions( Image & image, dimensions_t const & my_dimensions, unsigned int const alignment = 0 )
- {
- image.recreate( my_dimensions, alignment );
- }
-
-
- ////////////////////////////////////////////////////////////////////////////
- //
- // subview_for_offset()
- // --------------------
- //
- ////////////////////////////////////////////////////////////////////////////
- ///
- /// \brief Locally adjusts a view with a ROI/offset to prevent it exceeding
- /// the image dimensions when 'merged' with its offset. Done here so that
- /// backend classes do not need to handle this.
- /// \internal
- /// \throws nothing
- ///
- ////////////////////////////////////////////////////////////////////////////
-
- template <typename View>
- static View const & subview_for_offset( View const & view ) { return view; }
-
- template <typename View, typename Offset>
- static View subview_for_offset( dimensions_t const & my_dimensions, offset_view_t<View, Offset> const & offset_view )
- {
- dimensions_t const & target_dimensions( offset_view.original_view().dimensions() );
-
- bool const zero_x_offset( is_pod<Offset>::value );
- if ( zero_x_offset )
- {
- BOOST_ASSERT( get_offset_x( offset_view.offset() ) == 0 );
- BOOST_ASSERT( my_dimensions.x == target_dimensions.x );
- }
-
- unsigned int const width ( zero_x_offset ? target_dimensions.x : (std::min)( my_dimensions.x - get_offset_x( offset_view.offset() ), target_dimensions.x ) );
- unsigned int const height( (std::min)( my_dimensions.y - get_offset_y( offset_view.offset() ), target_dimensions.y ) );
-
- return subimage_view( offset_view.original_view(), 0, 0, width, height );
- }
-};
-
-
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \class backend_reader
-///
-////////////////////////////////////////////////////////////////////////////////
-
-template <class Backend>
-class backend_reader : public backend_reader_base
-{
-protected:
- template <class View>
- struct has_supported_format
- {
- private:
- typedef typename get_original_view_t<View>::type original_view_t;
-
- public:
- typedef typename formatted_image_traits<Backend>:: BOOST_NESTED_TEMPLATE is_supported
- <
- typename original_view_t::value_type,
- is_planar<original_view_t>::value
- > type;
- BOOST_STATIC_CONSTANT( bool, value = type::value );
- };
-
-protected:
- typedef typename formatted_image_traits<Backend>::format_t format_t;
- typedef typename formatted_image_traits<Backend>::view_data_t view_data_t;
-
-private:
- typedef mpl::range_c<std::size_t, 0, mpl::size<typename Backend::supported_pixel_formats>::value> valid_type_id_range_t;
-
- struct image_id_finder
- {
- image_id_finder( format_t const format ) : format_( format ), image_id_( unsupported_format ) {}
-
- template <typename ImageIndex>
- void operator()( ImageIndex )
- {
- typedef typename mpl::at<typename Backend::supported_pixel_formats, ImageIndex>::type pixel_format_t;
- format_t const image_format( typename Backend:: template get_native_format<pixel_format_t>::value );
- if ( image_format == this->format_ )
- {
- BOOST_ASSERT_MSG( image_id_ == unsupported_format, "Image ID already found." );
- image_id_ = ImageIndex::value;
- }
- }
-
- format_t const format_ ;
- unsigned int image_id_;
-
- private:
- void operator=( image_id_finder const & );
- };
-
-private:
- // MSVC++ (8,9,10) generates code to check whether this == 0.
- typedef typename Backend::native_reader Impl;
- Impl & impl() { BF_ASSUME( this != 0 ); return static_cast<Impl &>( *this ); }
- Impl const & impl() const { BF_ASSUME( this != 0 ); return static_cast<Impl const &>( *this ); }
-
-protected:
- template <typename View>
- bool dimensions_mismatch( View const & view ) const
- {
- return formatted_image_base::dimensions_mismatch( impl().dimensions(), view );
- }
-
- bool dimensions_mismatch( dimensions_t const & other_dimensions ) const
- {
- return formatted_image_base::dimensions_mismatch( impl().dimensions(), other_dimensions );
- }
-
- template <class View>
- void do_ensure_dimensions_match( View const & view ) const
- {
- formatted_image_base::do_ensure_dimensions_match( impl().dimensions(), view );
- }
-
- template <typename View>
- bool formats_mismatch() const
- {
- return formats_mismatch( get_native_format<typename get_original_view_t<View>::type>::value );
- }
-
- bool formats_mismatch( format_t const other_format ) const
- {
- return ( other_format != impl().closest_gil_supported_format() ) != false;
- }
-
- template <class View>
- void do_ensure_formats_match() const { formatted_image_base::do_ensure_formats_match( formats_mismatch<View>() ); }
-
- template <typename View>
- bool can_do_inplace_transform() const
- {
- return can_do_inplace_transform<View>( impl().format() );
- }
-
- template <typename View>
- bool can_do_inplace_transform( format_t const my_format ) const
- {
- return ( impl().cached_format_size( my_format ) == static_cast<std::size_t>( memunit_step( get_original_view_t<View>::type::x_iterator() ) ) );
- }
-
- template <typename View>
- static View const & subview_for_offset( View const & view ) { return view; }
-
- template <typename View, typename Offset>
- View subview_for_offset( offset_view_t<View, Offset> const & offset_view ) const
- {
- return formatted_image_base::subview_for_offset( impl().dimensions(), offset_view );
- }
-
- template <typename View>
- static view_data_t get_view_data( View const & view )
- {
- return view_data_t( view );
- }
-
- template <typename View>
- view_data_t get_view_data( offset_view_t<View, typename Backend::offset_t> const & offset_view ) const
- {
- return view_data_t
- (
- subview_for_offset( offset_view ),
- offset_view.offset()
- );
- }
-
-public: // Low-level (row, strip, tile) access
- // Generic implementations: impl classes are encouraged to provide more
- // efficient overrides.
-
- std::size_t pixel_size() const
- {
- return impl().cached_format_size( impl().format() );
- }
-
- std::size_t row_size() const
- {
- return impl().pixel_size() * impl().dimensions().x;
- }
-
- static image_type_id image_format_id( format_t const closest_gil_supported_format )
- {
- // This (linear search) will be transformed into a switch...
- image_id_finder finder( closest_gil_supported_format );
- mpl::for_each<valid_type_id_range_t>( ref( finder ) );
- BOOST_ASSERT( finder.image_id_ != unsupported_format );
- return finder.image_id_;
- }
-
-public: // Views...
- template <typename View>
- void copy_to( View const & view, assert_dimensions_match, assert_formats_match ) const
- {
- BOOST_STATIC_ASSERT( get_original_view_t<View>::type::value_type::is_mutable );
- BOOST_STATIC_ASSERT( has_supported_format<View>::value );
- BOOST_ASSERT( !impl().dimensions_mismatch( view ) );
- BOOST_ASSERT( !impl().formats_mismatch<View>() );
- impl().raw_copy_to_prepared_view( get_view_data( view ) );
- }
-
- template <typename View>
- void copy_to( View const & view, assert_dimensions_match, ensure_formats_match ) const
- {
- impl().do_ensure_formats_match<View>();
- impl().copy_to( view, assert_dimensions_match(), assert_formats_match() );
- }
-
- template <typename View>
- void copy_to( View const & view, ensure_dimensions_match, assert_formats_match ) const
- {
- impl().do_ensure_dimensions_match( view );
- impl().copy_to( view, assert_dimensions_match(), assert_formats_match() );
- }
-
- template <typename View>
- void copy_to( View const & view, ensure_dimensions_match, ensure_formats_match ) const
- {
- impl().do_ensure_dimensions_match( view );
- impl().copy_to( view, assert_dimensions_match(), ensure_formats_match() );
- }
-
- template <typename View>
- void copy_to( View const & view, ensure_dimensions_match, synchronize_formats ) const
- {
- impl().do_ensure_dimensions_match( view );
- impl().copy_to( view, assert_dimensions_match(), synchronize_formats() );
- }
-
- template <typename View>
- void copy_to( View const & view, assert_dimensions_match, synchronize_formats ) const
- {
- BOOST_ASSERT( !impl().dimensions_mismatch( view ) );
- typedef mpl::bool_
- <
- has_supported_format <View >::value &&
- formatted_image_traits<Backend>::builtin_conversion
- > can_use_raw_t;
- default_convert_to_worker( view, can_use_raw_t() );
- }
-
- template <typename FormatConverter, typename View>
- void copy_to( View const & view, ensure_dimensions_match, FormatConverter & format_converter ) const
- {
- impl().do_ensure_dimensions_match( view );
- impl().copy_to( view, assert_dimensions_match(), format_converter );
- }
-
- template <typename FormatConverter, typename View>
- void copy_to( View const & view, assert_dimensions_match, FormatConverter & format_converter ) const
- {
- BOOST_ASSERT( !impl().dimensions_mismatch( view ) );
- impl().convert_to_prepared_view( view, format_converter );
- }
-
-public: // Images...
- template <typename Image, typename FormatsPolicy>
- Image copy_to_image( FormatsPolicy const formats_policy ) const
- {
- Image image( impl().dimensions(), formatted_image_traits<Backend>::desired_alignment );
- impl().copy_to( view( image ), assert_dimensions_match(), formats_policy );
- return image;
- }
-
- template <typename Image, typename DimensionsPolicy, typename FormatsPolicy>
- void copy_to_image( Image & image, DimensionsPolicy const dimensions_policy, FormatsPolicy const formats_policy ) const
- {
- impl().copy_to( view( image ), dimensions_policy, formats_policy );
- }
-
- template <typename Image, typename FormatsPolicy>
- void copy_to_image( Image & image, synchronize_dimensions, FormatsPolicy const formats_policy ) const
- {
- impl().do_synchronize_dimensions( image, impl().dimensions(), formatted_image_traits<Backend>::desired_alignment );
- impl().copy_to( view( image ), assert_dimensions_match(), formats_policy );
- }
-
-public: // Offset factory
- template <class View>
- static
- offset_view_t<View, typename Backend::offset_t>
- offset_view( View const & view, typename Backend::offset_t const offset )
- {
- return offset_view_t<View, offset_t>( view, offset );
- }
-
-public: // Utility 'quick-wrappers'...
- template <class Source, class Image>
- static void read( Source const & target, Image & image )
- {
- typedef typename reader_for<typename decay<Source>::type>::type reader_t;
- // The backend does not know how to read from the specified source type.
- BOOST_STATIC_ASSERT(( !is_same<reader_t, mpl::void_>::value ));
- reader_t( target ).copy_to_image( image, synchronize_dimensions(), synchronize_formats() );
- }
-
- template <typename char_type, class View>
- static void read( std::basic_string<char_type> const & file_name, View const & view )
- {
- read( file_name.c_str(), view );
- }
-
- template <typename char_type, class View>
- static void read( std::basic_string<char_type> & file_name, View const & view )
- {
- read( file_name.c_str(), view );
- }
-
-private:
- template <class View, typename CC>
- class in_place_converter_t
- {
- public:
- typedef void result_type;
-
- in_place_converter_t( CC const & cc, View const & view ) : members_( cc, view ) {}
-
- template <std::size_t index>
- void operator()( mpl::size_t<index> ) const
- {
- typedef typename mpl::at_c<supported_pixel_formats, index>::type::view_t view_t;
- BOOST_ASSERT( is_planar<View>::value == is_planar<view_t>::value ); //zzz...make this a static assert...
- if ( is_planar<View>::value )
- {
- for ( unsigned int plane( 0 ); plane < num_channels<View>::value; ++plane )
- {
- BOOST_ASSERT( sizeof( view_t ) == sizeof( View ) ); //zzz...make this a static assert...
- for_each_pixel( nth_channel_view( *gil_reinterpret_cast_c<view_t const *>( &view() ), plane ), *this );
- }
- }
- else
- {
- BOOST_ASSERT( sizeof( view_t ) == sizeof( View ) ); //zzz...make this a static assert...
- for_each_pixel( *gil_reinterpret_cast_c<view_t const *>( &view() ), *this );
- }
- }
-
- template <typename SrcP>
- typename enable_if<is_pixel<SrcP> >::type
- operator()( SrcP & srcP )
- {
- convert_aux( srcP, is_planar<View>() );
- }
-
- void operator=( in_place_converter_t const & other )
- {
- BOOST_ASSERT( this->view() == other.view() );
- this->cc() = other.cc();
- }
-
- private:
- CC & cc () { return members_.first (); }
- CC const & cc () const { return members_.first (); }
- View const & view() const { return members_.second(); }
-
- template <typename SrcP>
- void convert_aux( SrcP & srcP, mpl::true_ /*is planar*/ )
- {
- typedef typename nth_channel_view_type<View>::type::value_type DstP;
- BOOST_ASSERT( sizeof( SrcP ) == sizeof( DstP ) ); //zzz...make this a static assert...
- cc()( srcP, *const_cast<DstP *>( gil_reinterpret_cast_c<DstP const *>( &srcP ) ) );
- }
-
- template <typename SrcP>
- void convert_aux( SrcP & srcP, mpl::false_ /*is not planar*/ )
- {
- typedef typename View::value_type DstP;
- BOOST_ASSERT( sizeof( SrcP ) == sizeof( DstP ) ); //zzz...make this a static assert...
- cc()( srcP, *const_cast<DstP *>( gil_reinterpret_cast_c<DstP const *>( &srcP ) ) );
- }
-
- private:
- compressed_pair<CC, View const &> members_;
- };
-
- template <class View, typename CC>
- class generic_converter_t
- {
- public:
- typedef void result_type;
-
- generic_converter_t( Impl const & impl, CC const & cc, View const & view )
- : impl_( impl ), cc_view_( cc, view ) {}
-
- template <std::size_t index>
- void operator()( mpl::size_t<index> ) const
- {
- typedef typename mpl::at_c<supported_pixel_formats, index>::type::view_t my_view_t;
- impl_. BOOST_NESTED_TEMPLATE generic_convert_to_prepared_view<my_view_t>( view(), cc() );
- }
-
- void operator=( generic_converter_t const & other )
- {
- BOOST_ASSERT( this->impl_ == other.impl_ );
- BOOST_ASSERT( this->view_ == other.view_ );
- this->cc() = other.cc();
- }
-
- private:
- CC & cc () { return cc_view_.first (); }
- CC const & cc () const { return cc_view_.first (); }
- View const & view() const { return cc_view_.second(); }
-
- private:
- Impl const & impl_ ;
- compressed_pair<CC, View const &> cc_view_;
- };
-
- template <class TargetView, class CC>
- static void in_place_transform( unsigned int const source_view_type_id, TargetView const & view, CC const & cc )
- {
- return switch_<valid_type_id_range_t>
- (
- source_view_type_id,
- in_place_converter_t<TargetView, CC>( cc, view ),
- assert_default_case_not_reached<void>()
- );
- }
-
- template <class TargetView, class CC>
- void generic_transform( unsigned int const source_view_type_id, TargetView const & view, CC const & cc ) const
- {
- return switch_<valid_type_id_range_t>
- (
- source_view_type_id,
- generic_converter_t<TargetView, CC>
- (
- impl(),
- cc,
- offset_new_view
- (
- // See the note for formatted_image_base::subview_for_offset()...
- subview_for_offset( view ),
- view
- )
- ),
- assert_default_case_not_reached<void>()
- );
- }
-
- template <typename View, typename CC>
- void convert_to_prepared_view( View const & view, CC const & converter ) const
- {
- BOOST_ASSERT( !dimensions_mismatch( view ) );
- convert_to_prepared_view_worker
- (
- view,
- converter,
- mpl::bool_
- <
- is_plain_in_memory_view<typename get_original_view_t<View>::type>::value &&
- has_supported_format < View >::value
- >()
- );
- }
-
- template <typename View, typename CC>
- void convert_to_prepared_view_worker( View const & view, CC const & converter, mpl::true_ /*can use raw*/ ) const
- {
- format_t const current_format ( impl().closest_gil_supported_format() );
- unsigned int const current_image_format_id( impl().image_format_id( current_format ) );
- if ( can_do_inplace_transform<View>( current_format ) )
- {
- view_data_t view_data( get_view_data( view ) );
- if ( formatted_image_traits<Backend>::builtin_conversion )
- view_data.set_format( current_format );
- else
- BOOST_ASSERT( current_format == impl().format() );
- impl().raw_copy_to_prepared_view( view_data );
- in_place_transform( current_image_format_id, original_view( view ), converter );
- }
- else
- {
- generic_transform( current_image_format_id, view, converter );
- }
- }
-
- template <typename View, typename CC>
- void convert_to_prepared_view_worker( View const & view, CC const & converter, mpl::false_ /*must use generic*/ ) const
- {
- generic_transform( Impl::image_format_id( impl().closest_gil_supported_format() ), view, converter );
- }
-
- template <typename View>
- void default_convert_to_worker( View const & view, mpl::true_ /*can use raw*/ ) const
- {
- impl().raw_convert_to_prepared_view( get_view_data( view ) );
- }
-
- template <typename View>
- void default_convert_to_worker( View const & view, mpl::false_ /*cannot use raw*/ ) const
- {
- impl().convert_to_prepared_view( view, default_color_converter() );
- }
-};
-
-
-//------------------------------------------------------------------------------
-} // namespace detail
-//------------------------------------------------------------------------------
-} // namespace io
-//------------------------------------------------------------------------------
-} // namespace gil
-//------------------------------------------------------------------------------
-} // namespace boost
-//------------------------------------------------------------------------------
-#endif // backend_reader_hpp

Deleted: sandbox/gil/boost/gil/extension/io2/backend_writer.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/backend_writer.hpp 2011-07-27 18:18:58 EDT (Wed, 27 Jul 2011)
+++ (empty file)
@@ -1,113 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \file backend_writer.hpp
-/// ------------------------
-///
-/// Base CRTP class for backend writers.
-///
-/// Copyright (c) Domagoj Saric 2010.-2011.
-///
-/// Use, modification and distribution is subject to the Boost Software License, Version 1.0.
-/// (See accompanying file LICENSE_1_0.txt or copy at
-/// http://www.boost.org/LICENSE_1_0.txt)
-///
-/// For more information, see http://www.boost.org
-///
-////////////////////////////////////////////////////////////////////////////////
-//------------------------------------------------------------------------------
-#ifndef backend_writer_hpp__D65DA8BE_0605_4A62_AC73_B557F7A94DA6
-#define backend_writer_hpp__D65DA8BE_0605_4A62_AC73_B557F7A94DA6
-#pragma once
-//------------------------------------------------------------------------------
-#include "format_tags.hpp"
-#include "detail/platform_specifics.hpp"
-#include "detail/io_error.hpp"
-
-#include "boost/gil/typedefs.hpp"
-
-#include "boost/static_assert.hpp"
-#include "boost/type_traits/is_same.hpp"
-//------------------------------------------------------------------------------
-namespace boost
-{
-//------------------------------------------------------------------------------
-namespace gil
-{
-//------------------------------------------------------------------------------
-namespace io
-{
-//------------------------------------------------------------------------------
-
-////////////////////////////////////////////////////////////////////////////////
-/// \class formatted_image_traits
-/// ( forward declaration )
-////////////////////////////////////////////////////////////////////////////////
-
-template <class Impl>
-struct formatted_image_traits;
-
-
-namespace detail
-{
-//------------------------------------------------------------------------------
-
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \class backend_writer
-///
-////////////////////////////////////////////////////////////////////////////////
-
-template <class Backend>
-class backend_writer
-{
-protected:
- typedef typename formatted_image_traits<Backend>::view_data_t view_data_t;
-
-private:
- // MSVC++ (8,9,10) generates code to check whether this == 0.
- typedef typename Backend::native_writer Impl;
- Impl & impl() { BF_ASSUME( this != 0 ); return static_cast<Impl &>( *this ); }
- Impl const & impl() const { BF_ASSUME( this != 0 ); return static_cast<Impl const &>( *this ); }
-
-public: // Utility 'quick-wrappers'...
- template <class Target, class View>
- static void write( Target & target, View const & view )
- {
- typedef typename writer_for<Target>::type writer_t;
- // The backend does not know how to write to the specified target type.
- BOOST_STATIC_ASSERT(( !is_same<writer_t, mpl::void_>::value ));
- writer_t( target, view ).write_default();
- }
-
- template <class Target, class View>
- static void write( Target * p_target, View const & view )
- {
- typedef typename writer_for<Target const *>::type writer_t;
- // The backend does not know how to write to the specified target type.
- BOOST_STATIC_ASSERT(( !is_same<writer_t, mpl::void_>::value ));
- writer_t( p_target, view ).write_default();
- }
-
- template <typename char_type, class View>
- static void write( std::basic_string<char_type> const & file_name, View const & view )
- {
- write( file_name.c_str(), view );
- }
-
- template <typename char_type, class View>
- static void write( std::basic_string<char_type> & file_name, View const & view )
- {
- write( file_name.c_str(), view );
- }
-};
-
-//------------------------------------------------------------------------------
-} // namespace detail
-//------------------------------------------------------------------------------
-} // namespace io
-//------------------------------------------------------------------------------
-} // namespace gil
-//------------------------------------------------------------------------------
-} // namespace boost
-//------------------------------------------------------------------------------
-#endif // backend_writer_hpp

Copied: sandbox/gil/boost/gil/extension/io2/backends/detail/backend.hpp (from r73403, /sandbox/gil/boost/gil/extension/io2/formatted_image.hpp)
==============================================================================
--- /sandbox/gil/boost/gil/extension/io2/formatted_image.hpp (original)
+++ sandbox/gil/boost/gil/extension/io2/backends/detail/backend.hpp 2011-07-27 18:18:58 EDT (Wed, 27 Jul 2011)
@@ -1,7 +1,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \file formatted_image.hpp
-/// -------------------------
+/// \file backend.hpp
+/// -----------------
 ///
 /// Base CRTP class for all image implementation classes/backends.
 ///
@@ -15,24 +15,20 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 //------------------------------------------------------------------------------
-#ifndef formatted_image_hpp__C34C1FB0_A4F5_42F3_9318_5805B88CFE49
-#define formatted_image_hpp__C34C1FB0_A4F5_42F3_9318_5805B88CFE49
+#ifndef backend_hpp__C34C1FB0_A4F5_42F3_9318_5805B88CFE49
+#define backend_hpp__C34C1FB0_A4F5_42F3_9318_5805B88CFE49
 #pragma once
 //------------------------------------------------------------------------------
-#include "format_tags.hpp"
-#include "detail/platform_specifics.hpp"
-#include "detail/io_error.hpp"
-#include "detail/switch.hpp"
+#include "boost/gil/extension/io2/format_tags.hpp"
+#include "boost/gil/extension/io2/detail/platform_specifics.hpp"
+#include "boost/gil/extension/io2/detail/io_error.hpp"
+#include "boost/gil/extension/io2/detail/switch.hpp"
 
 #include "boost/gil/packed_pixel.hpp"
 #include "boost/gil/planar_pixel_iterator.hpp"
 #include "boost/gil/planar_pixel_reference.hpp"
 #include "boost/gil/typedefs.hpp"
 
-#include <boost/compressed_pair.hpp>
-#ifdef _DEBUG
-#include <boost/detail/endian.hpp>
-#endif // _DEBUG
 #include <boost/mpl/eval_if.hpp>
 #include <boost/mpl/for_each.hpp>
 #include <boost/mpl/integral_c.hpp>
@@ -112,12 +108,12 @@
 //------------------------------------------------------------------------------
 
 ////////////////////////////////////////////////////////////////////////////////
-/// \class formatted_image_traits
+/// \class backend_traits
 /// ( forward declaration )
 ////////////////////////////////////////////////////////////////////////////////
 
 template <class Impl>
-struct formatted_image_traits;
+struct backend_traits;
 
 template <class Backend, typename Source>
 struct reader_for;
@@ -131,11 +127,11 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \class formatted_image_base
+/// \class backend_base
 ///
 ////////////////////////////////////////////////////////////////////////////////
 
-class formatted_image_base : noncopyable
+class backend_base : noncopyable
 {
 public: // Low-level (row, strip, tile) access
     struct sequential_row_read_state { BOOST_STATIC_CONSTANT( bool, throws_on_error = true ); };
@@ -188,23 +184,23 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \class formatted_image
+/// \class backend
 ///
 ////////////////////////////////////////////////////////////////////////////////
 
 template <class Impl>
-class formatted_image : public formatted_image_base
+class backend : public backend_base
 {
 public:
- //typedef typename formatted_image_traits<Impl>::format_t format_t;
+ //typedef typename backend_traits<Impl>::format_t format_t;
 
- typedef typename formatted_image_traits<Impl>::supported_pixel_formats_t supported_pixel_formats;
- typedef typename formatted_image_traits<Impl>::roi_t roi;
+ typedef typename backend_traits<Impl>::supported_pixel_formats_t supported_pixel_formats;
+ typedef typename backend_traits<Impl>::roi_t roi;
     typedef typename roi::offset_t offset_t;
 
     template <typename PixelType, bool IsPlanar>
     struct native_format
- : formatted_image_traits<Impl>::gil_to_native_format:: BOOST_NESTED_TEMPLATE apply<PixelType, IsPlanar>::type
+ : backend_traits<Impl>::gil_to_native_format:: BOOST_NESTED_TEMPLATE apply<PixelType, IsPlanar>::type
     {};
 
     template <typename T> struct get_native_format;
@@ -224,9 +220,9 @@
     BOOST_STATIC_CONSTANT( bool, has_full_roi = (is_same<typename roi::offset_t, typename roi::point_t>::value) );
 
 protected:
- typedef formatted_image base_t;
+ typedef backend base_t;
 
- //typedef typename formatted_image_traits<Impl>::view_data_t view_data_t;
+ //typedef typename backend_traits<Impl>::view_data_t view_data_t;
 
 private:
     // MSVC++ 10 generates code to check whether this == 0.
@@ -244,4 +240,4 @@
 //------------------------------------------------------------------------------
 } // namespace boost
 //------------------------------------------------------------------------------
-#endif // formatted_image_hpp
+#endif // backend_hpp

Copied: sandbox/gil/boost/gil/extension/io2/backends/detail/extern_lib_guard.hpp (from r73384, /sandbox/gil/boost/gil/extension/io2/detail/extern_lib.hpp)
==============================================================================
--- /sandbox/gil/boost/gil/extension/io2/detail/extern_lib.hpp (original)
+++ sandbox/gil/boost/gil/extension/io2/backends/detail/extern_lib_guard.hpp 2011-07-27 18:18:58 EDT (Wed, 27 Jul 2011)
@@ -133,9 +133,9 @@
         if ( !delayed_lib_.is_initialized() )
             delayed_lib_ = in_place( lib_name );
         else
- BOOST_ASSERT
+ BOOST_ASSERT_MSG
             (
- ( delayed_lib_->lib_handle() == win32_preloaded_reloadable_lib( lib_name ).lib_handle() ) &&
+ ( delayed_lib_->lib_handle() == win32_preloaded_reloadable_lib( lib_name ).lib_handle() ),
                 "Library reloaded/relocated!"
             );
     }
@@ -145,9 +145,9 @@
         if ( !delayed_lib_.is_initialized() )
             delayed_lib_ = in_place( lib_name );
         else
- BOOST_ASSERT
+ BOOST_ASSERT_MSG
             (
- ( delayed_lib_->lib_handle() == win32_preloaded_reloadable_lib( lib_name ).lib_handle() ) &&
+ ( delayed_lib_->lib_handle() == win32_preloaded_reloadable_lib( lib_name ).lib_handle() ),
                 "Library reloaded/relocated!"
             );
     }
@@ -193,9 +193,9 @@
         if ( !delayed_lib_.is_initialized() )
             delayed_lib_ = in_place( lib_name );
         else
- BOOST_ASSERT
+ BOOST_ASSERT_MSG
             (
- ( delayed_lib_->lib_handle() == win32_reloadable_lib_guard( lib_name ).lib_handle() ) &&
+ ( delayed_lib_->lib_handle() == win32_reloadable_lib_guard( lib_name ).lib_handle() ),
                 "Library reloaded/relocated!"
             );
     }
@@ -205,9 +205,9 @@
         if ( !delayed_lib_.is_initialized() )
             delayed_lib_ = in_place( lib_name );
         else
- BOOST_ASSERT
+ BOOST_ASSERT_MSG
             (
- ( delayed_lib_->lib_handle() == win32_reloadable_lib_guard( lib_name ).lib_handle() ) &&
+ ( delayed_lib_->lib_handle() == win32_reloadable_lib_guard( lib_name ).lib_handle() ),
                 "Library reloaded/relocated!"
             );
     }

Copied: sandbox/gil/boost/gil/extension/io2/backends/detail/reader.hpp (from r73403, /sandbox/gil/boost/gil/extension/io2/backend_reader.hpp)
==============================================================================
--- /sandbox/gil/boost/gil/extension/io2/backend_reader.hpp (original)
+++ sandbox/gil/boost/gil/extension/io2/backends/detail/reader.hpp 2011-07-27 18:18:58 EDT (Wed, 27 Jul 2011)
@@ -1,7 +1,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \file backend_reader.hpp
-/// ------------------------
+/// \file reader.hpp
+/// ----------------
 ///
 /// Base CRTP class for backend readers.
 ///
@@ -15,14 +15,16 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 //------------------------------------------------------------------------------
-#ifndef backend_reader_hpp__3E2ACB3B_F45F_404B_A603_0396518B183C
-#define backend_reader_hpp__3E2ACB3B_F45F_404B_A603_0396518B183C
+#ifndef reader_hpp__3E2ACB3B_F45F_404B_A603_0396518B183C
+#define reader_hpp__3E2ACB3B_F45F_404B_A603_0396518B183C
 #pragma once
 //------------------------------------------------------------------------------
-#include "format_tags.hpp"
-#include "detail/platform_specifics.hpp"
-#include "detail/io_error.hpp"
-#include "detail/switch.hpp"
+#include "reader_for.hpp"
+
+#include "boost/gil/extension/io2/format_tags.hpp"
+#include "boost/gil/extension/io2/detail/platform_specifics.hpp"
+#include "boost/gil/extension/io2/detail/io_error.hpp"
+#include "boost/gil/extension/io2/detail/switch.hpp"
 
 #include "boost/gil/planar_pixel_iterator.hpp"
 #include "boost/gil/planar_pixel_reference.hpp"
@@ -106,12 +108,12 @@
 
 
 ////////////////////////////////////////////////////////////////////////////////
-/// \class formatted_image_traits
+/// \class backend_traits
 /// ( forward declaration )
 ////////////////////////////////////////////////////////////////////////////////
 
 template <class Impl>
-struct formatted_image_traits;
+struct backend_traits;
 
 namespace detail
 {
@@ -274,7 +276,7 @@
         typedef typename get_original_view_t<View>::type original_view_t;
 
     public:
- typedef typename formatted_image_traits<Backend>:: BOOST_NESTED_TEMPLATE is_supported
+ typedef typename backend_traits<Backend>:: BOOST_NESTED_TEMPLATE is_supported
         <
             typename original_view_t::value_type,
             is_planar<original_view_t>::value
@@ -283,8 +285,8 @@
     };
 
 protected:
- typedef typename formatted_image_traits<Backend>::format_t format_t;
- typedef typename formatted_image_traits<Backend>::view_data_t view_data_t;
+ typedef typename backend_traits<Backend>::format_t format_t;
+ typedef typename backend_traits<Backend>::view_data_t view_data_t;
 
 private:
     typedef mpl::range_c<std::size_t, 0, mpl::size<typename Backend::supported_pixel_formats>::value> valid_type_id_range_t;
@@ -322,18 +324,18 @@
     template <typename View>
     bool dimensions_mismatch( View const & view ) const
     {
- return formatted_image_base::dimensions_mismatch( impl().dimensions(), view );
+ return backend_base::dimensions_mismatch( impl().dimensions(), view );
     }
 
     bool dimensions_mismatch( dimensions_t const & other_dimensions ) const
     {
- return formatted_image_base::dimensions_mismatch( impl().dimensions(), other_dimensions );
+ return backend_base::dimensions_mismatch( impl().dimensions(), other_dimensions );
     }
 
     template <class View>
     void do_ensure_dimensions_match( View const & view ) const
     {
- formatted_image_base::do_ensure_dimensions_match( impl().dimensions(), view );
+ backend_base::do_ensure_dimensions_match( impl().dimensions(), view );
     }
 
     template <typename View>
@@ -348,7 +350,7 @@
     }
 
     template <class View>
- void do_ensure_formats_match() const { formatted_image_base::do_ensure_formats_match( formats_mismatch<View>() ); }
+ void do_ensure_formats_match() const { backend_base::do_ensure_formats_match( formats_mismatch<View>() ); }
 
     template <typename View>
     bool can_do_inplace_transform() const
@@ -368,7 +370,7 @@
     template <typename View, typename Offset>
     View subview_for_offset( offset_view_t<View, Offset> const & offset_view ) const
     {
- return formatted_image_base::subview_for_offset( impl().dimensions(), offset_view );
+ return backend_base::subview_for_offset( impl().dimensions(), offset_view );
     }
 
     template <typename View>
@@ -456,7 +458,7 @@
         typedef mpl::bool_
         <
             has_supported_format <View >::value &&
- formatted_image_traits<Backend>::builtin_conversion
+ backend_traits<Backend>::builtin_conversion
> can_use_raw_t;
         default_convert_to_worker( view, can_use_raw_t() );
     }
@@ -479,7 +481,7 @@
     template <typename Image, typename FormatsPolicy>
     Image copy_to_image( FormatsPolicy const formats_policy ) const
     {
- Image image( impl().dimensions(), formatted_image_traits<Backend>::desired_alignment );
+ Image image( impl().dimensions(), backend_traits<Backend>::desired_alignment );
         impl().copy_to( view( image ), assert_dimensions_match(), formats_policy );
         return image;
     }
@@ -493,7 +495,7 @@
     template <typename Image, typename FormatsPolicy>
     void copy_to_image( Image & image, synchronize_dimensions, FormatsPolicy const formats_policy ) const
     {
- impl().do_synchronize_dimensions( image, impl().dimensions(), formatted_image_traits<Backend>::desired_alignment );
+ impl().do_synchronize_dimensions( image, impl().dimensions(), backend_traits<Backend>::desired_alignment );
         impl().copy_to( view( image ), assert_dimensions_match(), formats_policy );
     }
 
@@ -651,7 +653,7 @@
                 cc,
                 offset_new_view
                 (
- // See the note for formatted_image_base::subview_for_offset()...
+ // See the note for backend_base::subview_for_offset()...
                     subview_for_offset( view ),
                     view
                 )
@@ -684,7 +686,7 @@
         if ( can_do_inplace_transform<View>( current_format ) )
         {
             view_data_t view_data( get_view_data( view ) );
- if ( formatted_image_traits<Backend>::builtin_conversion )
+ if ( backend_traits<Backend>::builtin_conversion )
                 view_data.set_format( current_format );
             else
                 BOOST_ASSERT( current_format == impl().format() );
@@ -726,4 +728,4 @@
 //------------------------------------------------------------------------------
 } // namespace boost
 //------------------------------------------------------------------------------
-#endif // backend_reader_hpp
+#endif // reader_hpp

Copied: sandbox/gil/boost/gil/extension/io2/backends/detail/reader_for.hpp (from r73403, /sandbox/gil/boost/gil/extension/io2/reader.hpp)
==============================================================================
--- /sandbox/gil/boost/gil/extension/io2/reader.hpp (original)
+++ sandbox/gil/boost/gil/extension/io2/backends/detail/reader_for.hpp 2011-07-27 18:18:58 EDT (Wed, 27 Jul 2011)
@@ -1,9 +1,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \file formatted_image.hpp
-/// -------------------------
-///
-/// Base CRTP class for all image implementation classes/backends.
+/// \file reader_for.hpp
+/// --------------------
 ///
 /// Copyright (c) Domagoj Saric 2010.-2011.
 ///
@@ -15,13 +13,14 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 //------------------------------------------------------------------------------
-#ifndef reader_hpp__1733426F_1D8C_4F4E_A966_BDB6426AA88C
-#define reader_hpp__1733426F_1D8C_4F4E_A966_BDB6426AA88C
+#ifndef reader_for_hpp__1733426F_1D8C_4F4E_A966_BDB6426AA88C
+#define reader_for_hpp__1733426F_1D8C_4F4E_A966_BDB6426AA88C
 #pragma once
 //------------------------------------------------------------------------------
-#include "format_tags.hpp"
-#include "detail/platform_specifics.hpp"
-#include "detail/io_error.hpp"
+#include "boost/gil/extension/io2/format_tags.hpp"
+#include "boost/gil/extension/io2/devices/device.hpp"
+#include "boost/gil/extension/io2/detail/platform_specifics.hpp"
+#include "boost/gil/extension/io2/detail/io_error.hpp"
 
 #include "boost/gil/typedefs.hpp"
 
@@ -56,18 +55,18 @@
 
 
 ////////////////////////////////////////////////////////////////////////////////
-/// \class formatted_image_traits
+/// \class backend_traits
 /// ( forward declaration )
 ////////////////////////////////////////////////////////////////////////////////
 
 template <class Impl>
-struct formatted_image_traits;
+struct backend_traits;
 
 
 template <class Backend, typename Source>
 struct reader_for
 {
- typedef typename mpl::has_key<typename formatted_image_traits<Backend>::native_sources, Source>::type supported_by_native_reader_t;
+ typedef typename mpl::has_key<typename backend_traits<Backend>::native_sources, Source>::type supported_by_native_reader_t;
 
     // The backend does not seem to provide a reader for the specified target...
     BOOST_STATIC_ASSERT
@@ -95,4 +94,4 @@
 //------------------------------------------------------------------------------
 } // namespace boost
 //------------------------------------------------------------------------------
-#endif // reader_hpp
+#endif // reader_for_hpp

Copied: sandbox/gil/boost/gil/extension/io2/backends/detail/writer.hpp (from r73403, /sandbox/gil/boost/gil/extension/io2/backend_writer.hpp)
==============================================================================
--- /sandbox/gil/boost/gil/extension/io2/backend_writer.hpp (original)
+++ sandbox/gil/boost/gil/extension/io2/backends/detail/writer.hpp 2011-07-27 18:18:58 EDT (Wed, 27 Jul 2011)
@@ -1,7 +1,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \file backend_writer.hpp
-/// ------------------------
+/// \file writer.hpp
+/// ----------------
 ///
 /// Base CRTP class for backend writers.
 ///
@@ -15,13 +15,15 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 //------------------------------------------------------------------------------
-#ifndef backend_writer_hpp__D65DA8BE_0605_4A62_AC73_B557F7A94DA6
-#define backend_writer_hpp__D65DA8BE_0605_4A62_AC73_B557F7A94DA6
+#ifndef writer_hpp__D65DA8BE_0605_4A62_AC73_B557F7A94DA6
+#define writer_hpp__D65DA8BE_0605_4A62_AC73_B557F7A94DA6
 #pragma once
 //------------------------------------------------------------------------------
-#include "format_tags.hpp"
-#include "detail/platform_specifics.hpp"
-#include "detail/io_error.hpp"
+#include "writer_for.hpp"
+
+#include "boost/gil/extension/io2/format_tags.hpp"
+#include "boost/gil/extension/io2/detail/io_error.hpp"
+#include "boost/gil/extension/io2/detail/platform_specifics.hpp"
 
 #include "boost/gil/typedefs.hpp"
 
@@ -39,12 +41,12 @@
 //------------------------------------------------------------------------------
 
 ////////////////////////////////////////////////////////////////////////////////
-/// \class formatted_image_traits
+/// \class backend_traits
 /// ( forward declaration )
 ////////////////////////////////////////////////////////////////////////////////
 
 template <class Impl>
-struct formatted_image_traits;
+struct backend_traits;
 
 
 namespace detail
@@ -61,7 +63,7 @@
 class backend_writer
 {
 protected:
- typedef typename formatted_image_traits<Backend>::view_data_t view_data_t;
+ typedef typename backend_traits<Backend>::view_data_t view_data_t;
 
 private:
     // MSVC++ (8,9,10) generates code to check whether this == 0.
@@ -110,4 +112,4 @@
 //------------------------------------------------------------------------------
 } // namespace boost
 //------------------------------------------------------------------------------
-#endif // backend_writer_hpp
+#endif // writer_hpp

Copied: sandbox/gil/boost/gil/extension/io2/backends/detail/writer_for.hpp (from r73403, /sandbox/gil/boost/gil/extension/io2/writer.hpp)
==============================================================================
--- /sandbox/gil/boost/gil/extension/io2/writer.hpp (original)
+++ sandbox/gil/boost/gil/extension/io2/backends/detail/writer_for.hpp 2011-07-27 18:18:58 EDT (Wed, 27 Jul 2011)
@@ -1,9 +1,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \file formatted_image.hpp
-/// -------------------------
-///
-/// Base CRTP class for all image implementation classes/backends.
+/// \file writer_for.hpp
+/// --------------------
 ///
 /// Copyright (c) Domagoj Saric 2010.-2011.
 ///
@@ -15,8 +13,8 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 //------------------------------------------------------------------------------
-#ifndef writer_hpp__CBE52E51_7B06_4018_996A_63F9B7DF05AC
-#define writer_hpp__CBE52E51_7B06_4018_996A_63F9B7DF05AC
+#ifndef writer_for_hpp__CBE52E51_7B06_4018_996A_63F9B7DF05AC
+#define writer_for_hpp__CBE52E51_7B06_4018_996A_63F9B7DF05AC
 #pragma once
 //------------------------------------------------------------------------------
 
@@ -31,14 +29,13 @@
 {
 //------------------------------------------------------------------------------
 
-
 ////////////////////////////////////////////////////////////////////////////////
-/// \class formatted_image_traits
+/// \class backend_traits
 /// ( forward declaration )
 ////////////////////////////////////////////////////////////////////////////////
 
 template <class Backend>
-struct formatted_image_traits;
+struct backend_traits;
 
 namespace detail
 {
@@ -163,12 +160,12 @@
 struct writer_for
 {
 private:
- typedef typename formatted_image_traits<Backend>::supported_image_formats supported_image_formats;
+ typedef typename backend_traits<Backend>::supported_image_formats supported_image_formats;
 
     BOOST_STATIC_CONSTANT( format_tag, default_format = mpl::front<supported_image_formats>::type::value );
     BOOST_STATIC_CONSTANT( bool , single_format = mpl::size <supported_image_formats>::value == 1 );
 
- typedef typename mpl::has_key<typename formatted_image_traits<Backend>::native_sinks, Target>::type supported_by_native_writer_t;
+ typedef typename mpl::has_key<typename backend_traits<Backend>::native_sinks, Target>::type supported_by_native_writer_t;
 
     // The backend does not seem to provide a writer for the specified target...
     BOOST_STATIC_ASSERT
@@ -196,7 +193,7 @@
     <
         first_layer_wrapper,
         Target,
- typename formatted_image_traits<Backend>::writer_view_data_t,
+ typename backend_traits<Backend>::writer_view_data_t,
         default_format
> type;
 };
@@ -208,4 +205,4 @@
 //------------------------------------------------------------------------------
 } // namespace boost
 //------------------------------------------------------------------------------
-#endif // writer_hpp
+#endif // writer_for_hpp

Copied: sandbox/gil/boost/gil/extension/io2/backends/libtiff/backend.hpp (from r73403, /sandbox/gil/boost/gil/extension/io2/libtiff_image.hpp)
==============================================================================
--- /sandbox/gil/boost/gil/extension/io2/libtiff_image.hpp (original)
+++ sandbox/gil/boost/gil/extension/io2/backends/libtiff/backend.hpp 2011-07-27 18:18:58 EDT (Wed, 27 Jul 2011)
@@ -1,7 +1,9 @@
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \file libtiff_image.hpp
-/// -----------------------
+/// \file backend.hpp
+/// -----------------
+///
+/// LibTIFF backend.
 ///
 /// Copyright (c) Domagoj Saric 2010.
 ///
@@ -13,16 +15,16 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 //------------------------------------------------------------------------------
-#ifndef libtiff_image_hpp__0808D24E_CED1_4921_A832_3C12DAE93Ef7
-#define libtiff_image_hpp__0808D24E_CED1_4921_A832_3C12DAE93Ef7
+#ifndef backend_hpp__0808D24E_CED1_4921_A832_3C12DAE93EF7
+#define backend_hpp__0808D24E_CED1_4921_A832_3C12DAE93EF7
 #pragma once
 //------------------------------------------------------------------------------
-#include "formatted_image.hpp"
+#include "boost/gil/extension/io2/backends/detail/backend.hpp"
 
-#include "detail/io_error.hpp"
-#include "detail/libx_shared.hpp"
-#include "detail/platform_specifics.hpp"
-#include "detail/shared.hpp"
+#include "boost/gil/extension/io2/detail/io_error.hpp"
+#include "boost/gil/extension/io2/detail/libx_shared.hpp"
+#include "boost/gil/extension/io2/detail/platform_specifics.hpp"
+#include "boost/gil/extension/io2/detail/shared.hpp"
 
 #if BOOST_MPL_LIMIT_VECTOR_SIZE < 35
     #error libtiff support requires mpl vectors of size 35 or greater...
@@ -267,7 +269,7 @@
         unsigned int format_id_;
     #endif
 
-private: // this should probably go to the base formatted_image class...
+private: // this should probably go to the base backend class...
     template <class View>
     void set_buffers( View const & view, mpl::true_ /*is planar*/ )
     {
@@ -282,7 +284,7 @@
     void set_buffers( View const & view, mpl::false_ /*is not planar*/ )
     {
         number_of_planes_ = 1;
- plane_buffers_[ 0 ] = formatted_image_base::get_raw_data( view );
+ plane_buffers_[ 0 ] = backend_base::get_raw_data( view );
     }
 
     void operator=( tiff_view_data_t const & );
@@ -296,7 +298,7 @@
 class libtiff_image;
 
 template <>
-struct formatted_image_traits<libtiff_image>
+struct backend_traits<libtiff_image>
 {
     typedef detail::full_format_t::format_id format_t;
 
@@ -336,7 +338,7 @@
 
 class libtiff_image
     :
- public detail::formatted_image<libtiff_image>
+ public detail::backend<libtiff_image>
 {
 public:
     struct guard {};
@@ -428,7 +430,7 @@
         return value;
     }
 
- static std::size_t cached_format_size( formatted_image_traits<libtiff_image>::format_t const format )
+ static std::size_t cached_format_size( backend_traits<libtiff_image>::format_t const format )
     {
         full_format_t::format_bitfield const & bits( reinterpret_cast<full_format_t const &>( format ).bits );
         return bits.bits_per_sample * ( ( bits.planar_configuration == PLANARCONFIG_CONTIG ) ? bits.samples_per_pixel : 1 ) / 8;
@@ -462,4 +464,4 @@
 //------------------------------------------------------------------------------
 } // namespace boost
 //------------------------------------------------------------------------------
-#endif // libtiff_image_hpp
+#endif // backend_hpp

Copied: sandbox/gil/boost/gil/extension/io2/backends/libtiff/reader.hpp (from r73404, /sandbox/gil/boost/gil/extension/io2/libtiff_reader.hpp)
==============================================================================
--- /sandbox/gil/boost/gil/extension/io2/libtiff_reader.hpp (original)
+++ sandbox/gil/boost/gil/extension/io2/backends/libtiff/reader.hpp 2011-07-27 18:18:58 EDT (Wed, 27 Jul 2011)
@@ -1,7 +1,9 @@
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \file libtiff_reader.hpp
-/// ------------------------
+/// \file reader.hpp
+/// ----------------
+///
+/// LibTIFF reader
 ///
 /// Copyright (c) Domagoj Saric 2010.-2011.
 ///
@@ -13,17 +15,17 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 //------------------------------------------------------------------------------
-#ifndef libtiff_reader_hpp__24E9D122_DAC7_415B_8880_9BFA03916E9F
-#define libtiff_reader_hpp__24E9D122_DAC7_415B_8880_9BFA03916E9F
+#ifndef reader_hpp__24E9D122_DAC7_415B_8880_9BFA03916E9F
+#define reader_hpp__24E9D122_DAC7_415B_8880_9BFA03916E9F
 #pragma once
 //------------------------------------------------------------------------------
-#include "backend_reader.hpp"
-#include "libtiff_image.hpp"
+#include "backend.hpp"
+#include "../detail/reader.hpp"
 
-#include "detail/io_error.hpp"
-#include "detail/libx_shared.hpp"
-#include "detail/platform_specifics.hpp"
-#include "detail/shared.hpp"
+#include "boost/gil/extension/io2/detail/io_error.hpp"
+#include "boost/gil/extension/io2/detail/libx_shared.hpp"
+#include "boost/gil/extension/io2/detail/platform_specifics.hpp"
+#include "boost/gil/extension/io2/detail/shared.hpp"
 
 #include "boost/gil/image_view_factory.hpp"
 
@@ -214,13 +216,13 @@
         return ( dividend + divisor - 1 ) / divisor;
     }
 
-private: // Private formatted_image_base interface.
+private: // Private backend_base interface.
     // Implementation note:
     // MSVC 10 accepts friend base_t and friend class base_t, Clang 2.8
     // accepts friend class base_t, Apple Clang 1.6 and GCC (4.2 and 4.6) accept
     // neither.
     // (13.01.2011.) (Domagoj Saric)
- friend class detail::formatted_image<libtiff_image::native_reader>;
+ friend class detail::backend<libtiff_image::native_reader>;
 
     struct tile_setup_t
         #ifndef __GNUC__
@@ -850,4 +852,4 @@
 //------------------------------------------------------------------------------
 } // namespace boost
 //------------------------------------------------------------------------------
-#endif // libtiff_reader_hpp
+#endif // reader_hpp

Copied: sandbox/gil/boost/gil/extension/io2/backends/libtiff/writer.hpp (from r73403, /sandbox/gil/boost/gil/extension/io2/libtiff_writer.hpp)
==============================================================================
--- /sandbox/gil/boost/gil/extension/io2/libtiff_writer.hpp (original)
+++ sandbox/gil/boost/gil/extension/io2/backends/libtiff/writer.hpp 2011-07-27 18:18:58 EDT (Wed, 27 Jul 2011)
@@ -1,7 +1,9 @@
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \file libtiff_writer.hpp
-/// ------------------------
+/// \file writer.hpp
+/// ----------------
+///
+/// LibTIFF writer.
 ///
 /// Copyright (c) Domagoj Saric 2010.-2011.
 ///
@@ -13,17 +15,17 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 //------------------------------------------------------------------------------
-#ifndef libtiff_writer_hpp__FD402B04_E934_4E73_8839_001A8633B5D3
-#define libtiff_writer_hpp__FD402B04_E934_4E73_8839_001A8633B5D3
+#ifndef writer_hpp__FD402B04_E934_4E73_8839_001A8633B5D3
+#define writer_hpp__FD402B04_E934_4E73_8839_001A8633B5D3
 #pragma once
 //------------------------------------------------------------------------------
-#include "libtiff_image.hpp"
-#include "backend_writer.hpp"
+#include "backend.hpp"
+#include "../detail/writer.hpp"
 
-#include "detail/io_error.hpp"
-#include "detail/libx_shared.hpp"
-#include "detail/platform_specifics.hpp"
-#include "detail/shared.hpp"
+#include "boost/gil/extension/io2/detail/io_error.hpp"
+#include "boost/gil/extension/io2/detail/libx_shared.hpp"
+#include "boost/gil/extension/io2/detail/platform_specifics.hpp"
+#include "boost/gil/extension/io2/detail/shared.hpp"
 
 #include <boost/array.hpp>
 //------------------------------------------------------------------------------
@@ -33,16 +35,14 @@
 namespace gil
 {
 //------------------------------------------------------------------------------
-namespace detail
+namespace io
 {
 //------------------------------------------------------------------------------
-
-inline tsize_t FILE_write_proc( thandle_t const handle, tdata_t const buf, tsize_t const size )
+namespace detail
 {
- return static_cast<tsize_t>( std::fwrite( buf, 1, size, reinterpret_cast<FILE *>( handle ) ) );
-}
+//------------------------------------------------------------------------------
 
-struct tiff_writer_view_data_t : public tiff_view_data_t
+struct tiff_writer_view_data_t : tiff_view_data_t
 {
     template <class View>
     tiff_writer_view_data_t( View const & view )
@@ -58,18 +58,28 @@
 //------------------------------------------------------------------------------
 } // namespace detail
 
-class libtiff_writer
+class libtiff_image::native_writer
     :
     public libtiff_image,
     public detail::backend_writer<libtiff_image>,
- public configure_on_write_writer
+ public detail::configure_on_write_writer
 {
 public:
- explicit libtiff_writer( char const * const file_name ) : libtiff_image( file_name, "w" ) {}
+ explicit native_writer( char const * const file_name ) : libtiff_image( file_name, "w" ) {}
 
- explicit libtiff_writer( FILE & file ) : libtiff_image( file ) {}
+ template <typename DeviceHandle>
+ explicit native_writer( DeviceHandle const handle )
+ :
+ libtiff_image
+ (
+ handle,
+ NULL,
+ &input_device<DeviceHandle>::write,
+ NULL,
+ NULL
+ ),
 
- void write_default( tiff_writer_view_data_t const & view )
+ void write_default( detail::tiff_writer_view_data_t const & view )
     {
         full_format_t::format_bitfield const format_bits( view.format_.bits );
         //BOOST_ASSERT( ( format_bits.planar_configuration == PLANARCONFIG_CONTIG ) && "Add planar support..." );
@@ -94,7 +104,7 @@
         write( view );
     }
 
- void write( tiff_writer_view_data_t const & view )
+ void write( detail::tiff_writer_view_data_t const & view )
     {
         cumulative_result result;
 
@@ -119,9 +129,9 @@
     void set_field( ttag_t const tag, T value )
     {
         #ifdef _MSC_VER
- BOOST_VERIFY( ::TIFFVSetField( &lib_object(), tag, gil_reinterpret_cast<va_list>( &value ) ) );
+ BOOST_VERIFY( ::TIFFVSetField( &lib_object(), tag, reinterpret_cast<va_list>( &value ) ) );
         #else
- BOOST_VERIFY( ::TIFFSetField ( &lib_object(), tag, value ) );
+ BOOST_VERIFY( ::TIFFSetField ( &lib_object(), tag, value ) );
         #endif // _MSC_VER
     }
 
@@ -133,8 +143,10 @@
 };
 
 //------------------------------------------------------------------------------
+} // namespace io
+//------------------------------------------------------------------------------
 } // namespace gil
 //------------------------------------------------------------------------------
 } // namespace boost
 //------------------------------------------------------------------------------
-#endif // libtiff_writer_hpp
+#endif // writer_hpp

Copied: sandbox/gil/boost/gil/extension/io2/backends/wic/backend.hpp (from r73403, /sandbox/gil/boost/gil/extension/io2/wic_image.hpp)
==============================================================================
--- /sandbox/gil/boost/gil/extension/io2/wic_image.hpp (original)
+++ sandbox/gil/boost/gil/extension/io2/backends/wic/backend.hpp 2011-07-27 18:18:58 EDT (Wed, 27 Jul 2011)
@@ -1,7 +1,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \file wic_image.hpp
-/// -------------------
+/// \file backend.hpp
+/// -----------------
 ///
 /// Base IO interface WIC implementation.
 ///
@@ -15,16 +15,18 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 //------------------------------------------------------------------------------
-#ifndef wic_image_hpp__78D710F7_11C8_4023_985A_22B180C9A476
-#define wic_image_hpp__78D710F7_11C8_4023_985A_22B180C9A476
+#ifndef backend_hpp__78D710F7_11C8_4023_985A_22B180C9A476
+#define backend_hpp__78D710F7_11C8_4023_985A_22B180C9A476
 #pragma once
 //------------------------------------------------------------------------------
-#include "detail/io_error.hpp"
-#include "detail/shared.hpp"
-#include "detail/wic_extern_lib_guard.hpp"
-#include "detail/windows_shared.hpp"
-#include "detail/windows_shared_istreams.hpp"
-#include "formatted_image.hpp"
+#include "extern_lib_guard.hpp"
+
+#include "boost/gil/extension/io2/backends/detail/backend.hpp"
+
+#include "boost/gil/extension/io2/detail/io_error.hpp"
+#include "boost/gil/extension/io2/detail/shared.hpp"
+#include "boost/gil/extension/io2/detail/windows_shared.hpp"
+#include "boost/gil/extension/io2/detail/windows_shared_istreams.hpp"
 
 #include <boost/mpl/vector_c.hpp> //...missing from metafuncitons.hpp...
 #include "boost/gil/metafunctions.hpp"
@@ -186,7 +188,7 @@
         stride_ = view.pixels().row_size();
         pixel_size_ = memunit_step( typename View::x_iterator() );
         //format_ = gil_to_wic_format<typename View::value_type, is_planar<View>::value>::value;
- p_buffer_ = detail::formatted_image_base::get_raw_data( view );
+ p_buffer_ = detail::backend_base::get_raw_data( view );
     }
 
     void operator=( wic_view_data_t const & );
@@ -205,7 +207,7 @@
 class wic_image;
 
 template <>
-struct formatted_image_traits<wic_image>
+struct backend_traits<wic_image>
 {
     typedef detail::wic_format_t format_t;
 
@@ -262,7 +264,7 @@
 class wic_image
     :
     private detail::wic_base_guard,
- public detail::formatted_image<wic_image>
+ public detail::backend<wic_image>
 {
 public:
     typedef detail::wic_user_guard guard;
@@ -284,4 +286,4 @@
 //------------------------------------------------------------------------------
 } // namespace boost
 //------------------------------------------------------------------------------
-#endif // wic_image_hpp
+#endif // backend_hpp

Copied: sandbox/gil/boost/gil/extension/io2/backends/wic/extern_lib_guard.hpp (from r73403, /sandbox/gil/boost/gil/extension/io2/detail/wic_extern_lib_guard.hpp)
==============================================================================
--- /sandbox/gil/boost/gil/extension/io2/detail/wic_extern_lib_guard.hpp (original)
+++ sandbox/gil/boost/gil/extension/io2/backends/wic/extern_lib_guard.hpp 2011-07-27 18:18:58 EDT (Wed, 27 Jul 2011)
@@ -1,9 +1,11 @@
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \file wic_extern_lib_guard.hpp
-/// ------------------------------
+/// \file extern_lib_guard.hpp
+/// --------------------------
 ///
-/// Copyright (c) Domagoj Saric 2010.
+/// WIC extern lib guard
+///
+/// Copyright (c) Domagoj Saric 2010.-2011.
 ///
 /// Use, modification and distribution is subject to the Boost Software License, Version 1.0.
 /// (See accompanying file LICENSE_1_0.txt or copy at
@@ -13,11 +15,11 @@
 ////////////////////////////////////////////////////////////////////////////////
 //------------------------------------------------------------------------------
 #pragma once
-#ifndef wic_extern_lib_guard_hpp__A28436C0_3FEA_4850_9287_656BAAAD6259
-#define wic_extern_lib_guard_hpp__A28436C0_3FEA_4850_9287_656BAAAD6259
+#ifndef extern_lib_guard_hpp__A28436C0_3FEA_4850_9287_656BAAAD6259
+#define extern_lib_guard_hpp__A28436C0_3FEA_4850_9287_656BAAAD6259
 //------------------------------------------------------------------------------
-#include "extern_lib.hpp"
-#include "io_error.hpp"
+#include "boost/gil/extension/io2/backends/detail/extern_lib_guard.hpp"
+#include "boost/gil/extension/io2/detail/io_error.hpp"
 
 #include <boost/preprocessor/comparison/greater.hpp>
 
@@ -191,4 +193,4 @@
 //------------------------------------------------------------------------------
 } // namespace boost
 //------------------------------------------------------------------------------
-#endif // wic_extern_lib_guard_hpp
+#endif // extern_lib_guard_hpp

Copied: sandbox/gil/boost/gil/extension/io2/backends/wic/reader.hpp (from r73403, /sandbox/gil/boost/gil/extension/io2/wic_reader.hpp)
==============================================================================
--- /sandbox/gil/boost/gil/extension/io2/wic_reader.hpp (original)
+++ sandbox/gil/boost/gil/extension/io2/backends/wic/reader.hpp 2011-07-27 18:18:58 EDT (Wed, 27 Jul 2011)
@@ -1,9 +1,9 @@
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \file wic_image.hpp
-/// -------------------
+/// \file reader.hpp
+/// ----------------
 ///
-/// Base IO interface WIC implementation.
+/// WIC reader.
 ///
 /// Copyright (c) Domagoj Saric 2010.-2011.
 ///
@@ -15,16 +15,16 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 //------------------------------------------------------------------------------
-#ifndef wic_reader_hpp__8C7EFA72_9E1A_4FD4_AF3F_B7921B320C1C
-#define wic_reader_hpp__8C7EFA72_9E1A_4FD4_AF3F_B7921B320C1C
+#ifndef reader_hpp__8C7EFA72_9E1A_4FD4_AF3F_B7921B320C1C
+#define reader_hpp__8C7EFA72_9E1A_4FD4_AF3F_B7921B320C1C
 #pragma once
 //------------------------------------------------------------------------------
-#include "backend_reader.hpp"
-#include "detail/io_error.hpp"
-#include "detail/wic_extern_lib_guard.hpp"
-#include "detail/windows_shared.hpp"
-#include "detail/windows_shared_istreams.hpp"
-#include "wic_image.hpp"
+#include "backend.hpp"
+#include "../detail/reader.hpp"
+
+#include "boost/gil/extension/io2/detail/io_error.hpp"
+#include "boost/gil/extension/io2/detail/windows_shared.hpp"
+#include "boost/gil/extension/io2/detail/windows_shared_istreams.hpp"
 
 #include <boost/mpl/vector_c.hpp> //...missing from metafuncitons.hpp...
 #include "boost/gil/metafunctions.hpp"
@@ -74,8 +74,6 @@
                 detail::com_scoped_ptr<IWICBitmapDecoder >
> lib_object_t;
 
- typedef detail::wic_user_guard guard;
-
 public:
     explicit native_reader( wchar_t const * const filename )
     {
@@ -298,4 +296,4 @@
 //------------------------------------------------------------------------------
 } // namespace boost
 //------------------------------------------------------------------------------
-#endif // wic_reader_hpp
+#endif // reader_hpp

Copied: sandbox/gil/boost/gil/extension/io2/backends/wic/writer.hpp (from r73403, /sandbox/gil/boost/gil/extension/io2/wic_writer.hpp)
==============================================================================
--- /sandbox/gil/boost/gil/extension/io2/wic_writer.hpp (original)
+++ sandbox/gil/boost/gil/extension/io2/backends/wic/writer.hpp 2011-07-27 18:18:58 EDT (Wed, 27 Jul 2011)
@@ -1,9 +1,9 @@
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \file wic_writer.hpp
-/// --------------------
+/// \file writer.hpp
+/// ----------------
 ///
-/// Base IO interface WIC implementation.
+/// WIC writer.
 ///
 /// Copyright (c) Domagoj Saric 2010.-2011.
 ///
@@ -15,17 +15,16 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 //------------------------------------------------------------------------------
-#ifndef wic_writer_hpp__F8E533DB_13F3_495F_9F64_0C33F7C5AB95
-#define wic_writer_hpp__F8E533DB_13F3_495F_9F64_0C33F7C5AB95
+#ifndef writer_hpp__F8E533DB_13F3_495F_9F64_0C33F7C5AB95
+#define writer_hpp__F8E533DB_13F3_495F_9F64_0C33F7C5AB95
 #pragma once
 //------------------------------------------------------------------------------
-#include "wic_image.hpp"
-#include "backend_writer.hpp"
-#include "writer.hpp"
-
-#include "detail/io_error.hpp"
-#include "detail/windows_shared.hpp"
-#include "detail/windows_shared_istreams.hpp"
+#include "backend.hpp"
+#include "../detail/writer.hpp"
+
+#include "boost/gil/extension/io2/detail/io_error.hpp"
+#include "boost/gil/extension/io2/detail/windows_shared.hpp"
+#include "boost/gil/extension/io2/detail/windows_shared_istreams.hpp"
 //------------------------------------------------------------------------------
 namespace boost
 {
@@ -146,4 +145,4 @@
 //------------------------------------------------------------------------------
 } // namespace boost
 //------------------------------------------------------------------------------
-#endif // wic_writer_hpp
+#endif // writer_hpp

Deleted: sandbox/gil/boost/gil/extension/io2/detail/extern_lib.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/detail/extern_lib.hpp 2011-07-27 18:18:58 EDT (Wed, 27 Jul 2011)
+++ (empty file)
@@ -1,394 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \file extern_lib.hpp
-/// --------------------
-///
-/// BOOST_DELAYED_EXTERN_LIB_GUARD helper macro for reducing boilerplate code
-/// related to dynamic/run-time linking.
-///
-/// Copyright (c) Domagoj Saric 2010.
-///
-/// Use, modification and distribution is subject to the Boost Software License, Version 1.0.
-/// (See accompanying file LICENSE_1_0.txt or copy at
-/// http://www.boost.org/LICENSE_1_0.txt)
-///
-/// For more information, see http://www.boost.org
-////////////////////////////////////////////////////////////////////////////////
-//------------------------------------------------------------------------------
-#pragma once
-#ifndef extern_lib_hpp__EAE6695D_91B6_4E14_A3B9_9931BA3FB3B3
-#define extern_lib_hpp__EAE6695D_91B6_4E14_A3B9_9931BA3FB3B3
-//------------------------------------------------------------------------------
-#include <boost/assert.hpp>
-#include <boost/concept_check.hpp>
-#include <boost/noncopyable.hpp>
-#include <boost/optional.hpp>
-#include <boost/preprocessor/cat.hpp>
-#include <boost/preprocessor/comparison/equal.hpp>
-#include <boost/preprocessor/control/expr_if.hpp>
-#include <boost/preprocessor/control/if.hpp>
-#include <boost/preprocessor/facilities/expand.hpp>
-#include <boost/preprocessor/punctuation/comma_if.hpp>
-#include <boost/preprocessor/seq/enum.hpp>
-#include <boost/preprocessor/seq/for_each.hpp>
-#include <boost/preprocessor/seq/for_each_i.hpp>
-#include <boost/preprocessor/stringize.hpp>
-#include <boost/preprocessor/tuple/elem.hpp>
-#include <boost/utility/in_place_factory.hpp>
-
-#ifdef _WIN32
- #include "windows.h"
-#else // _WIN32
- ...do implement...
-#endif // platform switch
-//------------------------------------------------------------------------------
-namespace boost
-{
-//------------------------------------------------------------------------------
-
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// Configuration macros
-//
-////////////////////////////////////////////////////////////////////////////////
-
-#define BOOST_LIB_LINK_LOADTIME_OR_STATIC 1
-#define BOOST_LIB_LINK_RUNTIME_ASSUME_LOADED 2
-#define BOOST_LIB_LINK_RUNTIME_AUTO_LOAD 3
-
-#define BOOST_LIB_LOADING_STATIC 1
-#define BOOST_LIB_LOADING_SINGLE 2
-#define BOOST_LIB_LOADING_RELOADABLE 3
-
-#define BOOST_LIB_INIT_ASSUME 1
-#define BOOST_LIB_INIT_AUTO 2
-
-// Usage example:
-// #define BOOST_GIL_EXTERNAL_LIB ( BOOST_LIB_LINK_RUNTIME_ASSUME_LOADED, BOOST_LIB_LOADING_RELOADABLE, BOOST_LIB_INIT_AUTO )
-
-
-//...or maybe provide the above options merged...something like this:
-//#define StaticallyLinkAssumeInitialized 0
-//#define StaticallyLinkAutoInitialized 1
-//#define DynamicLinkAssumeLoadedAndInitialized 2
-//#define DynamicLinkAssumeLoadedAutoInitialize 3
-//#define DynamicLinkAutoLoadAutoInitialize 4
-
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// Base guard classes
-//
-////////////////////////////////////////////////////////////////////////////////
-
-class win32_lib_handle : noncopyable
-{
-public:
- HMODULE lib_handle() const { return lib_handle_; }
-
- static HMODULE loaded_lib_handle( char const * const lib_name ) { return ::GetModuleHandleA( lib_name ); }
- static HMODULE loaded_lib_handle( wchar_t const * const lib_name ) { return ::GetModuleHandleW( lib_name ); }
-
- template <typename T>
- static T checked_proc_address( HMODULE const lib_handle, char const * const function_name )
- {
- BOOST_ASSERT( lib_handle );
- FARPROC const funcion_address( ::GetProcAddress( lib_handle, function_name ) );
- BOOST_ASSERT( funcion_address && "Requested function not exported by the library." );
- return reinterpret_cast<T>( *funcion_address );
- }
-
- template <typename T>
- T checked_proc_address( char const * const function_name ) const
- {
- return checked_proc_address<T>( lib_handle(), function_name );
- }
-
-protected:
- win32_lib_handle( HMODULE const lib_handle ) : lib_handle_( lib_handle ) {}
- ~win32_lib_handle() {}
-
- void ensure() const; //...implement later as desired...
- void verify() const { BOOST_ASSERT( lib_handle() && "Library not loaded." ); }
-
-private:
- HMODULE const lib_handle_;
-};
-
-
-class win32_preloaded_reloadable_lib : public win32_lib_handle
-{
-public:
- win32_preloaded_reloadable_lib( char const * const lib_name ) : win32_lib_handle( loaded_lib_handle( lib_name ) ) { verify(); }
- win32_preloaded_reloadable_lib( wchar_t const * const lib_name ) : win32_lib_handle( loaded_lib_handle( lib_name ) ) { verify(); }
-};
-
-
-class win32_preloaded_delayloaded_lib
-{
-public:
- win32_preloaded_delayloaded_lib( char const * const lib_name )
- {
- if ( !delayed_lib_.is_initialized() )
- delayed_lib_ = in_place( lib_name );
- else
- BOOST_ASSERT
- (
- ( delayed_lib_->lib_handle() == win32_preloaded_reloadable_lib( lib_name ).lib_handle() ) &&
- "Library reloaded/relocated!"
- );
- }
-
- win32_preloaded_delayloaded_lib( wchar_t const * const lib_name )
- {
- if ( !delayed_lib_.is_initialized() )
- delayed_lib_ = in_place( lib_name );
- else
- BOOST_ASSERT
- (
- ( delayed_lib_->lib_handle() == win32_preloaded_reloadable_lib( lib_name ).lib_handle() ) &&
- "Library reloaded/relocated!"
- );
- }
-
- static HMODULE lib_handle() { return delayed_lib_->lib_handle(); }
-
- static HMODULE loaded_lib_handle( char const * const lib_name )
- {
- BOOST_ASSERT( win32_lib_handle::loaded_lib_handle( lib_name ) == lib_handle() );
- ignore_unused_variable_warning( lib_name );
- return lib_handle();
- }
- static HMODULE loaded_lib_handle( wchar_t const * const lib_name )
- {
- BOOST_ASSERT( win32_lib_handle::loaded_lib_handle( lib_name ) == lib_handle() );
- ignore_unused_variable_warning( lib_name );
- return lib_handle();
- }
-
-private:
- static optional<win32_preloaded_reloadable_lib> delayed_lib_;
-};
-
-__declspec( selectany )
-optional<win32_preloaded_reloadable_lib> win32_preloaded_delayloaded_lib::delayed_lib_;
-
-
-class win32_reloadable_lib_guard : public win32_lib_handle
-{
-public:
- win32_reloadable_lib_guard( char const * const lib_name ) : win32_lib_handle( ::LoadLibraryA( lib_name ) ) { ensure(); }
- win32_reloadable_lib_guard( wchar_t const * const lib_name ) : win32_lib_handle( ::LoadLibraryW( lib_name ) ) { ensure(); }
-
- ~win32_reloadable_lib_guard() { BOOST_VERIFY( ::FreeLibrary( lib_handle() ) ); }
-};
-
-
-class win32_delayloaded_lib_guard
-{
-public:
- win32_delayloaded_lib_guard( char const * const lib_name )
- {
- if ( !delayed_lib_.is_initialized() )
- delayed_lib_ = in_place( lib_name );
- else
- BOOST_ASSERT
- (
- ( delayed_lib_->lib_handle() == win32_reloadable_lib_guard( lib_name ).lib_handle() ) &&
- "Library reloaded/relocated!"
- );
- }
-
- win32_delayloaded_lib_guard( wchar_t const * const lib_name )
- {
- if ( !delayed_lib_.is_initialized() )
- delayed_lib_ = in_place( lib_name );
- else
- BOOST_ASSERT
- (
- ( delayed_lib_->lib_handle() == win32_reloadable_lib_guard( lib_name ).lib_handle() ) &&
- "Library reloaded/relocated!"
- );
- }
-
- static HMODULE lib_handle() { return delayed_lib_->lib_handle(); }
-
- static HMODULE loaded_lib_handle( char const * const lib_name )
- {
- BOOST_ASSERT( win32_lib_handle::loaded_lib_handle( lib_name ) == lib_handle() );
- ignore_unused_variable_warning( lib_name );
- return lib_handle();
- }
- static HMODULE loaded_lib_handle( wchar_t const * const lib_name )
- {
- BOOST_ASSERT( win32_lib_handle::loaded_lib_handle( lib_name ) == lib_handle() );
- ignore_unused_variable_warning( lib_name );
- return lib_handle();
- }
-
-private:
- static optional<win32_reloadable_lib_guard> delayed_lib_;
-};
-
-__declspec( selectany )
-optional<win32_reloadable_lib_guard> win32_delayloaded_lib_guard::delayed_lib_;
-
-
-class dummy_lib_guard
-{
-public:
- dummy_lib_guard( char const * /*lib_name*/ ) {}
- dummy_lib_guard( wchar_t const * /*lib_name*/ ) {}
-
- static HMODULE loaded_lib_handle( char const * const lib_name ) { return win32_lib_handle::loaded_lib_handle( lib_name ); }
- static HMODULE loaded_lib_handle( wchar_t const * const lib_name ) { return win32_lib_handle::loaded_lib_handle( lib_name ); }
-};
-
-
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// Preprocessor section
-//
-////////////////////////////////////////////////////////////////////////////////
-
-#define BOOST_LIB_LINK( option ) BOOST_PP_TUPLE_ELEM( 3, 0, option )
-#define BOOST_LIB_LOADING( option ) BOOST_PP_TUPLE_ELEM( 3, 1, option )
-#define BOOST_LIB_INIT( option ) BOOST_PP_TUPLE_ELEM( 3, 2, option )
-
-#define BOOST_LIB_GUARD_FOR_LINK_TYPE( type ) \
- BOOST_PP_EXPR_IF \
- ( \
- BOOST_PP_EQUAL( BOOST_LIB_LINK( type ), BOOST_LIB_LINK_LOADTIME_OR_STATIC ), \
- no need for a lib guard with load time or static linking \
- ) \
- BOOST_PP_IF \
- ( \
- BOOST_PP_EQUAL( BOOST_LIB_INIT( type ), BOOST_LIB_INIT_ASSUME ), \
- dummy_lib_guard, \
- BOOST_PP_IF \
- ( \
- BOOST_PP_EQUAL( BOOST_LIB_LINK( type ), BOOST_LIB_LINK_RUNTIME_ASSUME_LOADED ), \
- BOOST_PP_IF \
- ( \
- BOOST_PP_EQUAL( BOOST_LIB_LOADING( type ), BOOST_LIB_LOADING_SINGLE ), \
- win32_preloaded_delayloaded_lib, \
- win32_preloaded_reloadable_lib \
- ), \
- BOOST_PP_IF \
- ( \
- BOOST_PP_EQUAL( BOOST_LIB_LOADING( type ), BOOST_LIB_LOADING_SINGLE ), \
- win32_delayloaded_lib_guard, \
- win32_reloadable_lib_guard \
- ) \
- ) \
- )
-
-
-#define BOOST_DELAYED_EXTERN_LIB_FUNCTION_TYPEDEF_AND_POINTER_WORKER( condition, return_type, call_convention, function_name, parameter_sequence ) \
- BOOST_PP_EXPR_IF \
- ( \
- condition, \
- typedef return_type ( call_convention & BOOST_PP_CAT( P, function_name ) ) ( BOOST_PP_SEQ_ENUM( parameter_sequence ) ) throw(); \
- return_type ( call_convention & BOOST_PP_CAT( p, function_name ) ) ( BOOST_PP_SEQ_ENUM( parameter_sequence ) ) throw(); \
- )
-
-#define BOOST_DELAYED_EXTERN_LIB_FUNCTION_TYPEDEF_AND_POINTER( r, dummy, element ) \
- BOOST_DELAYED_EXTERN_LIB_FUNCTION_TYPEDEF_AND_POINTER_WORKER( BOOST_PP_TUPLE_ELEM( 5, 0, element ), BOOST_PP_TUPLE_ELEM( 5, 1, element ), BOOST_PP_TUPLE_ELEM( 5, 2, element ), BOOST_PP_TUPLE_ELEM( 5, 3, element ), BOOST_PP_TUPLE_ELEM( 5, 4, element ) )
-
-
-#define BOOST_DELAYED_EXTERN_LIB_FUNCTION_PARAMETERS( r, data, index, parameter ) \
- BOOST_PP_COMMA_IF( index ) \
- parameter BOOST_PP_CAT( prm, index )
-
-
-#define BOOST_DELAYED_EXTERN_LIB_FUNCTION_ARGUMENTS( r, data, index, parameter ) \
- BOOST_PP_COMMA_IF( index ) \
- BOOST_PP_CAT( prm, index )
-
-
-#define BOOST_DELAYED_EXTERN_LIB_FUNCTION_IMPLEMENTATION_WORKER( condition, guard_class_name, return_type, call_convention, function_name, parameter_sequence ) \
- BOOST_PP_EXPR_IF \
- ( \
- condition, \
- inline __declspec( nothrow ) return_type call_convention function_name( BOOST_PP_SEQ_FOR_EACH_I( BOOST_DELAYED_EXTERN_LIB_FUNCTION_PARAMETERS, 0, parameter_sequence ) ) { \
- return guard_class_name::lib_functions().BOOST_PP_CAT( p, function_name )( BOOST_PP_SEQ_FOR_EACH_I( BOOST_DELAYED_EXTERN_LIB_FUNCTION_ARGUMENTS, 0, parameter_sequence ) ); } \
- )
-
-#define BOOST_DELAYED_EXTERN_LIB_FUNCTION_IMPLEMENTATION( r, guard_class_name, element ) \
- BOOST_DELAYED_EXTERN_LIB_FUNCTION_IMPLEMENTATION_WORKER( BOOST_PP_TUPLE_ELEM( 5, 0, element ), guard_class_name, BOOST_PP_TUPLE_ELEM( 5, 1, element ), BOOST_PP_TUPLE_ELEM( 5, 2, element ), BOOST_PP_TUPLE_ELEM( 5, 3, element ), BOOST_PP_TUPLE_ELEM( 5, 4, element ) )
-
-
-#define BOOST_DELAYED_EXTERN_LIB_FUNCTION_LOAD_WORKER( function_name ) \
- BOOST_PP_CAT( p, function_name )( boost::win32_lib_handle::checked_proc_address<BOOST_PP_CAT( P, function_name )>( lib_handle, BOOST_PP_STRINGIZE( function_name ) ) )
-
-#define BOOST_DELAYED_EXTERN_LIB_FUNCTION_LOAD( r, data, index, function_tuple ) \
- BOOST_PP_EXPR_IF \
- ( \
- BOOST_PP_TUPLE_ELEM( 5, 0, function_tuple ), \
- BOOST_PP_COMMA_IF( index ) \
- BOOST_DELAYED_EXTERN_LIB_FUNCTION_LOAD_WORKER \
- ( \
- BOOST_PP_TUPLE_ELEM( 5, 3, function_tuple ) \
- ) \
- )
-
-
-#define BOOST_DELAYED_EXTERN_LIB_GUARD( lib_name, guard_class_name, guard_option, functionSequence ) \
- class guard_class_name : public boost:: BOOST_LIB_GUARD_FOR_LINK_TYPE( guard_option ) \
- { \
- private: \
- struct functions : ::boost::noncopyable \
- { \
- BOOST_PP_SEQ_FOR_EACH( BOOST_DELAYED_EXTERN_LIB_FUNCTION_TYPEDEF_AND_POINTER, 0 , functionSequence ); \
- \
- functions( HMODULE const lib_handle ) \
- : \
- BOOST_PP_SEQ_FOR_EACH_I( BOOST_DELAYED_EXTERN_LIB_FUNCTION_LOAD, 0 , functionSequence ) \
- {} \
- }; \
- template <int dummy = 0> \
- struct functions_singleton : ::boost::noncopyable \
- { \
- static void create( HMODULE const lib_handle ) \
- { \
- if ( !functions_.is_initialized() ) \
- functions_ = boost::in_place( lib_handle ); \
- } \
- static functions const & lib_functions() { return *functions_; } \
- private: \
- static boost::optional<functions> functions_; \
- }; \
- public: \
- guard_class_name() : boost:: BOOST_LIB_GUARD_FOR_LINK_TYPE( guard_option ) ( L#lib_name ) \
- { \
- BOOST_PP_EXPR_IF \
- ( \
- BOOST_PP_EQUAL( BOOST_LIB_INIT( guard_option ), BOOST_LIB_INIT_AUTO ), \
- functions_singleton<>::create( lib_handle() ); \
- ) \
- } \
- static void init_functions( HMODULE const lib_handle ) { functions_singleton<>::create( lib_handle ); } \
- static void init_functions() { functions_singleton<>::create( loaded_lib_handle( L#lib_name ) ); } \
- static functions const & lib_functions() { return functions_singleton<>::lib_functions(); } \
- }; \
- \
-template <int dummy> \
-__declspec( selectany ) \
-boost::optional<guard_class_name::functions> guard_class_name::functions_singleton<dummy>::functions_; \
- \
-BOOST_PP_SEQ_FOR_EACH( BOOST_DELAYED_EXTERN_LIB_FUNCTION_IMPLEMENTATION, guard_class_name, functionSequence ); \
-/**/
-
-
-#ifndef BOOST_GIL_EXTERNAL_LIB
- //#define BOOST_GIL_EXTERNAL_LIB DynamicLinkAutoLoadAutoInitialize
- #define BOOST_GIL_EXTERNAL_LIB ( BOOST_LIB_LINK_RUNTIME_AUTO_LOAD, BOOST_LIB_LOADING_RELOADABLE, BOOST_LIB_INIT_AUTO )
-#endif // BOOST_GIL_EXTERNAL_LIB
-
-
-//------------------------------------------------------------------------------
-} // namespace boost
-//------------------------------------------------------------------------------
-#endif // extern_lib_hpp

Deleted: sandbox/gil/boost/gil/extension/io2/detail/wic_extern_lib_guard.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/detail/wic_extern_lib_guard.hpp 2011-07-27 18:18:58 EDT (Wed, 27 Jul 2011)
+++ (empty file)
@@ -1,194 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \file wic_extern_lib_guard.hpp
-/// ------------------------------
-///
-/// Copyright (c) Domagoj Saric 2010.
-///
-/// Use, modification and distribution is subject to the Boost Software License, Version 1.0.
-/// (See accompanying file LICENSE_1_0.txt or copy at
-/// http://www.boost.org/LICENSE_1_0.txt)
-///
-/// For more information, see http://www.boost.org
-////////////////////////////////////////////////////////////////////////////////
-//------------------------------------------------------------------------------
-#pragma once
-#ifndef wic_extern_lib_guard_hpp__A28436C0_3FEA_4850_9287_656BAAAD6259
-#define wic_extern_lib_guard_hpp__A28436C0_3FEA_4850_9287_656BAAAD6259
-//------------------------------------------------------------------------------
-#include "extern_lib.hpp"
-#include "io_error.hpp"
-
-#include <boost/preprocessor/comparison/greater.hpp>
-
-#include <cstdint>
-
-#if defined( _STDINT ) && !defined( _INTSAFE_H_INCLUDED_ )
- #define _INTSAFE_H_INCLUDED_
-#endif
-#ifndef COM_NO_WINDOWS_H
- #define COM_NO_WINDOWS_H
-#endif // COM_NO_WINDOWS_H
-#include "objbase.h"
-#include "wincodec.h"
-//------------------------------------------------------------------------------
-namespace boost
-{
-//------------------------------------------------------------------------------
-namespace gil
-{
-//------------------------------------------------------------------------------
-namespace io
-{
-//------------------------------------------------------------------------------
-namespace detail
-{
-//------------------------------------------------------------------------------
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// com_scoped_ptr
-// --------------
-//
-////////////////////////////////////////////////////////////////////////////////
-
-template <class COMInterface>
-class com_scoped_ptr : noncopyable
-{
-private:
- class __declspec( novtable ) block_manual_lifetime_management_proxy : public COMInterface
- {
- private:
- ULONG STDMETHODCALLTYPE AddRef ();
- ULONG STDMETHODCALLTYPE Release();
- };
-
-public:
- com_scoped_ptr() : baseCOMPtr_( NULL ) {}
- com_scoped_ptr( COMInterface const * const baseCOMPtr ) : baseCOMPtr_( baseCOMPtr ) { if ( baseCOMPtr ) baseCOMPtr ->AddRef(); }
- com_scoped_ptr( com_scoped_ptr const & source ) : baseCOMPtr_( source.baseCOMPtr_ ) { if ( baseCOMPtr_ ) baseCOMPtr_->AddRef(); }
- com_scoped_ptr( IUnknown & source )
- {
- //http://msdn.microsoft.com/en-us/library/ms682521(v=vs.85).aspx
- //http://blogs.msdn.com/b/oldnewthing/archive/2004/03/26/96777.aspx
- //http://c2.com/cgi/wiki?QueryInterface
- //http://msdn.microsoft.com/en-us/library/ms810016
- //http://msdn.microsoft.com/en-us/library/dd542643(VS.85).aspx
- //http://en.wikipedia.org/wiki/Catastrophic_failure
- BOOST_VERIFY
- (
- source.QueryInterface
- (
- __uuidof( COMInterface ),
- reinterpret_cast<void * *>( &baseCOMPtr_ )
- ) == S_OK
- );
- }
- ~com_scoped_ptr() { release(); }
-
- block_manual_lifetime_management_proxy & operator *() const { BOOST_ASSERT( baseCOMPtr_ ); return *static_cast<block_manual_lifetime_management_proxy *>( baseCOMPtr_ ); }
- block_manual_lifetime_management_proxy * operator->() const { return &operator*(); }
-
- COMInterface * * operator&()
- {
- BOOST_ASSERT( baseCOMPtr_ == NULL );
- return &baseCOMPtr_;
- }
-
- operator COMInterface *() const { return baseCOMPtr_; }
-
- void release()
- {
- if ( baseCOMPtr_ )
- {
- baseCOMPtr_->Release();
- baseCOMPtr_ = 0;
- }
- }
-
- HRESULT create_instance( CLSID const & class_id )
- {
- BOOST_ASSERT( baseCOMPtr_ == NULL );
- return ::CoCreateInstance( class_id, NULL, CLSCTX_INPROC_SERVER, __uuidof( COMInterface ), reinterpret_cast<void * *>( &baseCOMPtr_ ) );
- }
-
-private:
- COMInterface * baseCOMPtr_;
-};
-
-
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \class wic_factory
-///
-////////////////////////////////////////////////////////////////////////////////
-
-class wic_factory
-{
-public:
- static IWICImagingFactory & singleton()
- {
- BOOST_ASSERT_MSG( p_imaging_factory_, "WIC not initialized!" );
- return *p_imaging_factory_;
- }
-
- class creator : noncopyable
- {
- public:
- creator()
- {
- HRESULT hr( ::CoInitializeEx( 0, COINIT_MULTITHREADED | COINIT_DISABLE_OLE1DDE | COINIT_SPEED_OVER_MEMORY ) );
- if ( SUCCEEDED( hr ) )
- hr = wic_factory::p_imaging_factory_.create_instance( CLSID_WICImagingFactory );
-
- if ( FAILED( hr ) )
- io_error( "Boost.GIL failed to load external library." ); //...zzz...duplicated...
-
- BOOST_ASSERT( hr == S_OK );
- BOOST_ASSERT( wic_factory::p_imaging_factory_ );
- }
-
- ~creator()
- {
- wic_factory::p_imaging_factory_.release();
- ::CoUninitialize();
- }
- };
-
-private:
- static com_scoped_ptr<IWICImagingFactory> p_imaging_factory_;
-};
-
-// Implementation note:
-// GCC supports the __declspec( selectany ) declarator for Windows targets
-// so I'll avoid adding yet another template and assume that all other Windows
-// enabled compilers do too.
-// (10.10.2010.) (Domagoj Saric)
-__declspec( selectany )
-com_scoped_ptr<IWICImagingFactory> wic_factory::p_imaging_factory_;
-
-
-#if BOOST_LIB_INIT( BOOST_GIL_EXTERNAL_LIB ) == BOOST_LIB_INIT_ASSUME
-
- typedef wic_factory::creator wic_user_guard;
-
- struct wic_base_guard {};
-
-#else // BOOST_LIB_INIT( BOOST_GIL_EXTERNAL_LIB ) == BOOST_LIB_INIT_AUTO
-
- struct wic_user_guard {};
-
- typedef wic_factory::creator wic_base_guard;
-
-#endif // BOOST_LIB_INIT( BOOST_GIL_EXTERNAL_LIB ) == BOOST_LIB_INIT_AUTO
-
-//------------------------------------------------------------------------------
-} // namespace detail
-//------------------------------------------------------------------------------
-} // namespace io
-//------------------------------------------------------------------------------
-} // namespace gil
-//------------------------------------------------------------------------------
-} // namespace boost
-//------------------------------------------------------------------------------
-#endif // wic_extern_lib_guard_hpp

Modified: sandbox/gil/boost/gil/extension/io2/devices/device.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/devices/device.hpp (original)
+++ sandbox/gil/boost/gil/extension/io2/devices/device.hpp 2011-07-27 18:18:58 EDT (Wed, 27 Jul 2011)
@@ -17,7 +17,7 @@
 #define device_hpp__0B0D753B_4DAB_4EAF_8F73_780FF1D1F4D6
 #pragma once
 //------------------------------------------------------------------------------
-#include "detail/io_error.hpp"
+#include "boost/gil/extension/io2/detail/io_error.hpp"
 
 #include "boost/type_traits/is_convertible.hpp"
 //------------------------------------------------------------------------------

Modified: sandbox/gil/boost/gil/extension/io2/dynamic_image.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/dynamic_image.hpp (original)
+++ sandbox/gil/boost/gil/extension/io2/dynamic_image.hpp 2011-07-27 18:18:58 EDT (Wed, 27 Jul 2011)
@@ -1,9 +1,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \file formatted_image.hpp
-/// -------------------------
-///
-/// Base CRTP class for all image implementation classes/backends.
+/// \file dynamic_image_hpp
+/// -----------------------
 ///
 /// Copyright (c) Domagoj Saric 2010.-2011.
 ///

Modified: sandbox/gil/boost/gil/extension/io2/format_tags.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/format_tags.hpp (original)
+++ sandbox/gil/boost/gil/extension/io2/format_tags.hpp 2011-07-27 18:18:58 EDT (Wed, 27 Jul 2011)
@@ -3,7 +3,7 @@
 /// \file format_tags.hpp
 /// ---------------------
 ///
-/// Copyright (c) Domagoj Saric 2010.
+/// Copyright (c) Domagoj Saric 2010.-2011.
 ///
 /// Use, modification and distribution is subject to the Boost Software License, Version 1.0.
 /// (See accompanying file LICENSE_1_0.txt or copy at

Deleted: sandbox/gil/boost/gil/extension/io2/formatted_image.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/formatted_image.hpp 2011-07-27 18:18:58 EDT (Wed, 27 Jul 2011)
+++ (empty file)
@@ -1,247 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \file formatted_image.hpp
-/// -------------------------
-///
-/// Base CRTP class for all image implementation classes/backends.
-///
-/// Copyright (c) Domagoj Saric 2010.-2011.
-///
-/// Use, modification and distribution is subject to the Boost Software License, Version 1.0.
-/// (See accompanying file LICENSE_1_0.txt or copy at
-/// http://www.boost.org/LICENSE_1_0.txt)
-///
-/// For more information, see http://www.boost.org
-///
-////////////////////////////////////////////////////////////////////////////////
-//------------------------------------------------------------------------------
-#ifndef formatted_image_hpp__C34C1FB0_A4F5_42F3_9318_5805B88CFE49
-#define formatted_image_hpp__C34C1FB0_A4F5_42F3_9318_5805B88CFE49
-#pragma once
-//------------------------------------------------------------------------------
-#include "format_tags.hpp"
-#include "detail/platform_specifics.hpp"
-#include "detail/io_error.hpp"
-#include "detail/switch.hpp"
-
-#include "boost/gil/packed_pixel.hpp"
-#include "boost/gil/planar_pixel_iterator.hpp"
-#include "boost/gil/planar_pixel_reference.hpp"
-#include "boost/gil/typedefs.hpp"
-
-#include <boost/compressed_pair.hpp>
-#ifdef _DEBUG
-#include <boost/detail/endian.hpp>
-#endif // _DEBUG
-#include <boost/mpl/eval_if.hpp>
-#include <boost/mpl/for_each.hpp>
-#include <boost/mpl/integral_c.hpp>
-#include <boost/mpl/map.hpp>
-#include <boost/mpl/vector_c.hpp>
-#ifdef _DEBUG
-#include <boost/numeric/conversion/converter.hpp>
-#include <boost/numeric/conversion/converter_policies.hpp>
-#endif // _DEBUG
-#include <boost/range/iterator_range.hpp>
-#include <boost/static_assert.hpp>
-#include <boost/type_traits/decay.hpp>
-#include <boost/type_traits/is_unsigned.hpp>
-//------------------------------------------------------------------------------
-namespace boost
-{
-//------------------------------------------------------------------------------
-namespace gil
-{
-//------------------------------------------------------------------------------
-
-#if defined(BOOST_MSVC)
-# pragma warning( push )
-# pragma warning( disable : 4127 ) // "conditional expression is constant"
-#endif
-
-template <typename SrcChannelV, typename DstChannelV> // Model ChannelValueConcept
-struct channel_converter;
-
-// An integer version of the unsigned channel downsampling/quantizing 'overload'...
-template <typename SrcChannelV, int DestPackedNumBits>
-struct channel_converter<SrcChannelV, packed_channel_value<DestPackedNumBits> >
- : public std::unary_function<SrcChannelV, packed_channel_value<DestPackedNumBits> >
-{
- packed_channel_value<DestPackedNumBits> operator()( SrcChannelV const src ) const
- {
- typedef packed_channel_value<DestPackedNumBits> DstChannelV;
-
- typedef detail::channel_convert_to_unsigned <SrcChannelV> to_unsigned;
- typedef detail::channel_convert_from_unsigned<DstChannelV> from_unsigned;
-
- if ( is_unsigned<SrcChannelV>::value )
- {
- SrcChannelV const source_max( detail::unsigned_integral_max_value<SrcChannelV>::value );
- unsigned int const tmp ( ( static_cast<unsigned short>( src ) << DestPackedNumBits ) - src );
- typename DstChannelV::integer_t const result
- (
- static_cast<typename DstChannelV::integer_t>( tmp / source_max ) + ( ( tmp % source_max ) > ( source_max / 2 ) )
- );
- #ifdef _DEBUG
- unsigned char const destination_max( detail::unsigned_integral_max_value<DstChannelV>::value );
- DstChannelV const debug_result
- (
- numeric::converter<unsigned, double, numeric::conversion_traits<unsigned, double>, numeric::def_overflow_handler, numeric::RoundEven<double> >::convert
- (
- src * double( destination_max ) / double( source_max )
- )
- );
- BOOST_ASSERT( result == debug_result );
- #endif // _DEBUG
- return *gil_reinterpret_cast_c<DstChannelV const *>( &result );
- }
- else
- {
- typedef channel_converter_unsigned<typename to_unsigned::result_type, typename from_unsigned::argument_type> converter_unsigned;
- return from_unsigned()(converter_unsigned()(to_unsigned()(src)));
- }
- }
-};
-
-#if defined(BOOST_MSVC)
-# pragma warning( pop )
-#endif
-
-namespace io
-{
-//------------------------------------------------------------------------------
-
-////////////////////////////////////////////////////////////////////////////////
-/// \class formatted_image_traits
-/// ( forward declaration )
-////////////////////////////////////////////////////////////////////////////////
-
-template <class Impl>
-struct formatted_image_traits;
-
-template <class Backend, typename Source>
-struct reader_for;
-
-template <class Backend, typename Target>
-struct writer_for;
-
-namespace detail
-{
-//------------------------------------------------------------------------------
-
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \class formatted_image_base
-///
-////////////////////////////////////////////////////////////////////////////////
-
-class formatted_image_base : noncopyable
-{
-public: // Low-level (row, strip, tile) access
- struct sequential_row_read_state { BOOST_STATIC_CONSTANT( bool, throws_on_error = true ); };
-
- static sequential_row_read_state begin_sequential_row_read() { return sequential_row_read_state(); }
-
- static bool can_do_row_access () { return true ; }
- static bool can_do_strip_access() { return false; }
- static bool can_do_tile_access () { return false; }
-
- static bool can_do_roi_access () { return false; }
- static bool can_do_vertical_roi_access() { return true ; }
-
-public: //...zzz...
- template <typename View>
- static unsigned char * get_raw_data( View const & view )
- {
- // A private implementation of interleaved_view_get_raw_data() that
- // works with packed pixel views.
- BOOST_STATIC_ASSERT(( !is_planar<View>::value /*&& view_is_basic<View>::value*/ ));
- BOOST_STATIC_ASSERT(( is_pointer<typename View::x_iterator>::value ));
-
- return gil_reinterpret_cast<unsigned char *>( &gil::at_c<0>( view( 0, 0 ) ) );
- }
-
-protected:
- template <typename View>
- struct is_plain_in_memory_view
- :
- mpl::bool_
- <
- is_pointer<typename View::x_iterator>::value ||
- ( is_planar<View>::value && view_is_basic<View>::value )
- > {};
-
- template <typename ResultType>
- struct assert_default_case_not_reached
- {
- typedef ResultType result_type;
- template <typename Index>
- result_type operator()( Index const & ) const
- {
- BOOST_ASSERT( !"Default case must not have been reached!" );
- BF_UNREACHABLE_CODE
- return result_type();
- }
- };
-};
-
-
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \class formatted_image
-///
-////////////////////////////////////////////////////////////////////////////////
-
-template <class Impl>
-class formatted_image : public formatted_image_base
-{
-public:
- //typedef typename formatted_image_traits<Impl>::format_t format_t;
-
- typedef typename formatted_image_traits<Impl>::supported_pixel_formats_t supported_pixel_formats;
- typedef typename formatted_image_traits<Impl>::roi_t roi;
- typedef typename roi::offset_t offset_t;
-
- template <typename PixelType, bool IsPlanar>
- struct native_format
- : formatted_image_traits<Impl>::gil_to_native_format:: BOOST_NESTED_TEMPLATE apply<PixelType, IsPlanar>::type
- {};
-
- template <typename T> struct get_native_format;
-
- template <typename PixelType, typename IsPlanar>
- struct get_native_format<mpl::pair<PixelType, IsPlanar> > : native_format<PixelType, IsPlanar::value> {};
-
- template <typename PixelType, bool IsPlanar, class Allocator>
- struct get_native_format<image<PixelType, IsPlanar, Allocator> > : native_format<PixelType, IsPlanar> {};
-
- template <typename Locator>
- struct get_native_format<image_view<Locator> > : native_format<typename image_view<Locator>::value_type, is_planar<image_view<Locator> >::value> {};
-
- template <typename Source> struct reader_for : gil::io::reader_for<Impl, Source> {};
- template <typename Target> struct writer_for : gil::io::writer_for<Impl, Target> {};
-
- BOOST_STATIC_CONSTANT( bool, has_full_roi = (is_same<typename roi::offset_t, typename roi::point_t>::value) );
-
-protected:
- typedef formatted_image base_t;
-
- //typedef typename formatted_image_traits<Impl>::view_data_t view_data_t;
-
-private:
- // MSVC++ 10 generates code to check whether this == 0.
- Impl & impl() { BF_ASSUME( this != 0 ); return static_cast<Impl &>( *this ); }
- Impl const & impl() const { BF_ASSUME( this != 0 ); return static_cast<Impl const &>( *this ); }
-};
-
-
-//------------------------------------------------------------------------------
-} // namespace detail
-//------------------------------------------------------------------------------
-} // namespace io
-//------------------------------------------------------------------------------
-} // namespace gil
-//------------------------------------------------------------------------------
-} // namespace boost
-//------------------------------------------------------------------------------
-#endif // formatted_image_hpp

Deleted: sandbox/gil/boost/gil/extension/io2/libtiff_image.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/libtiff_image.hpp 2011-07-27 18:18:58 EDT (Wed, 27 Jul 2011)
+++ (empty file)
@@ -1,465 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \file libtiff_image.hpp
-/// -----------------------
-///
-/// Copyright (c) Domagoj Saric 2010.
-///
-/// Use, modification and distribution is subject to the Boost Software License, Version 1.0.
-/// (See accompanying file LICENSE_1_0.txt or copy at
-/// http://www.boost.org/LICENSE_1_0.txt)
-///
-/// For more information, see http://www.boost.org
-///
-////////////////////////////////////////////////////////////////////////////////
-//------------------------------------------------------------------------------
-#ifndef libtiff_image_hpp__0808D24E_CED1_4921_A832_3C12DAE93Ef7
-#define libtiff_image_hpp__0808D24E_CED1_4921_A832_3C12DAE93Ef7
-#pragma once
-//------------------------------------------------------------------------------
-#include "formatted_image.hpp"
-
-#include "detail/io_error.hpp"
-#include "detail/libx_shared.hpp"
-#include "detail/platform_specifics.hpp"
-#include "detail/shared.hpp"
-
-#if BOOST_MPL_LIMIT_VECTOR_SIZE < 35
- #error libtiff support requires mpl vectors of size 35 or greater...
-#endif
-
-#include <boost/array.hpp>
-#include <boost/mpl/set/set10.hpp>
-#include <boost/mpl/vector.hpp>
-#include <boost/smart_ptr/scoped_array.hpp>
-
-extern "C"
-{
- #include "tiff.h"
- #include "tiffio.h"
-}
-//------------------------------------------------------------------------------
-namespace boost
-{
-//------------------------------------------------------------------------------
-namespace gil
-{
-//------------------------------------------------------------------------------
-
-template <typename Pixel, bool IsPlanar, typename Alloc=std::allocator<unsigned char> >
-class image;
-
-namespace io
-{
-//------------------------------------------------------------------------------
-namespace detail
-{
-//------------------------------------------------------------------------------
-
-#define LIBTIFF_SPP( param ) ( ( param ) << ( 0 ) )
-#define LIBTIFF_BPS( param ) ( ( param ) << ( 0 + 3 ) )
-#define LIBTIFF_FMT( param ) ( ( param ) << ( 0 + 3 + 5 ) )
-#define LIBTIFF_PLANAR( param ) ( ( param ) << ( 0 + 3 + 5 + 3 ) )
-#define LIBTIFF_PHOTOMETRIC( param ) ( ( param ) << ( 0 + 3 + 5 + 3 + 2 ) )
-#define LIBTIFF_INKSET( param ) ( ( param ) << ( 0 + 3 + 5 + 3 + 2 + 3 ) )
-
-#define LIBTIFF_FORMAT( spp, bps, sample_format, planar_config, photometric_interpretation, inkset ) \
-( \
- LIBTIFF_SPP( spp ) | \
- LIBTIFF_BPS( bps ) | \
- LIBTIFF_FMT( sample_format ) | \
- LIBTIFF_PLANAR( planar_config ) | \
- LIBTIFF_PHOTOMETRIC( photometric_interpretation ) | \
- LIBTIFF_INKSET( inkset ) \
-)
-
-
-union full_format_t
-{
- struct format_bitfield
- {
- unsigned int samples_per_pixel : 3;
- unsigned int bits_per_sample : 5;
- unsigned int sample_format : 3;
- unsigned int planar_configuration : 2;
- unsigned int photometric : 3;
- unsigned int ink_set : 2;
- };
-
- typedef unsigned int format_id;
-
- format_id number;
- format_bitfield bits ;
-};
-
-
-template <typename Pixel, bool isPlanar>
-struct gil_to_libtiff_format
- :
- mpl::int_
- <
- LIBTIFF_FORMAT
- (
- num_channels<Pixel>::value,
- sizeof( typename channel_type<Pixel>::type ) * 8,
- (
- ( is_unsigned <typename channel_type<Pixel>::type>::value * SAMPLEFORMAT_UINT ) |
- ( is_signed <typename channel_type<Pixel>::type>::value * SAMPLEFORMAT_INT ) |
- ( is_floating_point<typename channel_type<Pixel>::type>::value * SAMPLEFORMAT_IEEEFP )
- ),
- isPlanar ? PLANARCONFIG_SEPARATE : PLANARCONFIG_CONTIG,
- (
- ( is_same<typename color_space_type<Pixel>::type, rgb_t >::value * PHOTOMETRIC_RGB ) |
- ( is_same<typename color_space_type<Pixel>::type, cmyk_t>::value * PHOTOMETRIC_SEPARATED ) |
- ( is_same<typename color_space_type<Pixel>::type, gray_t>::value * PHOTOMETRIC_MINISBLACK )
- ),
- ( is_same<typename color_space_type<Pixel>::type, cmyk_t>::value ? INKSET_CMYK : 0 )
- )
- >
-{};
-
-
-typedef mpl::vector35
-<
- image<rgb8_pixel_t , false>,
- image<rgb8_pixel_t , true >,
- image<rgba8_pixel_t, false>,
- image<rgba8_pixel_t, true >,
- image<cmyk8_pixel_t, false>,
- image<cmyk8_pixel_t, true >,
- image<gray8_pixel_t, false>,
-
- image<rgb16_pixel_t , false>,
- image<rgb16_pixel_t , true >,
- image<rgba16_pixel_t, false>,
- image<rgba16_pixel_t, true >,
- image<cmyk16_pixel_t, false>,
- image<cmyk16_pixel_t, true >,
- image<gray16_pixel_t, false>,
-
- image<rgb8s_pixel_t , false>,
- image<rgb8s_pixel_t , true >,
- image<rgba8s_pixel_t, false>,
- image<rgba8s_pixel_t, true >,
- image<cmyk8s_pixel_t, false>,
- image<cmyk8s_pixel_t, true >,
- image<gray8s_pixel_t, false>,
-
- image<rgb16s_pixel_t , false>,
- image<rgb16s_pixel_t , true >,
- image<rgba16s_pixel_t, false>,
- image<rgba16s_pixel_t, true >,
- image<cmyk16s_pixel_t, false>,
- image<cmyk16s_pixel_t, true >,
- image<gray16s_pixel_t, false>,
-
- image<rgb32f_pixel_t , false>,
- image<rgb32f_pixel_t , true >,
- image<rgba32f_pixel_t, false>,
- image<rgba32f_pixel_t, true >,
- image<cmyk32f_pixel_t, false>,
- image<cmyk32f_pixel_t, true >,
- image<gray32f_pixel_t, false>
-> libtiff_supported_pixel_formats;
-
-
-template <typename Handle>
-toff_t seek( thandle_t const handle, toff_t const off, int const whence )
-{
- return static_cast<tsize_t>( input_device<Handle>::seek( static_cast<device_base::seek_origin>( whence ), off, reinterpret_cast<Handle>( handle ) ) );
-}
-
-template <typename Handle>
-int close( thandle_t const handle )
-{
- input_device<Handle>::close( reinterpret_cast<Handle>( handle ) );
- return 0;
-}
-
-inline int nop_close( thandle_t /*handle*/ )
-{
- return 0;
-}
-
-template <typename Handle>
-toff_t size( thandle_t const fd )
-{
- return static_cast<toff_t>( input_device<Handle>::size( reinterpret_cast<Handle>( handle ) ) );
-}
-
-
-inline tsize_t memory_read_proc( thandle_t /*handle*/, tdata_t /*buf*/, tsize_t /*size*/ )
-{
- BF_UNREACHABLE_CODE
- return 0;
-}
-
-inline tsize_t memory_write_proc( thandle_t /*handle*/, tdata_t /*buf*/, tsize_t /*size*/ )
-{
- BF_UNREACHABLE_CODE
- return 0;
-}
-
-inline toff_t memory_seek_proc( thandle_t /*handle*/, toff_t /*off*/, int /*whence*/ )
-{
- BF_UNREACHABLE_CODE
- return 0;
-}
-
-inline int memory_close_proc( thandle_t /*handle*/ )
-{
- return 0;
-}
-
-inline toff_t memory_size_proc( thandle_t /*handle*/ )
-{
- BF_UNREACHABLE_CODE
- return 0;
-}
-
-inline int memory_map_proc( thandle_t const handle, tdata_t * const pbase, toff_t * const psize )
-{
- BOOST_ASSERT( handle );
- BOOST_ASSERT( pbase );
- BOOST_ASSERT( psize );
- //...zzz...
- //*pbase = static_cast<tdata_t>( const_cast<memory_range_t::value_type *>( gil_reinterpret_cast<memory_range_t *>( handle )->begin() ) );
- //*psize = gil_reinterpret_cast<memory_range_t *>( handle )->size ();
- return false;
-}
-
-
-#if defined(BOOST_MSVC)
-# pragma warning( push )
-# pragma warning( disable : 4127 ) // "conditional expression is constant"
-#endif
-
-struct tiff_view_data_t
-{
- template <class View>
- explicit tiff_view_data_t( View const & view, generic_vertical_roi::offset_t const offset = 0 )
- :
- dimensions_( view.dimensions() ),
- stride_ ( view.pixels().row_size() ),
- offset_ ( offset )
- #ifdef _DEBUG
- ,format_id_( gil_to_libtiff_format<typename View::value_type, is_planar<View>::value>::value )
- #endif
- {
- set_buffers( view, is_planar<View>() );
- }
-
- void set_format( full_format_t::format_id const format )
- {
- #ifdef _DEBUG
- BOOST_ASSERT( ( format_id_ == format ) && !"libtiff does not provide builtin conversion." );
- #endif // _DEBUG
- ignore_unused_variable_warning( format );
- }
-
- point2<std::ptrdiff_t> const & dimensions_ ;
- unsigned int stride_ ;
- unsigned int number_of_planes_;
- array<unsigned char *, 4> plane_buffers_ ;
- generic_vertical_roi::offset_t offset_ ;
-
- #ifdef _DEBUG
- unsigned int format_id_;
- #endif
-
-private: // this should probably go to the base formatted_image class...
- template <class View>
- void set_buffers( View const & view, mpl::true_ /*is planar*/ )
- {
- for ( number_of_planes_ = 0; number_of_planes_ < num_channels<View>::value; ++number_of_planes_ )
- {
- plane_buffers_[ number_of_planes_ ] = gil_reinterpret_cast<unsigned char *>( planar_view_get_raw_data( view, number_of_planes_ ) );
- }
- BOOST_ASSERT( number_of_planes_ == num_channels<View>::value );
- }
-
- template <class View>
- void set_buffers( View const & view, mpl::false_ /*is not planar*/ )
- {
- number_of_planes_ = 1;
- plane_buffers_[ 0 ] = formatted_image_base::get_raw_data( view );
- }
-
- void operator=( tiff_view_data_t const & );
-};
-
-struct tiff_writer_view_data_t;
-
-//------------------------------------------------------------------------------
-} // namespace detail
-
-class libtiff_image;
-
-template <>
-struct formatted_image_traits<libtiff_image>
-{
- typedef detail::full_format_t::format_id format_t;
-
- typedef detail::libtiff_supported_pixel_formats supported_pixel_formats_t;
-
- typedef detail::generic_vertical_roi roi_t;
-
- typedef detail::tiff_view_data_t view_data_t;
-
- struct gil_to_native_format
- {
- template <typename Pixel, bool IsPlanar>
- struct apply : detail::gil_to_libtiff_format<Pixel, IsPlanar> {};
- };
-
- template <typename Pixel, bool IsPlanar>
- struct is_supported : mpl::true_ {}; //...zzz...
-
- typedef mpl::set1
- <
- char const *
- > native_sources;
-
- typedef mpl::set1
- <
- char const *
- > native_sinks;
-
- typedef mpl::vector1_c<format_tag, tiff> supported_image_formats;
-
- typedef detail::tiff_writer_view_data_t writer_view_data_t;
-
- BOOST_STATIC_CONSTANT( unsigned int, desired_alignment = sizeof( void * ) );
- BOOST_STATIC_CONSTANT( bool , builtin_conversion = false );
-};
-
-
-class libtiff_image
- :
- public detail::formatted_image<libtiff_image>
-{
-public:
- struct guard {};
-
- class native_reader;
- class native_writer;
-
- typedef native_reader device_reader;
- typedef native_writer device_writer;
-
-public:
- TIFF & lib_object() const { BOOST_ASSERT( p_tiff_ ); return *p_tiff_; }
-
-protected:
- libtiff_image( char const * const file_name, char const * const access_mode )
- :
- p_tiff_( ::TIFFOpen( file_name, access_mode ) )
- {
- BOOST_ASSERT( file_name );
- construction_check();
- }
-
- template <typename DeviceHandle>
- explicit libtiff_image
- (
- DeviceHandle const handle,
- TIFFReadWriteProc const read_proc,
- TIFFReadWriteProc const write_proc,
- TIFFMapFileProc const map_proc,
- TIFFUnmapFileProc const unmap_proc
- )
- :
- p_tiff_
- (
- ::TIFFClientOpen
- (
- "", "", //"M"
- reinterpret_cast<thandle_t>( handle ),
- read_proc,
- write_proc,
- &detail::seek<DeviceHandle>,
- &detail::nop_close, //&detail::close<<DeviceHandle>>
- &detail::size<<DeviceHandle>,
- map_proc,
- unmap_proc
- )
- )
- {
- construction_check();
- }
-
- BF_NOTHROW ~libtiff_image()
- {
- ::TIFFClose( &lib_object() );
- }
-
-private:
- typedef detail::full_format_t full_format_t;
-
-public:
- point2<std::ptrdiff_t> dimensions() const
- {
- return point2<std::ptrdiff_t>( get_field<uint32>( TIFFTAG_IMAGEWIDTH ), get_field<uint32>( TIFFTAG_IMAGELENGTH ) );
- }
-
-protected:
- template <typename T>
- T get_field( ttag_t const tag ) const
- {
- // Implementation note:
- // Vararg functions are a brickwall to most compilers so try and avoid
- // them when possible.
- // (20.07.2011.) (Domagoj Saric)
- T value;
- #ifdef _MSC_VER
- T * p_value( &value );
- BOOST_VERIFY( ::TIFFVGetFieldDefaulted( &lib_object(), tag, reinterpret_cast<va_list>( &p_value ) ) );
- #else
- BOOST_VERIFY( ::TIFFGetFieldDefaulted ( &lib_object(), tag, &value ) );
- #endif // _MSC_VER
- return value;
- }
-
- template <typename T1, typename T2>
- std::pair<T1, T2> get_field( ttag_t const tag, int & cumulative_result ) const
- {
- std::pair<T1, T2> value;
- cumulative_result &= ::TIFFGetFieldDefaulted( &lib_object(), tag, &value.first, &value.second );
- return value;
- }
-
- static std::size_t cached_format_size( formatted_image_traits<libtiff_image>::format_t const format )
- {
- full_format_t::format_bitfield const & bits( reinterpret_cast<full_format_t const &>( format ).bits );
- return bits.bits_per_sample * ( ( bits.planar_configuration == PLANARCONFIG_CONTIG ) ? bits.samples_per_pixel : 1 ) / 8;
- }
-
-protected:
- class cumulative_result : public detail::cumulative_result
- {
- public:
- void throw_if_error() const { detail::cumulative_result::throw_if_error( "Error reading TIFF file" ); }
- };
-
-private:
- void construction_check() const
- {
- detail::io_error_if_not( p_tiff_, "Failed to create a LibTIFF object." );
- }
-
-private:
- TIFF * const p_tiff_;
-};
-
-#if defined(BOOST_MSVC)
-# pragma warning( pop )
-#endif
-
-//------------------------------------------------------------------------------
-} // namespace io
-//------------------------------------------------------------------------------
-} // namespace gil
-//------------------------------------------------------------------------------
-} // namespace boost
-//------------------------------------------------------------------------------
-#endif // libtiff_image_hpp

Deleted: sandbox/gil/boost/gil/extension/io2/libtiff_reader.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/libtiff_reader.hpp 2011-07-27 18:18:58 EDT (Wed, 27 Jul 2011)
+++ (empty file)
@@ -1,853 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \file libtiff_reader.hpp
-/// ------------------------
-///
-/// Copyright (c) Domagoj Saric 2010.-2011.
-///
-/// Use, modification and distribution is subject to the Boost Software License, Version 1.0.
-/// (See accompanying file LICENSE_1_0.txt or copy at
-/// http://www.boost.org/LICENSE_1_0.txt)
-///
-/// For more information, see http://www.boost.org
-///
-////////////////////////////////////////////////////////////////////////////////
-//------------------------------------------------------------------------------
-#ifndef libtiff_reader_hpp__24E9D122_DAC7_415B_8880_9BFA03916E9F
-#define libtiff_reader_hpp__24E9D122_DAC7_415B_8880_9BFA03916E9F
-#pragma once
-//------------------------------------------------------------------------------
-#include "backend_reader.hpp"
-#include "libtiff_image.hpp"
-
-#include "detail/io_error.hpp"
-#include "detail/libx_shared.hpp"
-#include "detail/platform_specifics.hpp"
-#include "detail/shared.hpp"
-
-#include "boost/gil/image_view_factory.hpp"
-
-#include <boost/array.hpp>
-#include <boost/mpl/vector.hpp>
-#include <boost/smart_ptr/scoped_array.hpp>
-
-extern "C"
-{
- #include "tiff.h"
- #include "tiffio.h"
-}
-//------------------------------------------------------------------------------
-namespace boost
-{
-//------------------------------------------------------------------------------
-namespace gil
-{
-//------------------------------------------------------------------------------
-namespace io
-{
-//------------------------------------------------------------------------------
-namespace detail
-{
-//------------------------------------------------------------------------------
-
-template <typename Handle>
-tsize_t read( thandle_t const handle, tdata_t const buf, tsize_t const size )
-{
- return static_cast<tsize_t>( input_device<Handle>::read( buf, size, reinterpret_cast<Handle>( handle ) ) );
-}
-
-template <typename Handle>
-int map( thandle_t /*handle*/, tdata_t * /*pbase*/, toff_t * /*psize*/ )
-{
- return false;
-}
-
-template <typename Handle>
-void unmap( thandle_t /*handle*/, tdata_t /*base*/, toff_t /*size*/ )
-{
-}
-
-//------------------------------------------------------------------------------
-} // namespace detail
-
-
-class libtiff_image::native_reader
- :
- public libtiff_image,
- public detail::backend_reader<libtiff_image>
-{
-public: /// \ingroup Construction
- explicit native_reader( char const * const file_name )
- :
- libtiff_image( file_name, "r" ),
- format_ ( get_format() )
- {}
-
- template <typename DeviceHandle>
- explicit native_reader( DeviceHandle const handle )
- :
- libtiff_image
- (
- handle,
- &input_device<DeviceHandle>::read,
- NULL,
- NULL,
- NULL
- ),
- format_( get_format() )
- {}
-
-public:
- format_t const & format () const { return format_.number; }
- format_t const & closest_gil_supported_format() const { return format() ; }
-
-public: // Low-level (row, strip, tile) access
- bool can_do_row_access () const { return !can_do_tile_access(); }
- bool can_do_strip_access() const { return /*...yet to implement...can_do_row_access();*/ false; }
- bool can_do_tile_access () const { return ::TIFFIsTiled( &lib_object() ) != 0; }
-
- std::size_t tile_size () const { return ::TIFFTileSize ( &lib_object() ); }
- std::size_t tile_row_size() const { return ::TIFFTileRowSize( &lib_object() ); }
- point2<std::ptrdiff_t> tile_dimensions() const
- {
- BOOST_ASSERT( can_do_tile_access() );
- return point2<std::ptrdiff_t>
- (
- get_field<uint32>( TIFFTAG_TILEWIDTH ),
- get_field<uint32>( TIFFTAG_TILELENGTH )
- );
- }
-
- class sequential_row_read_state
- :
- private libtiff_image::cumulative_result
- {
- public:
- using libtiff_image::cumulative_result::failed;
- using libtiff_image::cumulative_result::throw_if_error;
-
- BOOST_STATIC_CONSTANT( bool, throws_on_error = false );
-
- private: friend class libtiff_image::native_reader;
- sequential_row_read_state() : position_( 0 ) {}
-
- unsigned int position_;
- };
-
-
- static sequential_row_read_state begin_sequential_row_read() { return sequential_row_read_state(); }
-
- void read_row( sequential_row_read_state & state, unsigned char * const p_row_storage, unsigned int const plane = 0 ) const
- {
- state.accumulate_greater
- (
- ::TIFFReadScanline( &lib_object(), p_row_storage, state.position_++, static_cast<tsample_t>( plane ) ),
- 0
- );
- }
-
-
- typedef sequential_row_read_state sequential_tile_read_state;
-
- static sequential_tile_read_state begin_sequential_tile_access() { return begin_sequential_row_read(); }
-
- void read_tile( sequential_row_read_state & state, unsigned char * const p_tile_storage ) const
- {
- state.accumulate_greater
- (
- ::TIFFReadEncodedTile( &lib_object(), state.position_++, p_tile_storage, -1 ),
- 0
- );
- }
-
-private:
- full_format_t get_format()
- {
- int cumulative_result( true );
-
- unsigned const samples_per_pixel ( get_field<uint16>( TIFFTAG_SAMPLESPERPIXEL ) );
- unsigned const bits_per_sample ( get_field<uint16>( TIFFTAG_BITSPERSAMPLE ) );
- unsigned const sample_format ( get_field<uint16>( TIFFTAG_SAMPLEFORMAT ) );
- unsigned const planar_configuration( get_field<uint16>( TIFFTAG_PLANARCONFIG ) );
- unsigned const photometric ( get_field<uint16>( TIFFTAG_PHOTOMETRIC ) );
- unsigned const orientation ( get_field<uint16>( TIFFTAG_ORIENTATION ) );
-
- unsigned ink_set( 0 );
- bool unsupported_format( false );
- if ( samples_per_pixel == 4 )
- {
- switch ( photometric )
- {
- case PHOTOMETRIC_RGB:
- {
- std::pair<uint16, uint16 *> const extrasamples( get_field<uint16, uint16 *>( TIFFTAG_EXTRASAMPLES, cumulative_result ) );
- unsupported_format = ( extrasamples.first != 1 || *extrasamples.second != EXTRASAMPLE_UNASSALPHA );
- break;
- }
-
- case PHOTOMETRIC_SEPARATED:
- {
- ink_set = get_field<uint16>( TIFFTAG_INKSET );
- unsupported_format = ( ink_set != INKSET_CMYK );
- break;
- }
-
- default:
- unsupported_format = true;
- }
- }
-
- detail::io_error_if( !cumulative_result || unsupported_format || ( orientation != ORIENTATION_TOPLEFT ), "Unsupported TIFF format" );
-
- full_format_t const result =
- {
- LIBTIFF_FORMAT( samples_per_pixel, bits_per_sample, ( sample_format == SAMPLEFORMAT_VOID ) ? SAMPLEFORMAT_UINT : sample_format, planar_configuration, photometric, ink_set )
- };
- return result;
- }
-
-private:
- detail::full_format_t::format_bitfield const & format_bits() const { return format_.bits; }
-
- static unsigned int round_up_divide( unsigned int const dividend, unsigned int const divisor )
- {
- return ( dividend + divisor - 1 ) / divisor;
- }
-
-private: // Private formatted_image_base interface.
- // Implementation note:
- // MSVC 10 accepts friend base_t and friend class base_t, Clang 2.8
- // accepts friend class base_t, Apple Clang 1.6 and GCC (4.2 and 4.6) accept
- // neither.
- // (13.01.2011.) (Domagoj Saric)
- friend class detail::formatted_image<libtiff_image::native_reader>;
-
- struct tile_setup_t
- #ifndef __GNUC__
- : boost::noncopyable
- #endif // __GNUC__
- {
- tile_setup_t( native_reader const & source, point2<std::ptrdiff_t> const & dimensions, offset_t const offset, bool const nptcc )
- :
- tile_height ( source.get_field<uint32>( TIFFTAG_TILELENGTH ) ),
- tile_width ( source.get_field<uint32>( TIFFTAG_TILEWIDTH ) ),
- row_tiles ( source.get_field<uint32>( TIFFTAG_IMAGEWIDTH ) / tile_width ),
- size_of_pixel ( ( source.format_bits().planar_configuration == PLANARCONFIG_CONTIG ? source.format_bits().samples_per_pixel : 1 ) * source.format_bits().bits_per_sample / 8 ),
- tile_width_bytes ( tile_width * size_of_pixel ),
- tile_size_bytes ( tile_width_bytes * tile_height ),
- p_tile_buffer ( new unsigned char[ tile_size_bytes * ( nptcc ? source.format_bits().samples_per_pixel : 1 ) ] ),
- last_row_tile_width ( modulo_unless_zero( dimensions.x, tile_width ) /*dimensions.x % tile_width*/ ),
- tiles_per_row ( ( dimensions.x / tile_width ) + /*( last_row_tile_width != 0 )*/ ( ( dimensions.x % tile_width ) != 0 ) ),
- last_row_tile_width_bytes ( last_row_tile_width * size_of_pixel ),
- last_row_tile_size_bytes ( last_row_tile_width_bytes * tile_height ),
- current_row_tiles_remaining( tiles_per_row ),
- starting_tile ( offset / tile_height * tiles_per_row ),
- rows_to_skip ( offset % tile_height ),
- number_of_tiles ( round_up_divide( dimensions.y, tile_height ) * tiles_per_row * ( source.format_bits().planar_configuration == PLANARCONFIG_SEPARATE ? source.format_bits().samples_per_pixel : 1 ) )
- {
- BOOST_ASSERT( static_cast<tsize_t>( tile_width_bytes ) == ::TIFFTileRowSize( &source.lib_object() ) );
- BOOST_ASSERT( static_cast<tsize_t>( tile_size_bytes ) == ::TIFFTileSize ( &source.lib_object() ) );
- BOOST_ASSERT( starting_tile + number_of_tiles <= ::TIFFNumberOfTiles( &source.lib_object() ) );
- if ( tile_height > static_cast<uint32>( dimensions.y ) )
- {
- rows_to_read_per_tile = end_rows_to_read = dimensions.y;
- }
- else
- {
- end_rows_to_read = modulo_unless_zero( dimensions.y - ( tile_height - rows_to_skip ), tile_height );
- bool const starting_at_last_row( ( number_of_tiles - starting_tile ) <= tiles_per_row );
- rows_to_read_per_tile = starting_at_last_row ? end_rows_to_read : tile_height;
- }
- }
-
- uint32 const tile_height;
- uint32 const tile_width ;
- uint32 const row_tiles ;
-
- unsigned int const size_of_pixel ;
- size_t const tile_width_bytes;
- tsize_t const tile_size_bytes ;
-
- scoped_array<unsigned char> p_tile_buffer;
-
- unsigned int const last_row_tile_width ;
- unsigned int const tiles_per_row ;
- unsigned int const last_row_tile_width_bytes ;
- unsigned int const last_row_tile_size_bytes ;
- unsigned int current_row_tiles_remaining;
- ttile_t const starting_tile ;
- unsigned int rows_to_skip ;
- ttile_t const number_of_tiles ;
- unsigned int /*const*/ end_rows_to_read ;
- unsigned int rows_to_read_per_tile ;
-
- private:
- static unsigned int modulo_unless_zero( unsigned int const dividend, unsigned int const divisor )
- {
- unsigned int const modulo( dividend % divisor );
- return ( modulo != 0 ) ? modulo : divisor;
- }
- };
-
- struct skip_row_results_t
- {
- unsigned int rows_per_strip;
- unsigned int rows_to_read_using_scanlines;
- unsigned int starting_strip;
- };
-
- void raw_copy_to_prepared_view( view_data_t const & view_data ) const
- {
- cumulative_result result;
-
- if ( can_do_tile_access() )
- {
- tile_setup_t setup( *this, view_data.dimensions_, view_data.offset_, false );
-
- ttile_t current_tile( 0 );
-
- for ( unsigned int plane( 0 ); plane < view_data.number_of_planes_; ++plane )
- {
- unsigned char * p_target( view_data.plane_buffers_[ plane ] );
- for ( current_tile += setup.starting_tile; current_tile < setup.number_of_tiles; ++current_tile )
- {
- bool const last_row_tile ( !--setup.current_row_tiles_remaining );
- unsigned int const this_tile_width_bytes( last_row_tile ? setup.last_row_tile_width_bytes : setup.tile_width_bytes );
-
- result.accumulate_equal( ::TIFFReadEncodedTile( &lib_object(), current_tile, setup.p_tile_buffer.get(), setup.tile_size_bytes ), setup.tile_size_bytes );
- unsigned char const * p_tile_buffer_location( setup.p_tile_buffer.get() + ( setup.rows_to_skip * this_tile_width_bytes ) );
- unsigned char * p_target_local ( p_target );
- for ( unsigned int row( setup.rows_to_skip ); row < setup.rows_to_read_per_tile; ++row )
- {
- std::memcpy( p_target_local, p_tile_buffer_location, this_tile_width_bytes );
- memunit_advance( p_tile_buffer_location, setup.tile_width_bytes );
- memunit_advance( p_target_local , view_data.stride_ );
- }
- memunit_advance( p_target, this_tile_width_bytes );
- if ( last_row_tile )
- {
- p_target += ( ( setup.rows_to_read_per_tile - 1 - setup.rows_to_skip ) * view_data.stride_ );
- setup.rows_to_skip = 0;
- setup.current_row_tiles_remaining = setup.tiles_per_row;
- bool const next_row_is_last_row( ( setup.number_of_tiles - ( current_tile + 1 ) ) == setup.tiles_per_row );
- if ( next_row_is_last_row )
- setup.rows_to_read_per_tile = setup.end_rows_to_read;
- }
- //BOOST_ASSERT( p_tile_buffer_location == ( setup.p_tile_buffer.get() + this_tile_size_bytes ) || ( setup.rows_to_read_per_tile != setup.tile_height ) );
- BOOST_ASSERT( p_target <= view_data.plane_buffers_[ plane ] + ( view_data.stride_ * view_data.dimensions_.y ) );
- }
- BOOST_ASSERT( p_target == view_data.plane_buffers_[ plane ] + ( view_data.stride_ * view_data.dimensions_.y ) );
- }
- }
- else
- {
- BOOST_ASSERT( ::TIFFScanlineSize( &lib_object() ) <= static_cast<tsize_t>( view_data.stride_ ) );
- for ( unsigned int plane( 0 ); plane < view_data.number_of_planes_; ++plane )
- {
- unsigned char * buf( view_data.plane_buffers_[ plane ] );
- skip_row_results_t skip_result( skip_to_row( view_data.offset_, plane, buf, result ) );
- ttile_t const number_of_strips( ( view_data.dimensions_.y - skip_result.rows_to_read_using_scanlines + skip_result.rows_per_strip - 1 ) / skip_result.rows_per_strip );
- skip_result.rows_to_read_using_scanlines = std::min<unsigned int>( skip_result.rows_to_read_using_scanlines, view_data.dimensions_.y );
-
- unsigned int row( view_data.offset_ );
- while ( row != ( view_data.offset_ + skip_result.rows_to_read_using_scanlines ) )
- {
- result.accumulate_greater( ::TIFFReadScanline( &lib_object(), buf, row++, static_cast<tsample_t>( plane ) ), 0 );
- buf += view_data.stride_;
- }
-
- unsigned int const view_strip_increment( view_data.stride_ * skip_result.rows_per_strip );
- if ( view_strip_increment == static_cast<unsigned int>( ::TIFFStripSize( &lib_object() ) ) )
- {
- for ( unsigned int strip( skip_result.starting_strip ); strip < number_of_strips; ++strip )
- {
- result.accumulate_greater( ::TIFFReadEncodedStrip( &lib_object(), strip, buf, view_strip_increment ), 0 );
- buf += view_strip_increment;
- row += skip_result.rows_per_strip;
- }
- }
-
- unsigned int const target_row( view_data.offset_ + view_data.dimensions_.y );
- while ( row < target_row )
- {
- result.accumulate_greater( ::TIFFReadScanline( &lib_object(), buf, row++, static_cast<tsample_t>( plane ) ), 0 );
- buf += view_data.stride_;
- }
- }
- }
-
- result.throw_if_error();
- }
-
-
- ////////////////////////////////////////////////////////////////////////////
- //
- // generic_convert_to_prepared_view()
- // ----------------------------------
- //
- ////////////////////////////////////////////////////////////////////////////
- ///
- /// \todo Cleanup, document, split up and refactor this humongous monster
- /// (remove duplication, extract non-template and shared functionality...).
- /// (16.09.2010.) (Domagoj Saric)
- ///
- ////////////////////////////////////////////////////////////////////////////
-
- #if defined(BOOST_MSVC)
- # pragma warning( push )
- # pragma warning( disable : 4127 ) // "conditional expression is constant"
- #endif
-
- template <class MyView, class TargetView, class Converter>
- void generic_convert_to_prepared_view( TargetView const & view, Converter const & converter ) const
- {
- using namespace detail;
-
- typedef typename get_original_view_t<TargetView>::type original_target_view_t;
-
- typedef typename mpl::eval_if
- <
- is_planar<MyView>,
- nth_channel_view_type<original_target_view_t>,
- get_original_view_t<TargetView>
- >::type local_target_view_t;
- typedef typename get_original_view_t<local_target_view_t>::type::x_iterator target_x_iterator;
- typedef typename get_original_view_t<local_target_view_t>::type::y_iterator target_y_iterator;
-
- typedef typename mpl::eval_if
- <
- is_planar<MyView>,
- nth_channel_view_type<MyView>,
- mpl::identity<MyView>
- >::type::value_type my_pixel_t;
-
- typedef mpl::bool_
- <
- is_planar<MyView >::value &&
- !is_planar<original_target_view_t>::value &&
- (
- !is_same<typename color_space_type <MyView>::type, typename color_space_type <original_target_view_t>::type>::value ||
- !is_same<typename channel_mapping_type<MyView>::type, typename channel_mapping_type<original_target_view_t>::type>::value
- )
- > nondirect_planar_to_contig_conversion_t;
-
- cumulative_result result;
-
- typedef mpl::int_<is_planar<MyView>::value ? num_channels<MyView>::value : 1> number_of_planes_t;
-
- dimensions_t const & dimensions( original_view( view ).dimensions() );
-
- ////////////////////////////////////////////////////////////////////////
- // Tiled
- ////////////////////////////////////////////////////////////////////////
-
- if ( ::TIFFIsTiled( &lib_object() ) )
- {
- tile_setup_t setup
- (
- *this,
- dimensions,
- get_offset<offset_t>( view ),
- nondirect_planar_to_contig_conversion_t::value
- );
-
- unsigned int const tiles_per_plane( setup.number_of_tiles / number_of_planes_t::value );
- ttile_t current_tile ( 0 );
-
- if ( nondirect_planar_to_contig_conversion_t::value )
- {
- // For NPTCC there is no need for target view
- // planar<->non-planar adjustment because here we read whole
- // pixels before copying to the target view...
- typename original_target_view_t::y_iterator p_target( original_view( view ).y_at( 0, 0 ) );
-
- typename MyView::x_iterator const buffer_iterator
- (
- make_planar_buffer_iterator<typename MyView::x_iterator>
- (
- setup.p_tile_buffer.get(),
- setup.tile_size_bytes,
- number_of_planes_t()
- )
- );
-
- unsigned int horizontal_offset( 0 );
-
- for ( current_tile += setup.starting_tile; current_tile < tiles_per_plane; ++current_tile )
- {
- bool const last_row_tile ( !--setup.current_row_tiles_remaining );
- unsigned int const this_tile_width( last_row_tile ? setup.last_row_tile_width : setup.tile_width );
-
- for ( unsigned int channel_tile( 0 ); channel_tile < number_of_planes_t::value; ++channel_tile )
- {
- ttile_t const raw_tile_number( current_tile + ( channel_tile * tiles_per_plane ) );
- result.accumulate_equal
- (
- ::TIFFReadEncodedTile
- (
- &lib_object(),
- raw_tile_number,
- //buffer_iterator.at_c_dynamic( channel_tile ),
- &(*buffer_iterator)[ channel_tile ],
- setup.tile_size_bytes
- ),
- setup.tile_size_bytes
- );
- }
-
- typename MyView ::x_iterator p_source_pixel( buffer_iterator + ( setup.rows_to_skip * this_tile_width ) );
- typename original_target_view_t::x_iterator p_target_pixel( p_target.base() + horizontal_offset );
- for ( unsigned int row( setup.rows_to_skip ); row < setup.rows_to_read_per_tile; ++row )
- {
- typename MyView::x_iterator const local_end( p_source_pixel + this_tile_width );
- while ( p_source_pixel < local_end )
- {
- converter( *p_source_pixel, *p_target_pixel );
- ++p_source_pixel;
- ++p_target_pixel;
- }
- BOOST_ASSERT( p_source_pixel == local_end );
- p_source_pixel += setup.tile_width - this_tile_width;
- memunit_advance( p_target_pixel, original_view( view ).pixels().row_size() );
- p_target_pixel -= this_tile_width;
- }
- if ( last_row_tile )
- {
- p_target += ( setup.rows_to_read_per_tile /*- 1*/ - setup.rows_to_skip );
- setup.rows_to_skip = 0;
- setup.current_row_tiles_remaining = setup.tiles_per_row;
- bool const next_row_is_last_row( ( tiles_per_plane - ( current_tile + 1 ) ) == setup.tiles_per_row );
- if ( next_row_is_last_row )
- setup.rows_to_read_per_tile = setup.end_rows_to_read;
- }
- else
- horizontal_offset += setup.tile_width;
- //...make NPTCC version...BOOST_ASSERT( p_source_pixel == reinterpret_cast<my_pixel_t const *>( setup.p_tile_buffer.get() + this_tile_size_bytes ) || ( setup.rows_to_read_per_tile != setup.tile_height ) );
- BOOST_ASSERT( p_target <= original_view( view ).col_end( 0 ) );
- }
- BOOST_ASSERT( p_target == original_view( view ).col_end( 0 ) );
- }
- else // non NPTCC...
- {
- for
- (
- unsigned int plane( 0 ), current_plane_end_tile( tiles_per_plane );
- plane < number_of_planes_t::value;
- ++plane, current_plane_end_tile += tiles_per_plane
- )
- {
- local_target_view_t const & target_view( adjust_target_to_my_view( original_view( view ), plane, is_planar<MyView>() ) );
- target_y_iterator p_target( target_view.y_at( 0, 0 ) );
- BOOST_ASSERT( p_target.step() == original_view( view ).pixels().row_size() );
-
- unsigned int horizontal_offset ( 0 );
- unsigned int current_plane_rows_to_read_per_tile( setup.rows_to_read_per_tile );
- unsigned int current_plane_rows_to_skip ( setup.rows_to_skip );
-
- for ( current_tile += setup.starting_tile; current_tile < current_plane_end_tile; ++current_tile )
- {
- bool const last_row_tile ( !--setup.current_row_tiles_remaining );
- //unsigned int const this_tile_size_bytes ( last_row_tile ? setup.last_row_tile_size_bytes : setup.tile_size_bytes );
- unsigned int const this_tile_width_bytes( last_row_tile ? setup.last_row_tile_width_bytes : setup.tile_width_bytes );
-
- result.accumulate_equal( ::TIFFReadEncodedTile( &lib_object(), current_tile, setup.p_tile_buffer.get(), setup.tile_size_bytes ), setup.tile_size_bytes );
-
- my_pixel_t const * p_source_pixel( gil_reinterpret_cast_c<my_pixel_t const *>( setup.p_tile_buffer.get() + ( current_plane_rows_to_skip * this_tile_width_bytes ) ) );
- target_x_iterator p_target_pixel( p_target.base() + horizontal_offset );
- for ( unsigned int row( current_plane_rows_to_skip ); row < current_plane_rows_to_read_per_tile; ++row )
- {
- my_pixel_t const * const local_end( memunit_advanced( p_source_pixel, this_tile_width_bytes ) );
- while ( p_source_pixel < local_end )
- {
- converter( *p_source_pixel, *p_target_pixel );
- ++p_source_pixel;
- ++p_target_pixel;
- }
- BOOST_ASSERT( p_source_pixel == local_end );
- memunit_advance( p_source_pixel, setup.tile_width_bytes - this_tile_width_bytes );
- memunit_advance( p_target_pixel, original_view( view ).pixels().row_size() - ( this_tile_width_bytes * memunit_step( p_target_pixel ) / memunit_step( p_source_pixel ) ) );
- }
- BOOST_ASSERT
- (
- ( p_source_pixel == reinterpret_cast<my_pixel_t const *>( setup.p_tile_buffer.get() + setup.tile_size_bytes ) ) ||
- ( current_plane_rows_to_read_per_tile != setup.tile_height )
- );
- if ( last_row_tile )
- {
- p_target += ( current_plane_rows_to_read_per_tile /*- 1*/ - current_plane_rows_to_skip );
- current_plane_rows_to_skip = 0;
- horizontal_offset = 0;
- setup.current_row_tiles_remaining = setup.tiles_per_row;
- bool const next_row_is_last_row( ( current_plane_end_tile - ( current_tile + 1 ) ) == setup.tiles_per_row );
- if ( next_row_is_last_row )
- current_plane_rows_to_read_per_tile = setup.end_rows_to_read;
- }
- else
- {
- BOOST_ASSERT( this_tile_width_bytes == setup.tile_width_bytes );
- horizontal_offset += setup.tile_width;
- }
- BOOST_ASSERT( p_target.base() <= target_view.end().x() );
- }
- BOOST_ASSERT( p_target.base() == target_view.end().x() );
- }
- }
- }
- else
- ////////////////////////////////////////////////////////////////////////
- // Striped
- ////////////////////////////////////////////////////////////////////////
- {
- scanline_buffer_t<my_pixel_t> const scanline_buffer( *this, nondirect_planar_to_contig_conversion_t::value() );
-
- if ( nondirect_planar_to_contig_conversion_t::value )
- {
- typename original_target_view_t::y_iterator p_target( original_view( view ).y_at( 0, 0 ) );
- unsigned int row ( get_offset<offset_t>( view ) );
- unsigned int const target_row( row + dimensions.y );
-
- typename MyView::x_iterator const buffer_iterator
- (
- make_planar_buffer_iterator<typename MyView::x_iterator>
- (
- scanline_buffer.begin(),
- dimensions.x,
- number_of_planes_t()
- )
- );
-
- while ( row != target_row )
- {
- for ( unsigned int plane( 0 ); plane < number_of_planes_t::value; ++plane )
- {
- tdata_t const p_buffer( &(*buffer_iterator)[ plane ] );
- //...zzz...yup...not the most efficient thing in the universe...
- skip_to_row( get_offset<offset_t>( view ) + row, plane, p_buffer, result );
- result.accumulate_greater( ::TIFFReadScanline( &lib_object(), p_buffer, row, static_cast<tsample_t>( plane ) ), 0 );
- }
- typename MyView ::x_iterator p_source_pixel( buffer_iterator );
- typename original_target_view_t::x_iterator p_target_pixel( p_target.base() );
- while ( &(*p_source_pixel)[ 0 ] < &(*scanline_buffer.end())[ 0 ] )
- {
- converter( *p_source_pixel, *p_target_pixel );
- ++p_source_pixel;
- ++p_target_pixel;
- }
- ++p_target;
- ++row;
- }
- }
- else
- {
- for ( unsigned int plane( 0 ); plane < number_of_planes_t::value; ++plane )
- {
- if ( is_offset_view<TargetView>::value )
- skip_to_row( get_offset<offset_t>( view ), plane, scanline_buffer.begin(), result );
-
- local_target_view_t const & target_view( adjust_target_to_my_view( original_view( view ), plane, is_planar<MyView>() ) );
- target_y_iterator p_target( target_view.y_at( 0, 0 ) );
- unsigned int row ( get_offset<offset_t>( view ) );
- unsigned int const target_row( row + dimensions.y );
- while ( row != target_row )
- {
- result.accumulate_greater( ::TIFFReadScanline( &lib_object(), scanline_buffer.begin(), row++, static_cast<tsample_t>( plane ) ), 0 );
- my_pixel_t const * p_source_pixel( scanline_buffer.begin() );
- target_x_iterator p_target_pixel( p_target.base() );
- while ( p_source_pixel != scanline_buffer.end() )
- {
- converter( *p_source_pixel, *p_target_pixel );
- ++p_source_pixel;
- ++p_target_pixel;
- }
- ++p_target;
- }
- }
- }
- }
-
- result.throw_if_error();
- }
-
- #if defined(BOOST_MSVC)
- # pragma warning( pop )
- #endif
-
-private:
- template <typename View>
- static typename nth_channel_view_type<View>::type
- adjust_target_to_my_view( View const & view, unsigned int const plane, mpl::true_ /*source is planar*/ )
- {
- return nth_channel_view( view, plane );
- }
-
- template <typename View>
- static View const &
- adjust_target_to_my_view( View const & view, unsigned int const plane, mpl::false_ /*source is not planar*/ )
- {
- BOOST_ASSERT( plane == 0 );
- ignore_unused_variable_warning( plane );
- return view;
- }
-
- template <typename PixelIterator>
- static PixelIterator
- make_planar_buffer_iterator( void * const p_buffer, unsigned int /*row_width*/, mpl::int_<1> )
- {
- BOOST_ASSERT( !"Should not get called." );
- return static_cast<PixelIterator>( p_buffer );
- }
-
- template <typename PlanarPixelIterator>
- static PlanarPixelIterator
- make_planar_buffer_iterator( void * const p_buffer, unsigned int const row_width, mpl::int_<2> )
- {
- typedef typename channel_type<PlanarPixelIterator>::type * ptr_t;
- unsigned int const stride( row_width * memunit_step( ptr_t() ) );
- ptr_t const first ( static_cast<ptr_t>( p_buffer ) );
- ptr_t const second( first + stride );
- return PlanarPixelIterator( first, second );
- }
-
- template <typename PlanarPixelIterator>
- static PlanarPixelIterator
- make_planar_buffer_iterator( void * const p_buffer, unsigned int const row_width, mpl::int_<3> )
- {
- typedef typename channel_type<PlanarPixelIterator>::type * ptr_t;
- unsigned int const stride( row_width * memunit_step( ptr_t() ) );
- ptr_t const first ( static_cast<ptr_t>( p_buffer ) );
- ptr_t const second( first + stride );
- ptr_t const third ( second + stride );
- return PlanarPixelIterator( first, second, third );
- }
-
- template <typename PlanarPixelIterator>
- static PlanarPixelIterator
- make_planar_buffer_iterator( void * const p_buffer, unsigned int const row_width, mpl::int_<4> )
- {
- //...eradicate this triplication...
- typedef typename channel_type<PlanarPixelIterator>::type * ptr_t;
- unsigned int const stride( row_width * memunit_step( ptr_t() ) );
- ptr_t const first ( static_cast<ptr_t>( p_buffer ) );
- ptr_t const second( memunit_advanced( first , stride ) );
- ptr_t const third ( memunit_advanced( second, stride ) );
- ptr_t const fourth( memunit_advanced( third , stride ) );
- return PlanarPixelIterator( first, second, third, fourth );
- }
-
- // Implementation note:
- // Because of plain RVO incapable compilers (like Clang or even the latest
- // GCCs) a simple std::pair with a scoped_array cannot be used.
- // (11.01.2011.) (Domagoj Saric)
- //typedef std::pair
- //<
- // scoped_array<unsigned char> const,
- // unsigned char const * const
- //> generic_scanline_buffer_t;
-
- class scanline_buffer_base_t : boost::noncopyable
- {
- protected:
- explicit scanline_buffer_base_t( std::size_t const size )
- :
- p_begin_( new unsigned char[ size ] ),
- p_end_ ( p_begin_ + size )
- {}
-
- // This one makes the end pointer point to the end of the scanline/row
- // of the first plane not the end of the buffer itself...ugh...to be cleaned up...
- explicit scanline_buffer_base_t( std::pair<std::size_t, std::size_t> const size_to_allocate_size_to_report_pair )
- :
- p_begin_( new unsigned char[ size_to_allocate_size_to_report_pair.first ] ),
- p_end_ ( p_begin_ + size_to_allocate_size_to_report_pair.second )
- {}
-
- ~scanline_buffer_base_t() { delete[] p_begin_; }
-
- BF_NOTHROWNORESTRICTNOALIAS unsigned char * begin() const { return p_begin_; }
- BF_NOTHROWNORESTRICTNOALIAS unsigned char const * end () const { return p_end_ ; }
-
- static std::size_t scanline_buffer_construction( libtiff_image const & tiff )
- {
- return ( ::TIFFScanlineSize( &tiff.lib_object() ) );
- }
-
- static std::pair<std::size_t, std::size_t> planar_scanline_buffer_construction( native_reader const & tiff )
- {
- full_format_t::format_bitfield const format_bits( tiff.format_bits() );
- std::size_t const scanline_size ( format_bits.bits_per_sample * tiff.dimensions().x / 8 );
- std::size_t const allocation_size( scanline_size * format_bits.samples_per_pixel );
- return std::pair<std::size_t, std::size_t>( allocation_size, scanline_size );
- }
-
- private:
- unsigned char * const p_begin_;
- unsigned char const * const p_end_ ;
- };
-
- template <typename Pixel>
- class scanline_buffer_t : public scanline_buffer_base_t
- {
- public:
- scanline_buffer_t( libtiff_image const & tiff, mpl::true_ /* nptcc */ ) : scanline_buffer_base_t( planar_scanline_buffer_construction( tiff ) ) {}
- scanline_buffer_t( libtiff_image const & tiff, mpl::false_ /* not nptcc */ ) : scanline_buffer_base_t( scanline_buffer_construction ( tiff ) ) {}
-
- Pixel * begin() const { return gil_reinterpret_cast <Pixel *>( scanline_buffer_base_t::begin() ); }
- Pixel const * end () const { return gil_reinterpret_cast_c<Pixel const *>( scanline_buffer_base_t::end () ); }
- };
-
- template <typename Pixel>
- class planar_scanline_buffer_t : scanline_buffer_t<Pixel>
- {
- public:
- planar_scanline_buffer_t( libtiff_image const & image ) : scanline_buffer_t<Pixel>( tiff, mpl::true_() ) {}
- };
-
- skip_row_results_t BF_NOTHROWNOALIAS skip_to_row
- (
- unsigned int const row_to_skip_to,
- unsigned int const sample,
- tdata_t const buffer,
- cumulative_result & error_result
- ) const
- {
- BOOST_ASSERT( !::TIFFIsTiled( &lib_object() ) );
-
- skip_row_results_t result;
- result.rows_per_strip = get_field<uint32>( TIFFTAG_ROWSPERSTRIP );
- unsigned int const number_of_rows_to_skip_using_scanlines( row_to_skip_to % result.rows_per_strip );
- result.starting_strip = ( row_to_skip_to / result.rows_per_strip ) + ( number_of_rows_to_skip_using_scanlines != 0 ) + sample * get_field<uint32>( TIFFTAG_IMAGEWIDTH );
- result.rows_to_read_using_scanlines = row_to_skip_to ? ( result.rows_per_strip - number_of_rows_to_skip_using_scanlines - 1 ) : 0;
-
- bool const canSkipDirectly
- (
- ( result.rows_per_strip == 1 ) ||
- ( get_field<uint16>( TIFFTAG_COMPRESSION ) == COMPRESSION_NONE )
- );
- unsigned int row
- (
- canSkipDirectly
- ? row_to_skip_to
- : ( row_to_skip_to - number_of_rows_to_skip_using_scanlines )
- );
- while ( row < row_to_skip_to )
- {
- error_result.accumulate_greater( ::TIFFReadScanline( &lib_object(), buffer, row++, static_cast<tsample_t>( sample ) ), 0 );
- }
-
- //BOOST_ASSERT( !row_to_skip_to || ( ::TIFFCurrentRow( &lib_object() ) == row_to_skip_to ) );
-
- return result;
- }
-
-private:
- full_format_t const format_;
-};
-
-//------------------------------------------------------------------------------
-} // namespace io
-//------------------------------------------------------------------------------
-} // namespace gil
-//------------------------------------------------------------------------------
-} // namespace boost
-//------------------------------------------------------------------------------
-#endif // libtiff_reader_hpp

Deleted: sandbox/gil/boost/gil/extension/io2/libtiff_writer.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/libtiff_writer.hpp 2011-07-27 18:18:58 EDT (Wed, 27 Jul 2011)
+++ (empty file)
@@ -1,140 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \file libtiff_writer.hpp
-/// ------------------------
-///
-/// Copyright (c) Domagoj Saric 2010.-2011.
-///
-/// Use, modification and distribution is subject to the Boost Software License, Version 1.0.
-/// (See accompanying file LICENSE_1_0.txt or copy at
-/// http://www.boost.org/LICENSE_1_0.txt)
-///
-/// For more information, see http://www.boost.org
-///
-////////////////////////////////////////////////////////////////////////////////
-//------------------------------------------------------------------------------
-#ifndef libtiff_writer_hpp__FD402B04_E934_4E73_8839_001A8633B5D3
-#define libtiff_writer_hpp__FD402B04_E934_4E73_8839_001A8633B5D3
-#pragma once
-//------------------------------------------------------------------------------
-#include "libtiff_image.hpp"
-#include "backend_writer.hpp"
-
-#include "detail/io_error.hpp"
-#include "detail/libx_shared.hpp"
-#include "detail/platform_specifics.hpp"
-#include "detail/shared.hpp"
-
-#include <boost/array.hpp>
-//------------------------------------------------------------------------------
-namespace boost
-{
-//------------------------------------------------------------------------------
-namespace gil
-{
-//------------------------------------------------------------------------------
-namespace detail
-{
-//------------------------------------------------------------------------------
-
-inline tsize_t FILE_write_proc( thandle_t const handle, tdata_t const buf, tsize_t const size )
-{
- return static_cast<tsize_t>( std::fwrite( buf, 1, size, reinterpret_cast<FILE *>( handle ) ) );
-}
-
-struct tiff_writer_view_data_t : public tiff_view_data_t
-{
- template <class View>
- tiff_writer_view_data_t( View const & view )
- :
- tiff_view_data_t( view, 0 )
- {
- format_.number = gil_to_libtiff_format<typename View::value_type, is_planar<View>::value>::value;
- }
-
- full_format_t format_;
-};
-
-//------------------------------------------------------------------------------
-} // namespace detail
-
-class libtiff_writer
- :
- public libtiff_image,
- public detail::backend_writer<libtiff_image>,
- public configure_on_write_writer
-{
-public:
- explicit libtiff_writer( char const * const file_name ) : libtiff_image( file_name, "w" ) {}
-
- explicit libtiff_writer( FILE & file ) : libtiff_image( file ) {}
-
- void write_default( tiff_writer_view_data_t const & view )
- {
- full_format_t::format_bitfield const format_bits( view.format_.bits );
- //BOOST_ASSERT( ( format_bits.planar_configuration == PLANARCONFIG_CONTIG ) && "Add planar support..." );
-
- set_field( TIFFTAG_IMAGEWIDTH , view.dimensions_.x );
- set_field( TIFFTAG_IMAGELENGTH , view.dimensions_.y );
- set_field( TIFFTAG_BITSPERSAMPLE , format_bits.bits_per_sample );
- set_field( TIFFTAG_SAMPLESPERPIXEL, format_bits.samples_per_pixel );
- set_field( TIFFTAG_PLANARCONFIG , format_bits.planar_configuration );
- set_field( TIFFTAG_PHOTOMETRIC , format_bits.photometric );
- set_field( TIFFTAG_INKSET , format_bits.ink_set );
- set_field( TIFFTAG_SAMPLEFORMAT , format_bits.sample_format );
-
- set_field( TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT );
-
- if ( format_bits.samples_per_pixel == 4 && format_bits.photometric == PHOTOMETRIC_RGB )
- {
- uint16 const type( EXTRASAMPLE_UNASSALPHA );
- set_field( TIFFTAG_EXTRASAMPLES, 1, &type );
- }
-
- write( view );
- }
-
- void write( tiff_writer_view_data_t const & view )
- {
- cumulative_result result;
-
- for ( unsigned int plane( 0 ); plane < view.number_of_planes_; ++plane )
- {
- unsigned char * buf( view.plane_buffers_[ plane ] );
-
- unsigned int row ( 0 );
- unsigned int const target_row( view.dimensions_.y );
- while ( row < target_row )
- {
- result.accumulate_greater( ::TIFFWriteScanline( &lib_object(), buf, row++, static_cast<tsample_t>( plane ) ), 0 );
- buf += view.stride_;
- }
- }
-
- result.throw_if_error();
- }
-
-private:
- template <typename T>
- void set_field( ttag_t const tag, T value )
- {
- #ifdef _MSC_VER
- BOOST_VERIFY( ::TIFFVSetField( &lib_object(), tag, gil_reinterpret_cast<va_list>( &value ) ) );
- #else
- BOOST_VERIFY( ::TIFFSetField ( &lib_object(), tag, value ) );
- #endif // _MSC_VER
- }
-
- template <typename T1, typename T2>
- void set_field( ttag_t const tag, T1 const value1, T2 const value2 )
- {
- BOOST_VERIFY( ::TIFFSetField( &lib_object(), tag, value1, value2 ) );
- }
-};
-
-//------------------------------------------------------------------------------
-} // namespace gil
-//------------------------------------------------------------------------------
-} // namespace boost
-//------------------------------------------------------------------------------
-#endif // libtiff_writer_hpp

Deleted: sandbox/gil/boost/gil/extension/io2/reader.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/reader.hpp 2011-07-27 18:18:58 EDT (Wed, 27 Jul 2011)
+++ (empty file)
@@ -1,98 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \file formatted_image.hpp
-/// -------------------------
-///
-/// Base CRTP class for all image implementation classes/backends.
-///
-/// Copyright (c) Domagoj Saric 2010.-2011.
-///
-/// Use, modification and distribution is subject to the Boost Software License, Version 1.0.
-/// (See accompanying file LICENSE_1_0.txt or copy at
-/// http://www.boost.org/LICENSE_1_0.txt)
-///
-/// For more information, see http://www.boost.org
-///
-////////////////////////////////////////////////////////////////////////////////
-//------------------------------------------------------------------------------
-#ifndef reader_hpp__1733426F_1D8C_4F4E_A966_BDB6426AA88C
-#define reader_hpp__1733426F_1D8C_4F4E_A966_BDB6426AA88C
-#pragma once
-//------------------------------------------------------------------------------
-#include "format_tags.hpp"
-#include "detail/platform_specifics.hpp"
-#include "detail/io_error.hpp"
-
-#include "boost/gil/typedefs.hpp"
-
-#include <boost/static_assert.hpp>
-//------------------------------------------------------------------------------
-namespace boost
-{
-//------------------------------------------------------------------------------
-namespace gil
-{
-//------------------------------------------------------------------------------
-namespace io
-{
-//------------------------------------------------------------------------------
-
-namespace detail
-{
- template <class Reader, typename Source>
- class reader_extender
- :
- public input_device<Source>,
- public Reader
- {
- public:
- reader_extender( Source const source )
- :
- input_device<Source>( source ),
- Reader ( input_device<Source>::transform( source ) )
- {}
- };
-} // namespace detail
-
-
-////////////////////////////////////////////////////////////////////////////////
-/// \class formatted_image_traits
-/// ( forward declaration )
-////////////////////////////////////////////////////////////////////////////////
-
-template <class Impl>
-struct formatted_image_traits;
-
-
-template <class Backend, typename Source>
-struct reader_for
-{
- typedef typename mpl::has_key<typename formatted_image_traits<Backend>::native_sources, Source>::type supported_by_native_reader_t;
-
- // The backend does not seem to provide a reader for the specified target...
- BOOST_STATIC_ASSERT
- ((
- supported_by_native_reader_t::value ||
- !unknown_input_device<Source>::value
- ));
-
- typedef typename mpl::if_
- <
- supported_by_native_reader_t,
- typename Backend::native_reader,
- detail::reader_extender<typename Backend::device_reader, Source>
- >::type type;
-};
-
-
-template <class Backend>
-struct reader_for<Backend, char *> : reader_for<Backend, char const *> {};
-
-//------------------------------------------------------------------------------
-} // namespace io
-//------------------------------------------------------------------------------
-} // namespace gil
-//------------------------------------------------------------------------------
-} // namespace boost
-//------------------------------------------------------------------------------
-#endif // reader_hpp

Deleted: sandbox/gil/boost/gil/extension/io2/wic_image.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/wic_image.hpp 2011-07-27 18:18:58 EDT (Wed, 27 Jul 2011)
+++ (empty file)
@@ -1,287 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \file wic_image.hpp
-/// -------------------
-///
-/// Base IO interface WIC implementation.
-///
-/// Copyright (c) Domagoj Saric 2010.
-///
-/// Use, modification and distribution is subject to the Boost Software License, Version 1.0.
-/// (See accompanying file LICENSE_1_0.txt or copy at
-/// http://www.boost.org/LICENSE_1_0.txt)
-///
-/// For more information, see http://www.boost.org
-///
-////////////////////////////////////////////////////////////////////////////////
-//------------------------------------------------------------------------------
-#ifndef wic_image_hpp__78D710F7_11C8_4023_985A_22B180C9A476
-#define wic_image_hpp__78D710F7_11C8_4023_985A_22B180C9A476
-#pragma once
-//------------------------------------------------------------------------------
-#include "detail/io_error.hpp"
-#include "detail/shared.hpp"
-#include "detail/wic_extern_lib_guard.hpp"
-#include "detail/windows_shared.hpp"
-#include "detail/windows_shared_istreams.hpp"
-#include "formatted_image.hpp"
-
-#include <boost/mpl/vector_c.hpp> //...missing from metafuncitons.hpp...
-#include "boost/gil/metafunctions.hpp"
-#include "boost/gil/rgb.hpp"
-#include "boost/gil/typedefs.hpp"
-
-#include <boost/array.hpp>
-#include <boost/mpl/eval_if.hpp>
-#include <boost/mpl/integral_c.hpp>
-#include <boost/mpl/set/set10.hpp>
-#include <boost/range/iterator_range.hpp>
-#include <boost/static_assert.hpp>
-#include <boost/type_traits/is_pod.hpp>
-
-#include <algorithm>
-//------------------------------------------------------------------------------
-namespace boost
-{
-//------------------------------------------------------------------------------
-namespace gil
-{
-//------------------------------------------------------------------------------
-
-template <typename Pixel, bool IsPlanar, typename Alloc=std::allocator<unsigned char> >
-class image;
-
-namespace io
-{
-//------------------------------------------------------------------------------
-namespace detail
-{
-//------------------------------------------------------------------------------
-
-typedef WICPixelFormatGUID const & wic_format_t;
-
-template <wic_format_t guid>
-struct format_guid
-{
- typedef format_guid type;
-
- static wic_format_t const value;
-};
-
-template <wic_format_t guid>
-wic_format_t format_guid<guid>::value( guid );
-
-
-template <typename Pixel, bool IsPlanar>
-struct gil_to_wic_format : format_guid<GUID_WICPixelFormatUndefined> {};
-
-typedef packed_pixel_type<uint16_t, mpl::vector3_c<unsigned,5,6,5>, bgr_layout_t>::type wic_bgr565_pixel_t;
-
-template <> struct gil_to_wic_format<wic_bgr565_pixel_t, false> : format_guid<GUID_WICPixelFormat16bppBGR555> {};
-template <> struct gil_to_wic_format<bgr8_pixel_t , false> : format_guid<GUID_WICPixelFormat24bppBGR > {};
-template <> struct gil_to_wic_format<rgb8_pixel_t , false> : format_guid<GUID_WICPixelFormat24bppRGB > {};
-template <> struct gil_to_wic_format<bgra8_pixel_t , false> : format_guid<GUID_WICPixelFormat32bppBGRA > {};
-template <> struct gil_to_wic_format<gray16_pixel_t , false> : format_guid<GUID_WICPixelFormat16bppGray > {};
-template <> struct gil_to_wic_format<bgr16_pixel_t , false> : format_guid<GUID_WICPixelFormat48bppRGB > {};
-template <> struct gil_to_wic_format<bgra16_pixel_t , false> : format_guid<GUID_WICPixelFormat64bppBGRA > {};
-template <> struct gil_to_wic_format<cmyk8_pixel_t , false> : format_guid<GUID_WICPixelFormat32bppCMYK > {};
-
-
-typedef mpl::vector8
-<
- image<wic_bgr565_pixel_t, false>,
- image<bgr8_pixel_t , false>,
- image<rgb8_pixel_t , false>,
- image<bgra8_pixel_t , false>,
- image<gray16_pixel_t , false>,
- image<bgr16_pixel_t , false>,
- image<bgra16_pixel_t , false>,
- image<cmyk8_pixel_t , false>
-> wic_supported_pixel_formats;
-
-
-struct view_wic_format
-{
- template <typename Pixel, bool IsPlanar>
- struct apply : gil_to_wic_format<Pixel, IsPlanar> {};
-};
-
-
-class wic_roi : public WICRect
-{
-public:
- typedef INT value_type;
- typedef point2<value_type> point_t ;
-
- typedef point_t offset_t ;
-
-public:
- wic_roi( value_type const x, value_type const y, value_type const width, value_type const height )
- {
- X = x; Y = y;
- Width = width; Height = height;
- }
-
- wic_roi( offset_t const top_left, value_type const width, value_type const height )
- {
- X = top_left.x; Y = top_left.y;
- Width = width; Height = height;
- }
-
- wic_roi( offset_t const top_left, offset_t const bottom_right )
- {
- X = top_left.x; Y = top_left.y;
- Width = bottom_right.x - top_left.x;
- Height = bottom_right.y - top_left.y;
- }
-};
-
-
-inline void ensure_result( HRESULT const result )
-{
- io_error_if( result != S_OK, "WIC failure"/*error_string( result )*/ );
-}
-
-inline void verify_result( HRESULT const result )
-{
- BOOST_VERIFY( result == S_OK );
-}
-
-
-struct wic_view_data_t
-{
- template <typename View>
- wic_view_data_t( View const & view )
- :
- p_roi_ ( 0 ),
- format_( gil_to_wic_format<typename View::value_type, is_planar<View>::value>::value )
- {
- set_bitmapdata_for_view( view );
- }
-
- template <typename View>
- wic_view_data_t( View const & view, wic_roi::offset_t const & offset )
- :
- p_roi_ ( static_cast<wic_roi const *>( optional_roi_.address() ) ),
- format_( gil_to_wic_format<typename View::value_type, is_planar<View>::value>::value )
- {
- set_bitmapdata_for_view( view );
- new ( optional_roi_.address() ) wic_roi( offset, width_, height_ );
- }
-
- WICRect const * const p_roi_ ;
- unsigned int /*const*/ width_ ;
- unsigned int /*const*/ height_;
- unsigned int /*const*/ stride_;
- unsigned int /*const*/ pixel_size_;
- BYTE * /*const*/ p_buffer_;
- wic_format_t const format_;
-
-private:
- template <typename View>
- void set_bitmapdata_for_view( View const & view )
- {
- width_ = view.width();
- height_ = view.height();
- stride_ = view.pixels().row_size();
- pixel_size_ = memunit_step( typename View::x_iterator() );
- //format_ = gil_to_wic_format<typename View::value_type, is_planar<View>::value>::value;
- p_buffer_ = detail::formatted_image_base::get_raw_data( view );
- }
-
- void operator=( wic_view_data_t const & );
-
-private:
- aligned_storage<sizeof( wic_roi ), alignment_of<wic_roi>::value>::type optional_roi_;
-};
-
-
-template <template <typename Handle> class IODeviceStream, class BackendWriter>
-class device_stream_wrapper;
-
-//------------------------------------------------------------------------------
-} // namespace detail
-
-class wic_image;
-
-template <>
-struct formatted_image_traits<wic_image>
-{
- typedef detail::wic_format_t format_t;
-
- typedef detail::wic_supported_pixel_formats supported_pixel_formats_t;
-
- typedef detail::wic_roi roi_t;
-
- typedef detail::view_wic_format gil_to_native_format;
-
- template <typename Pixel, bool IsPlanar>
- struct is_supported
- :
- mpl::not_
- <
- is_same
- <
- typename gil_to_native_format:: BOOST_NESTED_TEMPLATE apply<Pixel, IsPlanar>::type,
- //format_guid<wic_format >,
- detail::format_guid<GUID_WICPixelFormatUndefined>
- >
- > {};
-
- typedef mpl::set4
- <
- char const *,
- wchar_t const *,
- HANDLE ,
- IStream &
- > native_sources;
-
- typedef mpl::set1
- <
- IStream &
- > native_sinks;
-
- typedef mpl::vector5_c<format_tag, png, bmp, gif, jpeg, tiff> supported_image_formats;
-
- typedef detail::wic_view_data_t view_data_t ;
- typedef view_data_t writer_view_data_t;
-
- BOOST_STATIC_CONSTANT( unsigned int, desired_alignment = sizeof( void * ) );
- BOOST_STATIC_CONSTANT( bool , builtin_conversion = true );
-};
-
-
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \class wic_image
-///
-////////////////////////////////////////////////////////////////////////////////
-// http://msdn.microsoft.com/en-us/magazine/cc500647.aspx
-////////////////////////////////////////////////////////////////////////////////
-
-class wic_image
- :
- private detail::wic_base_guard,
- public detail::formatted_image<wic_image>
-{
-public:
- typedef detail::wic_user_guard guard;
-
- class native_reader;
- typedef detail::device_stream_wrapper<detail::input_device_stream , native_reader> device_reader;
-
- class native_writer;
- typedef detail::device_stream_wrapper<detail::output_device_stream, native_writer> device_writer;
-
-public: // Low-level (row, strip, tile) access
- static bool can_do_roi_access() { return true; }
-};
-
-//------------------------------------------------------------------------------
-} // namespace io
-//------------------------------------------------------------------------------
-} // namespace gil
-//------------------------------------------------------------------------------
-} // namespace boost
-//------------------------------------------------------------------------------
-#endif // wic_image_hpp

Deleted: sandbox/gil/boost/gil/extension/io2/wic_reader.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/wic_reader.hpp 2011-07-27 18:18:58 EDT (Wed, 27 Jul 2011)
+++ (empty file)
@@ -1,301 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \file wic_image.hpp
-/// -------------------
-///
-/// Base IO interface WIC implementation.
-///
-/// Copyright (c) Domagoj Saric 2010.-2011.
-///
-/// Use, modification and distribution is subject to the Boost Software License, Version 1.0.
-/// (See accompanying file LICENSE_1_0.txt or copy at
-/// http://www.boost.org/LICENSE_1_0.txt)
-///
-/// For more information, see http://www.boost.org
-///
-////////////////////////////////////////////////////////////////////////////////
-//------------------------------------------------------------------------------
-#ifndef wic_reader_hpp__8C7EFA72_9E1A_4FD4_AF3F_B7921B320C1C
-#define wic_reader_hpp__8C7EFA72_9E1A_4FD4_AF3F_B7921B320C1C
-#pragma once
-//------------------------------------------------------------------------------
-#include "backend_reader.hpp"
-#include "detail/io_error.hpp"
-#include "detail/wic_extern_lib_guard.hpp"
-#include "detail/windows_shared.hpp"
-#include "detail/windows_shared_istreams.hpp"
-#include "wic_image.hpp"
-
-#include <boost/mpl/vector_c.hpp> //...missing from metafuncitons.hpp...
-#include "boost/gil/metafunctions.hpp"
-#include "boost/gil/rgb.hpp"
-#include "boost/gil/typedefs.hpp"
-
-#include <boost/array.hpp>
-#include <boost/mpl/eval_if.hpp>
-#include <boost/mpl/integral_c.hpp>
-#include <boost/range/iterator_range.hpp>
-#include <boost/static_assert.hpp>
-#include <boost/type_traits/is_pod.hpp>
-
-#include <algorithm>
-//------------------------------------------------------------------------------
-namespace boost
-{
-//------------------------------------------------------------------------------
-namespace gil
-{
-//------------------------------------------------------------------------------
-namespace io
-{
-//------------------------------------------------------------------------------
-
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \class wic_image::native_reader
-///
-////////////////////////////////////////////////////////////////////////////////
-
-class wic_image::native_reader
- :
- public wic_image,
- public detail::backend_reader<wic_image>
-{
-public:
- // Implementation note:
- // The IWICBitmapDecoder instance is not otherwise necessary once an
- // IWICBitmapFrameDecode instance is created but we keep it here and make it
- // accessible to the user to enable the use of multi frame/page/picture
- // formats like GIF and TIFF.
- // (26.07.2010.) (Domagoj Saric)
- typedef std::pair
- <
- detail::com_scoped_ptr<IWICBitmapFrameDecode>,
- detail::com_scoped_ptr<IWICBitmapDecoder >
- > lib_object_t;
-
- typedef detail::wic_user_guard guard;
-
-public:
- explicit native_reader( wchar_t const * const filename )
- {
- create_decoder_from_filename( filename );
- }
-
- explicit native_reader( char const * const filename )
- {
- create_decoder_from_filename( detail::wide_path( filename ) );
- }
-
- // The passed IStream object must outlive the wic_image object (to support
- // lazy evaluation).
- explicit native_reader( IStream & stream )
- {
- using namespace detail;
- ensure_result( wic_factory::singleton().CreateDecoderFromStream( &stream, NULL, WICDecodeMetadataCacheOnDemand, &lib_object().second ) );
- create_first_frame_decoder();
- }
-
- explicit native_reader( HANDLE const file_handle )
- {
- using namespace detail;
- ensure_result( wic_factory::singleton().CreateDecoderFromFileHandle( reinterpret_cast<ULONG_PTR>( file_handle ), NULL, WICDecodeMetadataCacheOnDemand, &lib_object().second ) );
- create_first_frame_decoder();
- }
-
-public:
- point2<std::ptrdiff_t> dimensions() const
- {
- using namespace detail;
- typedef point2<std::ptrdiff_t> result_t;
- aligned_storage<sizeof( result_t ), alignment_of<result_t>::value>::type placeholder;
- result_t & result( *gil_reinterpret_cast<result_t *>( placeholder.address() ) );
- BOOST_STATIC_ASSERT( sizeof( result_t::value_type ) == sizeof( UINT ) );
- verify_result( frame_decoder().GetSize( gil_reinterpret_cast<UINT *>( &result.x ), gil_reinterpret_cast<UINT *>( &result.y ) ) );
- return result;
- }
-
- /*format_t*/WICPixelFormatGUID format() const
- {
- WICPixelFormatGUID pixel_format;
- detail::verify_result( frame_decoder().GetPixelFormat( &pixel_format ) );
- //...zzz...check that it is a supported format...
- return pixel_format;
- }
-
- /*format_t*/WICPixelFormatGUID closest_gil_supported_format() const { return format(); }
-
- image_type_id current_image_format_id() const
- {
- return image_format_id( closest_gil_supported_format() );
- }
-
-public: // Low-level (row, strip, tile) access
- class sequential_row_read_state
- :
- private detail::cumulative_result
- {
- public:
- using detail::cumulative_result::failed;
- void throw_if_error() const { detail::cumulative_result::throw_if_error( "WIC failure" ); }
-
- BOOST_STATIC_CONSTANT( bool, throws_on_error = false );
-
- private:
- sequential_row_read_state( wic_image::native_reader const & source_image )
- :
- roi_ ( 0, 0, source_image.dimensions().x, 1 ),
- stride_( roi_.X * source_image.pixel_size() )
- {}
-
- private: friend wic_image;
- detail::wic_roi roi_ ;
- UINT const stride_;
- };
-
- sequential_row_read_state begin_sequential_row_read() const { return sequential_row_read_state( *this ); }
-
- void read_row( sequential_row_read_state & state, unsigned char * const p_row_storage ) const
- {
- state.accumulate_equal
- (
- frame_decoder().CopyPixels
- (
- &state.roi_,
- state.stride_,
- state.stride_,
- p_row_storage
- ),
- S_OK
- );
- ++state.roi_.Y;
- }
-
- lib_object_t & lib_object() { return lib_object_; }
-
-private: // Private formatted_image_base interface.
- friend class detail::backend_reader<wic_image>;
-
- template <class MyView, class TargetView, class Converter>
- void generic_convert_to_prepared_view( TargetView const & view, Converter const & converter ) const
- {
- BOOST_ASSERT( !dimensions_mismatch( view ) );
-
- using namespace detail;
-
- //...non template related code yet to be extracted...
- point2<std::ptrdiff_t> const & targetDimensions( original_view( view ).dimensions() );
- wic_roi const roi( get_offset<wic_roi::offset_t>( view ), targetDimensions.x, targetDimensions.y );
- com_scoped_ptr<IWICBitmap> p_bitmap;
- ensure_result( wic_factory::singleton().CreateBitmapFromSourceRect( &frame_decoder(), roi.X, roi.Y, roi.Width, roi.Height, &p_bitmap ) );
- com_scoped_ptr<IWICBitmapLock> p_bitmap_lock;
- ensure_result( p_bitmap->Lock( &roi, WICBitmapLockRead, &p_bitmap_lock ) );
- unsigned int buffer_size;
- BYTE * p_buffer;
- verify_result( p_bitmap_lock->GetDataPointer( &buffer_size, &p_buffer ) );
- unsigned int stride;
- verify_result( p_bitmap_lock->GetStride( &stride ) );
- #ifndef NDEBUG
- WICPixelFormatGUID locked_format;
- verify_result( p_bitmap_lock->GetPixelFormat( &locked_format ) );
- BOOST_ASSERT(( locked_format == gil_to_wic_format<typename View::value_type, is_planar<View>::value>::value ));
- #endif
- copy_and_convert_pixels
- (
- interleaved_view
- (
- roi.Width ,
- roi.Height,
- gil_reinterpret_cast_c<typename MyView::value_type const *>( p_buffer ),
- stride
- ),
- view,
- converter
- );
- }
-
-
- void raw_convert_to_prepared_view( view_data_t const & view_data ) const
- {
- BOOST_ASSERT( view_data.format_ != GUID_WICPixelFormatUndefined ); //...zzz...
- using namespace detail;
- com_scoped_ptr<IWICFormatConverter> p_converter;
- ensure_result( wic_factory::singleton().CreateFormatConverter( &p_converter ) );
- ensure_result( p_converter->Initialize( &frame_decoder(), view_data.format_, WICBitmapDitherTypeNone, NULL, 0, WICBitmapPaletteTypeCustom ) );
- ensure_result
- (
- p_converter->CopyPixels
- (
- view_data.p_roi_,
- view_data.stride_,
- view_data.height_ * view_data.stride_ * view_data.pixel_size_,
- view_data.p_buffer_
- )
- );
- }
-
-
- void raw_copy_to_prepared_view( view_data_t const & view_data ) const
- {
- detail::ensure_result
- (
- frame_decoder().CopyPixels
- (
- view_data.p_roi_,
- view_data.stride_,
- view_data.height_ * view_data.stride_ * view_data.pixel_size_,
- view_data.p_buffer_
- )
- );
- }
-
-
- static std::size_t cached_format_size( format_t const format )
- {
- using namespace detail;
- com_scoped_ptr<IWICComponentInfo> p_component_info;
- ensure_result( wic_factory::singleton().CreateComponentInfo( format, &p_component_info ) );
- //com_scoped_ptr<IWICPixelFormatInfo> p_pixel_format_info;
- //p_component_info->QueryInterface( );IID_IWICPixelFormatInfo
- com_scoped_ptr<IWICPixelFormatInfo> const p_pixel_format_info( *p_component_info );
- io_error_if_not( p_pixel_format_info, "WIC failure" );
- unsigned int bits_per_pixel;
- verify_result( p_pixel_format_info->GetBitsPerPixel( &bits_per_pixel ) );
- return bits_per_pixel;
- }
-
-private:
- IWICBitmapFrameDecode & frame_decoder() const { return *lib_object_.first ; }
- IWICBitmapDecoder & wic_decoder () const { return *lib_object_.second; }
-
- void create_decoder_from_filename( wchar_t const * const filename )
- {
- using namespace detail;
- ensure_result( wic_factory::singleton().CreateDecoderFromFilename( filename, NULL, GENERIC_READ, WICDecodeMetadataCacheOnDemand, &lib_object().second ) );
- create_first_frame_decoder();
- }
-
- void create_first_frame_decoder()
- {
- using namespace detail;
- #ifndef NDEBUG
- unsigned int frame_count;
- verify_result( wic_decoder().GetFrameCount( &frame_count ) );
- BOOST_ASSERT( frame_count >= 1 );
- #endif // NDEBUG
- ensure_result( wic_decoder().GetFrame( 0, &lib_object().first ) );
- }
-
-private:
- lib_object_t lib_object_;
-};
-
-
-//------------------------------------------------------------------------------
-} // namespace io
-//------------------------------------------------------------------------------
-} // namespace gil
-//------------------------------------------------------------------------------
-} // namespace boost
-//------------------------------------------------------------------------------
-#endif // wic_reader_hpp

Deleted: sandbox/gil/boost/gil/extension/io2/wic_writer.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/wic_writer.hpp 2011-07-27 18:18:58 EDT (Wed, 27 Jul 2011)
+++ (empty file)
@@ -1,149 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \file wic_writer.hpp
-/// --------------------
-///
-/// Base IO interface WIC implementation.
-///
-/// Copyright (c) Domagoj Saric 2010.-2011.
-///
-/// Use, modification and distribution is subject to the Boost Software License, Version 1.0.
-/// (See accompanying file LICENSE_1_0.txt or copy at
-/// http://www.boost.org/LICENSE_1_0.txt)
-///
-/// For more information, see http://www.boost.org
-///
-////////////////////////////////////////////////////////////////////////////////
-//------------------------------------------------------------------------------
-#ifndef wic_writer_hpp__F8E533DB_13F3_495F_9F64_0C33F7C5AB95
-#define wic_writer_hpp__F8E533DB_13F3_495F_9F64_0C33F7C5AB95
-#pragma once
-//------------------------------------------------------------------------------
-#include "wic_image.hpp"
-#include "backend_writer.hpp"
-#include "writer.hpp"
-
-#include "detail/io_error.hpp"
-#include "detail/windows_shared.hpp"
-#include "detail/windows_shared_istreams.hpp"
-//------------------------------------------------------------------------------
-namespace boost
-{
-//------------------------------------------------------------------------------
-namespace gil
-{
-//------------------------------------------------------------------------------
-namespace io
-{
-//------------------------------------------------------------------------------
-
-class wic_image::native_writer
- :
- public wic_image,
- public detail::backend_writer<wic_image>,
- public detail::configure_on_write_writer
-{
-public:
- struct lib_object_t
- {
- detail::com_scoped_ptr<IWICBitmapFrameEncode> p_frame_ ;
- detail::com_scoped_ptr<IWICBitmapEncoder > p_encoder_ ;
- IPropertyBag2 * p_frame_parameters_;
- };
-
- lib_object_t & lib_object() { return lib_object_; }
-
-public:
- native_writer( IStream & target, format_tag const format )
- {
- create_encoder( target, encoder_guid( format ) );
- }
-
- void write_default( detail::wic_view_data_t const & view_data )
- {
- HRESULT hr( frame().Initialize( lib_object().p_frame_parameters_ ) );
-
- if ( SUCCEEDED( hr ) )
- {
- hr = frame().SetSize( view_data.width_, view_data.height_ );
- }
-
- if ( SUCCEEDED( hr ) )
- {
- WICPixelFormatGUID formatGUID( view_data.format_ );
- hr = frame().SetPixelFormat( &formatGUID );
- if ( SUCCEEDED( hr ) )
- {
- hr = ( formatGUID == view_data.format_ ) ? S_OK : E_FAIL;
- }
- }
-
- if ( SUCCEEDED( hr ) )
- {
- hr = frame().WritePixels( view_data.height_, view_data.stride_, view_data.height_ * view_data.stride_, view_data.p_buffer_ );
- }
-
- if ( SUCCEEDED( hr ) )
- {
- hr = frame().Commit();
- }
-
- if ( SUCCEEDED( hr ) )
- {
- hr = encoder().Commit();
- }
-
- detail::ensure_result( hr );
- }
-
- void write( detail::wic_view_data_t const & view_data ) { write_default( view_data ); }
-
-private:
- void create_encoder( IStream & target, GUID const & format )
- {
- using namespace detail;
- HRESULT hr;
- {
- hr = wic_factory::singleton().CreateEncoder( format, NULL, &lib_object().p_encoder_ );
- }
- if ( SUCCEEDED( hr ) )
- {
- hr = encoder().Initialize( &target, WICBitmapEncoderNoCache );
- }
- if ( SUCCEEDED( hr ) )
- {
- hr = encoder().CreateNewFrame( &lib_object().p_frame_, &lib_object().p_frame_parameters_ );
- }
- ensure_result( hr );
- }
-
- static GUID const & encoder_guid( format_tag const format )
- {
- static GUID const * const guids[ number_of_known_formats ] =
- {
- &GUID_ContainerFormatBmp,
- &GUID_ContainerFormatGif,
- &GUID_ContainerFormatJpeg,
- &GUID_ContainerFormatPng,
- &GUID_ContainerFormatTiff,
- NULL // TGA
- };
- BOOST_ASSERT_MSG( guids[ format ] != NULL, "File format not supported by WIC." );
- return *guids[ format ];
- }
-
- IWICBitmapFrameEncode & frame () { return *lib_object().p_frame_ ; }
- IWICBitmapEncoder & encoder() { return *lib_object().p_encoder_; }
-
-private:
- lib_object_t lib_object_;
-};
-
-//------------------------------------------------------------------------------
-} // namespace io
-//------------------------------------------------------------------------------
-} // namespace gil
-//------------------------------------------------------------------------------
-} // namespace boost
-//------------------------------------------------------------------------------
-#endif // wic_writer_hpp

Deleted: sandbox/gil/boost/gil/extension/io2/writer.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/writer.hpp 2011-07-27 18:18:58 EDT (Wed, 27 Jul 2011)
+++ (empty file)
@@ -1,211 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \file formatted_image.hpp
-/// -------------------------
-///
-/// Base CRTP class for all image implementation classes/backends.
-///
-/// Copyright (c) Domagoj Saric 2010.-2011.
-///
-/// Use, modification and distribution is subject to the Boost Software License, Version 1.0.
-/// (See accompanying file LICENSE_1_0.txt or copy at
-/// http://www.boost.org/LICENSE_1_0.txt)
-///
-/// For more information, see http://www.boost.org
-///
-////////////////////////////////////////////////////////////////////////////////
-//------------------------------------------------------------------------------
-#ifndef writer_hpp__CBE52E51_7B06_4018_996A_63F9B7DF05AC
-#define writer_hpp__CBE52E51_7B06_4018_996A_63F9B7DF05AC
-#pragma once
-//------------------------------------------------------------------------------
-
-//------------------------------------------------------------------------------
-namespace boost
-{
-//------------------------------------------------------------------------------
-namespace gil
-{
-//------------------------------------------------------------------------------
-namespace io
-{
-//------------------------------------------------------------------------------
-
-
-////////////////////////////////////////////////////////////////////////////////
-/// \class formatted_image_traits
-/// ( forward declaration )
-////////////////////////////////////////////////////////////////////////////////
-
-template <class Backend>
-struct formatted_image_traits;
-
-namespace detail
-{
-//------------------------------------------------------------------------------
-
-
-template <class Writer, typename Target>
-class writer_extender
- :
- public output_device<Target>,
- public Writer
-{
-public:
- writer_extender( Target const target )
- :
- output_device<Target>( target ),
- Writer ( output_device<Target>::transform( target ) )
- {}
-
- writer_extender( Target const target, format_tag const file_format )
- :
- output_device<Target>( target ),
- Writer ( output_device<Target>::transform( target ), file_format )
- {}
-};
-
-
-////////////////////////////////////////////////////////////////////////////////
-// Wrappers that normalize writer interfaces.
-////////////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \class configure_on_write_writer
-/// \internal
-/// \brief Helper wrapper for backends/writers that first need to open the
-/// target/file and then be configured for the desired view.
-///
-////////////////////////////////////////////////////////////////////////////////
-
-struct configure_on_write_writer
-{
- template <typename Writer, typename WriterTarget, typename ViewDataHolder, format_tag DefaultFormat>
- class wrapper : public Writer
- {
- public:
- template <typename View>
- wrapper( WriterTarget const & target, View const & view, format_tag const specified_format = DefaultFormat )
- :
- Writer ( target, specified_format ),
- view_data_( view )
- {}
-
- void write_default() { Writer::write_default( view_data_ ); }
- void write () { Writer::write ( view_data_ ); }
-
- private:
- ViewDataHolder const view_data_;
- };
-
- template <typename Writer, typename WriterTarget, format_tag OnlyFormat>
- class single_format_writer_wrapper : public Writer
- {
- public:
- single_format_writer_wrapper( WriterTarget const & target, format_tag const specified_format = OnlyFormat )
- :
- Writer( target )
- {
- BOOST_VERIFY( specified_format == OnlyFormat );
- }
- };
-};
-
-
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \class open_on_write_writer
-/// \internal
-/// \brief Helper wrapper for backends/writers that first need to be configured
-/// for/created from the desired view and then open the target/file.
-///
-////////////////////////////////////////////////////////////////////////////////
-
-struct open_on_write_writer
-{
- template <typename Writer, typename WriterTarget, typename ViewDataHolder, format_tag DefaultFormat>
- class wrapper : public Writer
- {
- public:
- template <typename View>
- wrapper( WriterTarget const & target, View const & view, format_tag const specified_format = DefaultFormat )
- :
- Writer ( view ),
- target_ ( target ),
- specified_format_( specified_format )
- {}
-
- void write_default() { Writer::write_default( target_, specified_format_ ); }
- void write () { Writer::write ( target_, specified_format_ ); }
-
- private:
- typename call_traits<WriterTarget>::param_type const target_;
- format_tag const specified_format_;
- };
-
- template <typename Writer, typename WriterTarget, format_tag OnlyFormat>
- class single_format_writer_wrapper : public Writer
- {
- public:
- template <typename View>
- single_format_writer_wrapper( View const & view ) : Writer( view ) {}
-
- void write_default( WriterTarget const & target, format_tag const specified_format = OnlyFormat ) { BOOST_VERIFY( specified_format == OnlyFormat ); Writer::write_default( target ); }
- void write ( WriterTarget const & target, format_tag const specified_format = OnlyFormat ) { BOOST_VERIFY( specified_format == OnlyFormat ); Writer::write ( target ); }
- };
-};
-
-//------------------------------------------------------------------------------
-} // namespace detail
-
-template <class Backend, typename Target>
-struct writer_for
-{
-private:
- typedef typename formatted_image_traits<Backend>::supported_image_formats supported_image_formats;
-
- BOOST_STATIC_CONSTANT( format_tag, default_format = mpl::front<supported_image_formats>::type::value );
- BOOST_STATIC_CONSTANT( bool , single_format = mpl::size <supported_image_formats>::value == 1 );
-
- typedef typename mpl::has_key<typename formatted_image_traits<Backend>::native_sinks, Target>::type supported_by_native_writer_t;
-
- // The backend does not seem to provide a writer for the specified target...
- BOOST_STATIC_ASSERT
- ((
- supported_by_native_writer_t::value ||
- !unknown_output_device<Target>::value
- ));
-
- typedef typename mpl::if_
- <
- supported_by_native_writer_t,
- typename Backend::native_writer,
- detail::writer_extender<typename Backend::device_writer, Target>
- >::type base_writer_t;
-
- typedef typename mpl::if_c
- <
- single_format,
- typename base_writer_t:: BOOST_NESTED_TEMPLATE single_format_writer_wrapper<base_writer_t, Target, default_format>,
- base_writer_t
- >::type first_layer_wrapper;
-
-public:
- typedef typename base_writer_t:: BOOST_NESTED_TEMPLATE wrapper
- <
- first_layer_wrapper,
- Target,
- typename formatted_image_traits<Backend>::writer_view_data_t,
- default_format
- > type;
-};
-
-//------------------------------------------------------------------------------
-} // namespace io
-//------------------------------------------------------------------------------
-} // namespace gil
-//------------------------------------------------------------------------------
-} // namespace boost
-//------------------------------------------------------------------------------
-#endif // writer_hpp


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk