Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65882 - sandbox/gil/boost/gil/extension/io2
From: dsaritz_at_[hidden]
Date: 2010-10-10 12:50:31


Author: psiha
Date: 2010-10-10 12:50:29 EDT (Sun, 10 Oct 2010)
New Revision: 65882
URL: http://svn.boost.org/trac/boost/changeset/65882

Log:
Removed obsolete files.
Removed:
   sandbox/gil/boost/gil/extension/io2/dynamic_io.hpp
   sandbox/gil/boost/gil/extension/io2/gp_private_io.hpp
   sandbox/gil/boost/gil/extension/io2/gp_private_png_io.ipp
   sandbox/gil/boost/gil/extension/io2/jpeg_dynamic_io.hpp
   sandbox/gil/boost/gil/extension/io2/jpeg_io.hpp
   sandbox/gil/boost/gil/extension/io2/jpeg_io_private.hpp
   sandbox/gil/boost/gil/extension/io2/png_dynamic_io.hpp
   sandbox/gil/boost/gil/extension/io2/png_io.hpp
   sandbox/gil/boost/gil/extension/io2/png_io_libpng.ipp
   sandbox/gil/boost/gil/extension/io2/png_io_private.hpp
   sandbox/gil/boost/gil/extension/io2/tiff_dynamic_io.hpp
   sandbox/gil/boost/gil/extension/io2/tiff_io.hpp

Deleted: sandbox/gil/boost/gil/extension/io2/dynamic_io.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/dynamic_io.hpp 2010-10-10 12:50:29 EDT (Sun, 10 Oct 2010)
+++ (empty file)
@@ -1,80 +0,0 @@
-/*
- Copyright 2005-2007 Adobe Systems Incorporated
-
- Use, modification and distribution are subject to the Boost Software License,
- Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt).
-
- See http://opensource.adobe.com/gil for most recent version including documentation.
-*/
-/*************************************************************************************************/
-
-#ifndef GIL_DYNAMIC_IO_H
-#define GIL_DYNAMIC_IO_H
-
-/// \file
-/// \brief Generic io functions for dealing with dynamic images
-//
-/// \author Hailin Jin and Lubomir Bourdev \n
-/// Adobe Systems Incorporated
-/// \date 2005-2007 \n Last updated May 30, 2006
-
-#include <boost/mpl/at.hpp>
-#include <boost/mpl/size.hpp>
-#include "../../gil_config.hpp"
-#include "io_error.hpp"
-#include "../dynamic_image/any_image.hpp"
-
-namespace boost { namespace gil {
-
-namespace detail {
-
-template <long N>
-struct construct_matched_t {
- template <typename Images,typename Pred>
- static bool apply(any_image<Images>& im,Pred pred) {
- if (pred.template apply<typename mpl::at_c<Images,N-1>::type>()) {
- typename mpl::at_c<Images,N-1>::type x;
- im.move_in(x);
- return true;
- } else return construct_matched_t<N-1>::apply(im,pred);
- }
-};
-template <>
-struct construct_matched_t<0> {
- template <typename Images,typename Pred>
- static bool apply(any_image<Images>&,Pred) {return false;}
-};
-
-// A function object that can be passed to apply_operation.
-// Given a predicate IsSupported taking a view type and returning an MPL boolean,
-// calls the apply method of OpClass with the view if the given view IsSupported, or throws an exception otherwise
-template <typename IsSupported, typename OpClass>
-class dynamic_io_fnobj {
- OpClass* _op;
-
- template <typename View>
- void apply(const View& view,mpl::true_ ) {_op->apply(view);}
- template <typename View>
- void apply(const View& view,mpl::false_) {io_error("dynamic_io: unsupported view type for the given file format");}
-public:
- dynamic_io_fnobj(OpClass* op) : _op(op) {}
-
- typedef void result_type;
-
- template <typename View>
- void operator()(const View& view) {apply(view,typename IsSupported::template apply<View>::type());}
-};
-
-} // namespace detail
-
-/// \brief Within the any_image, constructs an image with the given dimensions
-/// and a type that satisfies the given predicate
-template <typename Images,typename Pred>
-inline bool construct_matched(any_image<Images>& im,Pred pred) {
- return detail::construct_matched_t<mpl::size<Images>::value>::apply(im,pred);
-}
-
-} } // namespace boost::gil
-
-#endif

Deleted: sandbox/gil/boost/gil/extension/io2/gp_private_io.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/gp_private_io.hpp 2010-10-10 12:50:29 EDT (Sun, 10 Oct 2010)
+++ (empty file)
@@ -1,148 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \file gp_private_io.hpp
-/// -----------------------
-///
-/// Base IO interface GDI+ 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
-///
-////////////////////////////////////////////////////////////////////////////////
-//------------------------------------------------------------------------------
-#pragma once
-#ifndef gp_private_io_hpp__7BCE38D9_64FA_4C63_8BAE_FE220717DBB9
-#define gp_private_io_hpp__7BCE38D9_64FA_4C63_8BAE_FE220717DBB9
-//------------------------------------------------------------------------------
-#include "gp_private_base.hpp"
-//------------------------------------------------------------------------------
-namespace boost
-{
-//------------------------------------------------------------------------------
-namespace gil
-{
-//------------------------------------------------------------------------------
-namespace detail
-{
-//------------------------------------------------------------------------------
-
-inline point2<std::ptrdiff_t> read_dimensions( detail::gp_image const & image ) {
- return image.dimensions();
-}
-
-inline point2<std::ptrdiff_t> read_dimensions( char const * const filename ) {
- return read_dimensions( gp_image( filename ) );
-}
-
-
-template <typename View>
-inline void read_view( gp_image const & image, View const & view ) {
- image.copy_to( view, ensure_dimensions_match(), ensure_formats_match() );
-}
-
-template <typename View>
-inline void read_view( char const * const filename, View const & view ) {
- read_view( gp_image( filename ), view );
-}
-
-
-template <typename Image>
-inline void read_image( gp_image const & gp_image, Image & gil_image ) {
- gp_image.copy_to_image( gil_image, synchronize_dimensions(), ensure_formats_match() );
-}
-
-template <typename Image>
-inline void read_image(const char* filename,Image& im) {
- read_image( gp_image( filename ), im );
-}
-
-template <typename Image>
-inline void read_image( wchar_t const * const filename, Image & im ) {
- read_image( gp_image( filename ), im );
-}
-
-
-template <typename View,typename CC>
-inline void read_and_convert_view( gp_image const & image, View const & view, CC cc ) {
- image.convert_to_view( view, cc );
-}
-
-template <typename View,typename CC>
-inline void read_and_convert_view( char const * const filename, View const & view, CC cc ) {
- read_and_convert_view( gp_image( filename ), view, cc );
-}
-
-
-template <typename View>
-inline void read_and_convert_view( gp_image const & image, View const & view ) {
- image.convert_to_view( view );
-}
-
-template <typename View>
-inline void read_and_convert_view( const char* filename, const View& view ) {
- read_and_convert_view( gp_image( filename ), view );
-}
-
-
-template <typename Image,typename CC>
-inline void read_and_convert_image( gp_image const & gp_image, Image & gil_image, CC const cc ) {
- gp_image.copy_to_image( gil_image, synchronize_dimensions() , cc );
-}
-
-template <typename Image,typename CC>
-inline void read_and_convert_image(const char* filename,Image& im,CC cc) {
- read_and_convert_image( gp_image( filename ), im, cc );
-}
-
-template <typename Image,typename CC>
-inline void read_and_convert_image( wchar_t const * const filename, Image & im, CC const & cc ) {
- read_and_convert_image( gp_image( filename ), im, cc );
-}
-
-
-template <typename Image>
-inline void read_and_convert_image( gp_image const & gp_image, Image & gil_image ) {
- gp_image.copy_to_image( gil_image, synchronize_dimensions() , synchronize_formats() );
-}
-
-template <typename Image>
-inline void read_and_convert_image(const char* filename,Image& im) {
- read_and_convert_image( gp_image( filename ), im );
-}
-
-template <typename Image>
-inline void read_and_convert_image( wchar_t const * const filename, Image & im ) {
- read_and_convert_image( gp_image( filename ), im );
-}
-
-template <typename Image>
-inline void read_and_convert_image( FILE * pFile, Image & im ) {
- read_and_convert_image( gp_FILE_image( pFile ), im );
-}
-
-template <typename Image>
-inline void read_and_convert_image( memory_chunk_t const & in_memory_image, Image & im ) {
- read_and_convert_image( gp_memory_image( in_memory_image ), im );
-}
-
-
-template <typename View>
-inline void png_write_view(const char* filename,const View& view) {
- detail::gp_image const m( view );
- m.save_to_png( filename );
-}
-
-
-//------------------------------------------------------------------------------
-} // namespace detail
-//------------------------------------------------------------------------------
-} // namespace gil
-//------------------------------------------------------------------------------
-} // namespace boost
-//------------------------------------------------------------------------------
-#endif // gp_private_io_hpp

Deleted: sandbox/gil/boost/gil/extension/io2/gp_private_png_io.ipp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/gp_private_png_io.ipp 2010-10-10 12:50:29 EDT (Sun, 10 Oct 2010)
+++ (empty file)
@@ -1,66 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \file gp_private_png_io.ipp
-/// ---------------------------
-///
-/// Base PNG IO interface GDI+ 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
-///
-////////////////////////////////////////////////////////////////////////////////
-//------------------------------------------------------------------------------
-#include "gp_private_io.hpp"
-//------------------------------------------------------------------------------
-namespace boost
-{
-//------------------------------------------------------------------------------
-namespace gil
-{
-//------------------------------------------------------------------------------
-
-template <typename Source>
-inline point2<std::ptrdiff_t> png_read_dimensions( Source const & source ) {
- return detail::read_dimensions( source );
-}
-
-
-template <typename View, typename Source>
-inline void png_read_view( Source const & source, View const & view ) {
- detail::read_view( source, view );
-}
-
-
-template <typename Image, typename Source>
-inline void png_read_image( Source const & source, Image & gil_image ) {
- detail::read_image( source, gil_image );
-}
-
-
-template <typename View,typename CC, typename Source>
-inline void png_read_and_convert_view( Source const & source, View const & view, CC cc ) {
- detail::read_and_convert_view( source, view, cc );
-}
-
-
-template <typename Image,typename CC, typename Source>
-inline void png_read_and_convert_image( Source const & source, Image & gil_image, CC cc ) {
- detail::read_and_convert_image( source, gil_image, cc );
-}
-
-template <typename Image, typename Source>
-inline void png_read_and_convert_image( Source const & source, Image & gil_image ) {
- detail::read_and_convert_image( source, gil_image );
-}
-
-
-//------------------------------------------------------------------------------
-} // namespace gil
-//------------------------------------------------------------------------------
-} // namespace boost
-//------------------------------------------------------------------------------

Deleted: sandbox/gil/boost/gil/extension/io2/jpeg_dynamic_io.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/jpeg_dynamic_io.hpp 2010-10-10 12:50:29 EDT (Sun, 10 Oct 2010)
+++ (empty file)
@@ -1,130 +0,0 @@
-/*
- Copyright 2005-2007 Adobe Systems Incorporated
-
- Use, modification and distribution are subject to the Boost Software License,
- Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt).
-
- See http://opensource.adobe.com/gil for most recent version including documentation.
-*/
-
-/*************************************************************************************************/
-
-#ifndef GIL_JPEG_DYNAMIC_IO_H
-#define GIL_JPEG_DYNAMIC_IO_H
-
-/// \file
-/// \brief Support for reading and writing JPEG files
-/// Requires libjpeg
-///
-/// \author Hailin Jin and Lubomir Bourdev \n
-/// Adobe Systems Incorporated
-/// \date 2005-2007 \n Last updated June 10, 2006
-
-#include <stdio.h>
-#include <string>
-#include <boost/mpl/bool.hpp>
-#include <boost/shared_ptr.hpp>
-#include "../dynamic_image/dynamic_image_all.hpp"
-#include "io_error.hpp"
-
-#include "jpeg_io.hpp"
-#include "jpeg_io_private.hpp"
-#include "dynamic_io.hpp"
-
-namespace boost { namespace gil {
-
-namespace detail {
-
-struct jpeg_write_is_supported {
- template<typename View> struct apply
- : public mpl::bool_<jpeg_write_support<View>::is_supported> {};
-};
-
-class jpeg_writer_dynamic : public jpeg_writer {
- int _quality;
-public:
- jpeg_writer_dynamic(FILE* file, int quality=100) : jpeg_writer(file) , _quality(quality) {}
- jpeg_writer_dynamic(const char* filename, int quality=100) : jpeg_writer(filename), _quality(quality) {}
-
- template <typename Views>
- void write_view(const any_image_view<Views>& runtime_view) {
- dynamic_io_fnobj<jpeg_write_is_supported, jpeg_writer> op(this);
- apply_operation(runtime_view,op);
- }
-};
-
-class jpeg_type_format_checker {
- J_COLOR_SPACE _color_type;
-public:
- jpeg_type_format_checker(J_COLOR_SPACE color_type_in) :
- _color_type(color_type_in) {}
- template <typename Image>
- bool apply() {
- return jpeg_read_support<typename Image::view_t>::color_type==_color_type;
- }
-};
-
-struct jpeg_read_is_supported {
- template<typename View> struct apply
- : public mpl::bool_<jpeg_read_support<View>::is_supported> {};
-};
-
-class jpeg_reader_dynamic : public jpeg_reader {
-public:
- jpeg_reader_dynamic(FILE* file) : jpeg_reader(file) {}
- jpeg_reader_dynamic(const char* filename) : jpeg_reader(filename){}
-
- template <typename Images>
- void read_image(any_image<Images>& im) {
- if (!construct_matched(im,detail::jpeg_type_format_checker(_cinfo.out_color_space))) {
- io_error("jpeg_reader_dynamic::read_image(): no matching image type between those of the given any_image and that of the file");
- } else {
- im.recreate(get_dimensions());
- dynamic_io_fnobj<jpeg_read_is_supported, jpeg_reader> op(this);
- apply_operation(view(im),op);
- }
- }
-};
-
-} // namespace detail
-
-
-/// \ingroup JPEG_IO
-/// \brief reads a JPEG image into a run-time instantiated image
-/// Opens the given JPEG file name, selects the first type in Images whose color space and channel are compatible to those of the image file
-/// and creates a new image of that type with the dimensions specified by the image file.
-/// Throws std::ios_base::failure if none of the types in Images are compatible with the type on disk.
-template <typename Images>
-inline void jpeg_read_image(const char* filename,any_image<Images>& im) {
- detail::jpeg_reader_dynamic m(filename);
- m.read_image(im);
-}
-
-/// \ingroup JPEG_IO
-/// \brief reads a JPEG image into a run-time instantiated image
-template <typename Images>
-inline void jpeg_read_image(const std::string& filename,any_image<Images>& im) {
- jpeg_read_image(filename.c_str(),im);
-}
-
-/// \ingroup JPEG_IO
-/// \brief Saves the currently instantiated view to a jpeg file specified by the given jpeg image file name.
-/// Throws std::ios_base::failure if the currently instantiated view type is not supported for writing by the I/O extension
-/// or if it fails to create the file.
-template <typename Views>
-inline void jpeg_write_view(const char* filename,const any_image_view<Views>& runtime_view) {
- detail::jpeg_writer_dynamic m(filename);
- m.write_view(runtime_view);
-}
-
-/// \ingroup JPEG_IO
-/// \brief Saves the currently instantiated view to a jpeg file specified by the given jpeg image file name.
-template <typename Views>
-inline void jpeg_write_view(const std::string& filename,const any_image_view<Views>& runtime_view) {
- jpeg_write_view(filename.c_str(),runtime_view);
-}
-
-} } // namespace boost::gil
-
-#endif

Deleted: sandbox/gil/boost/gil/extension/io2/jpeg_io.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/jpeg_io.hpp 2010-10-10 12:50:29 EDT (Sun, 10 Oct 2010)
+++ (empty file)
@@ -1,202 +0,0 @@
-/*
- Copyright 2005-2007 Adobe Systems Incorporated
-
- Use, modification and distribution are subject to the Boost Software License,
- Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt).
-
- See http://opensource.adobe.com/gil for most recent version including documentation.
-*/
-
-/*************************************************************************************************/
-
-#ifndef GIL_JPEG_IO_H
-#define GIL_JPEG_IO_H
-
-/// \file
-/// \brief Support for reading and writing JPEG files
-/// Requires libjpeg
-/// \author Hailin Jin and Lubomir Bourdev \n
-/// Adobe Systems Incorporated
-/// \date 2005-2007 \n Last updated September 24, 2006
-
-#include <cstdio>
-#include <algorithm>
-#include <string>
-#include <boost/static_assert.hpp>
-#include <boost/shared_ptr.hpp>
-extern "C" {
-#include <jpeglib.h>
-}
-#include "io_error.hpp"
-#include "jpeg_io_private.hpp"
-
-namespace boost { namespace gil {
-
-/// \ingroup JPEG_IO
-/// \brief Determines whether the given view type is supported for reading
-template <typename View>
-struct jpeg_read_support {
- BOOST_STATIC_CONSTANT(bool,is_supported=
- (detail::jpeg_read_support_private<typename channel_type<View>::type,
- typename color_space_type<View>::type>::is_supported));
- BOOST_STATIC_CONSTANT(J_COLOR_SPACE,color_type=
- (detail::jpeg_read_support_private<typename channel_type<View>::type,
- typename color_space_type<View>::type>::color_type));
- BOOST_STATIC_CONSTANT(bool, value=is_supported);
-};
-
-/// \ingroup JPEG_IO
-/// \brief Returns the width and height of the JPEG file at the specified location.
-/// Throws std::ios_base::failure if the location does not correspond to a valid JPEG file
-inline point2<std::ptrdiff_t> jpeg_read_dimensions(const char* filename) {
- detail::jpeg_reader m(filename);
- return m.get_dimensions();
-}
-
-/// \ingroup JPEG_IO
-/// \brief Returns the width and height of the JPEG file at the specified location.
-/// Throws std::ios_base::failure if the location does not correspond to a valid JPEG file
-inline point2<std::ptrdiff_t> jpeg_read_dimensions(const std::string& filename) {
- return jpeg_read_dimensions(filename.c_str());
-}
-
-/// \ingroup JPEG_IO
-/// \brief Loads the image specified by the given jpeg image file name into the given view.
-/// Triggers a compile assert if the view color space and channel depth are not supported by the JPEG library or by the I/O extension.
-/// Throws std::ios_base::failure if the file is not a valid JPEG file, or if its color space or channel depth are not
-/// compatible with the ones specified by View, or if its dimensions don't match the ones of the view.
-template <typename View>
-inline void jpeg_read_view(const char* filename,const View& view) {
- BOOST_STATIC_ASSERT(jpeg_read_support<View>::is_supported);
-
- detail::jpeg_reader m(filename);
- m.apply(view);
-}
-
-/// \ingroup JPEG_IO
-/// \brief Loads the image specified by the given jpeg image file name into the given view.
-template <typename View>
-inline void jpeg_read_view(const std::string& filename,const View& view) {
- jpeg_read_view(filename.c_str(),view);
-}
-
-/// \ingroup JPEG_IO
-/// \brief Allocates a new image whose dimensions are determined by the given jpeg image file, and loads the pixels into it.
-/// Triggers a compile assert if the image color space or channel depth are not supported by the JPEG library or by the I/O extension.
-/// Throws std::ios_base::failure if the file is not a valid JPEG file, or if its color space or channel depth are not
-/// compatible with the ones specified by Image
-template <typename Image>
-inline void jpeg_read_image(const char* filename,Image& im) {
- BOOST_STATIC_ASSERT(jpeg_read_support<typename Image::view_t>::is_supported);
-
- detail::jpeg_reader m(filename);
- m.read_image(im);
-}
-
-/// \ingroup JPEG_IO
-/// \brief Allocates a new image whose dimensions are determined by the given jpeg image file, and loads the pixels into it.
-template <typename Image>
-inline void jpeg_read_image(const std::string& filename,Image& im) {
- jpeg_read_image(filename.c_str(),im);
-}
-
-/// \ingroup JPEG_IO
-/// \brief Loads and color-converts the image specified by the given jpeg image file name into the given view.
-/// Throws std::ios_base::failure if the file is not a valid JPEG file, or if its dimensions don't match the ones of the view.
-template <typename View,typename CC>
-inline void jpeg_read_and_convert_view(const char* filename,const View& view,CC cc) {
- detail::jpeg_reader_color_convert<CC> m(filename,cc);
- m.apply(view);
-}
-
-/// \ingroup JPEG_IO
-/// \brief Loads and color-converts the image specified by the given jpeg image file name into the given view.
-/// Throws std::ios_base::failure if the file is not a valid JPEG file, or if its dimensions don't match the ones of the view.
-template <typename View>
-inline void jpeg_read_and_convert_view(const char* filename,const View& view) {
- detail::jpeg_reader_color_convert<default_color_converter> m(filename,default_color_converter());
- m.apply(view);
-}
-
-/// \ingroup JPEG_IO
-/// \brief Loads and color-converts the image specified by the given jpeg image file name into the given view.
-template <typename View,typename CC>
-inline void jpeg_read_and_convert_view(const std::string& filename,const View& view,CC cc) {
- jpeg_read_and_convert_view(filename.c_str(),view);
-}
-
-/// \ingroup JPEG_IO
-/// \brief Loads and color-converts the image specified by the given jpeg image file name into the given view.
-template <typename View>
-inline void jpeg_read_and_convert_view(const std::string& filename,const View& view) {
- jpeg_read_and_convert_view(filename.c_str(),view);
-}
-
-/// \ingroup JPEG_IO
-/// \brief Allocates a new image whose dimensions are determined by the given jpeg image file, loads and color-converts the pixels into it.
-/// Throws std::ios_base::failure if the file is not a valid JPEG file
-template <typename Image,typename CC>
-inline void jpeg_read_and_convert_image(const char* filename,Image& im,CC cc) {
- detail::jpeg_reader_color_convert<CC> m(filename,cc);
- m.read_image(im);
-}
-
-/// \ingroup JPEG_IO
-/// \brief Allocates a new image whose dimensions are determined by the given jpeg image file, loads and color-converts the pixels into it.
-/// Throws std::ios_base::failure if the file is not a valid JPEG file
-template <typename Image>
-inline void jpeg_read_and_convert_image(const char* filename,Image& im) {
- detail::jpeg_reader_color_convert<default_color_converter> m(filename,default_color_converter());
- m.read_image(im);
-}
-
-/// \ingroup JPEG_IO
-/// \brief Allocates a new image whose dimensions are determined by the given jpeg image file, loads and color-converts the pixels into it.
-template <typename Image,typename CC>
-inline void jpeg_read_and_convert_image(const std::string& filename,Image& im,CC cc) {
- jpeg_read_and_convert_image(filename.c_str(),im);
-}
-
-/// \ingroup JPEG_IO
-/// \brief Allocates a new image whose dimensions are determined by the given jpeg image file, loads and color-converts the pixels into it.
-template <typename Image>
-inline void jpeg_read_and_convert_image(const std::string& filename,Image& im) {
- jpeg_read_and_convert_image(filename.c_str(),im);
-}
-
-/// \ingroup JPEG_IO
-/// \brief Determines whether the given view type is supported for writing
-template <typename View>
-struct jpeg_write_support {
- BOOST_STATIC_CONSTANT(bool,is_supported=
- (detail::jpeg_write_support_private<typename channel_type<View>::type,
- typename color_space_type<View>::type>::is_supported));
- BOOST_STATIC_CONSTANT(J_COLOR_SPACE,color_type=
- (detail::jpeg_write_support_private<typename channel_type<View>::type,
- typename color_space_type<View>::type>::color_type));
- BOOST_STATIC_CONSTANT(bool, value=is_supported);
-};
-
-/// \ingroup JPEG_IO
-/// \brief Saves the view to a jpeg file specified by the given jpeg image file name.
-/// Triggers a compile assert if the view color space and channel depth are not supported by the JPEG library or by the I/O extension.
-/// Throws std::ios_base::failure if it fails to create the file.
-template <typename View>
-inline void jpeg_write_view(const char* filename,const View& view,int quality=100) {
- BOOST_STATIC_ASSERT(jpeg_write_support<View>::is_supported);
-
- detail::jpeg_writer m(filename);
- m.apply(view,quality);
-}
-
-/// \ingroup JPEG_IO
-/// \brief Saves the view to a jpeg file specified by the given jpeg image file name.
-template <typename View>
-inline void jpeg_write_view(const std::string& filename,const View& view,int quality=100) {
- jpeg_write_view(filename.c_str(),view,quality);
-}
-
-} } // namespace boost::gil
-
-#endif

Deleted: sandbox/gil/boost/gil/extension/io2/jpeg_io_private.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/jpeg_io_private.hpp 2010-10-10 12:50:29 EDT (Sun, 10 Oct 2010)
+++ (empty file)
@@ -1,226 +0,0 @@
-/*
- Copyright 2005-2007 Adobe Systems Incorporated
-
- Use, modification and distribution are subject to the Boost Software License,
- Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt).
-
- See http://opensource.adobe.com/gil for most recent version including documentation.
-*/
-
-/*************************************************************************************************/
-
-#ifndef GIL_JPEG_IO_PRIVATE_H
-#define GIL_JPEG_IO_PRIVATE_H
-
-/// \file
-/// \brief Internal support for reading and writing JPEG files
-/// \author Hailin Jin and Lubomir Bourdev \n
-/// Adobe Systems Incorporated
-/// \date 2005-2007 \n Last updated September 24, 2006
-
-#include <stdio.h>
-#include <boost/static_assert.hpp>
-#include <vector>
-#include "../../gil_all.hpp"
-#include "io_error.hpp"
-#include <jpeglib.h>
-
-namespace boost { namespace gil {
-
-namespace detail {
-
-// lbourdev: What is the advantage of having channel and colorspace together? Are there cases where they are interrelated?
-
-template <typename Channel,typename ColorSpace>
-struct jpeg_read_support_private {
- BOOST_STATIC_CONSTANT(bool,is_supported=false);
- BOOST_STATIC_CONSTANT(J_COLOR_SPACE,color_type=JCS_UNKNOWN);
-};
-template <>
-struct jpeg_read_support_private<bits8,gray_t> {
- BOOST_STATIC_ASSERT(BITS_IN_JSAMPLE==8);
- BOOST_STATIC_CONSTANT(bool,is_supported=true);
- BOOST_STATIC_CONSTANT(J_COLOR_SPACE,color_type=JCS_GRAYSCALE);
-};
-template <>
-struct jpeg_read_support_private<bits8,rgb_t> {
- BOOST_STATIC_ASSERT(BITS_IN_JSAMPLE==8);
- BOOST_STATIC_CONSTANT(bool,is_supported=true);
- BOOST_STATIC_CONSTANT(J_COLOR_SPACE,color_type=JCS_RGB);
-};
-template <>
-struct jpeg_read_support_private<bits8,cmyk_t> {
- BOOST_STATIC_ASSERT(BITS_IN_JSAMPLE==8);
- BOOST_STATIC_CONSTANT(bool,is_supported=true);
- BOOST_STATIC_CONSTANT(J_COLOR_SPACE,color_type=JCS_CMYK);
-};
-template <typename Channel,typename ColorSpace>
-struct jpeg_write_support_private {
- BOOST_STATIC_CONSTANT(bool,is_supported=false);
- BOOST_STATIC_CONSTANT(J_COLOR_SPACE,color_type=JCS_UNKNOWN);
-};
-template <>
-struct jpeg_write_support_private<bits8,gray_t> {
- BOOST_STATIC_ASSERT(BITS_IN_JSAMPLE==8);
- BOOST_STATIC_CONSTANT(bool,is_supported=true);
- BOOST_STATIC_CONSTANT(J_COLOR_SPACE,color_type=JCS_GRAYSCALE);
-};
-template <>
-struct jpeg_write_support_private<bits8,rgb_t> {
- BOOST_STATIC_ASSERT(BITS_IN_JSAMPLE==8);
- BOOST_STATIC_CONSTANT(bool,is_supported=true);
- BOOST_STATIC_CONSTANT(J_COLOR_SPACE,color_type=JCS_RGB);
-};
-template <>
-struct jpeg_write_support_private<bits8,cmyk_t> {
- BOOST_STATIC_ASSERT(BITS_IN_JSAMPLE==8);
- BOOST_STATIC_CONSTANT(bool,is_supported=true);
- BOOST_STATIC_CONSTANT(J_COLOR_SPACE,color_type=JCS_CMYK);
-};
-
-
-class jpeg_reader : public file_mgr {
-protected:
- jpeg_decompress_struct _cinfo;
- jpeg_error_mgr _jerr;
-
- void init() {
- _cinfo.err=jpeg_std_error(&_jerr);
- jpeg_create_decompress(&_cinfo);
- jpeg_stdio_src(&_cinfo,_fp.get());
- jpeg_read_header(&_cinfo,TRUE);
- }
-public:
- jpeg_reader(FILE* file) : file_mgr(file) { init(); }
- jpeg_reader(const char* filename) : file_mgr(filename, "rb") { init(); }
-
- ~jpeg_reader() { jpeg_destroy_decompress(&_cinfo); }
-
- template <typename View>
- void apply(const View& view) {
- jpeg_start_decompress(&_cinfo); // lbourdev: Can this return an error? You need to check and throw. Check all other library methods that can return an error state...
- io_error_if(_cinfo.data_precision!=8,"jpeg_reader::apply(): this image file is not supported");
- io_error_if(_cinfo.out_color_space!=jpeg_read_support_private<typename channel_type<View>::type,
- typename color_space_type<View>::type>::color_type,
- "jpeg_reader::apply(): input view type does not match the image file");
- io_error_if(view.dimensions() != get_dimensions(), "jpeg_reader::apply(): input view dimensions do not match the image file");
- std::vector<pixel<bits8,layout<typename color_space_type<View>::type> > > row(view.width());
- JSAMPLE* row_address=(JSAMPLE*)&row.front();
- for(int y=0;y<view.height();++y) {
- io_error_if(jpeg_read_scanlines(&_cinfo,(JSAMPARRAY)&row_address,1)!=1,
- "jpeg_reader::apply(): fail to read JPEG file");
- std::copy(row.begin(),row.end(),view.row_begin(y));
- }
- jpeg_finish_decompress(&_cinfo);
- }
-
- template <typename Image>
- void read_image(Image& im) {
- im.recreate(get_dimensions());
- apply(view(im));
- }
-
- point2<std::ptrdiff_t> get_dimensions() const {
- return point2<std::ptrdiff_t>(_cinfo.image_width,_cinfo.image_height);
- }
-};
-
-// This code will be simplified...
-template <typename CC>
-class jpeg_reader_color_convert : public jpeg_reader {
-private:
- CC _cc;
-public:
- jpeg_reader_color_convert(FILE* file,CC cc_in) : jpeg_reader(file),_cc(cc_in) {}
- jpeg_reader_color_convert(FILE* file) : jpeg_reader(file) {}
- jpeg_reader_color_convert(const char* filename,CC cc_in) : jpeg_reader(filename),_cc(cc_in) {}
- jpeg_reader_color_convert(const char* filename) : jpeg_reader(filename) {}
- template <typename View>
- void apply(const View& view) {
- jpeg_start_decompress(&_cinfo); // lbourdev: Can this return an error? You need to check and throw. Check all other library methods that can return an error state...
- io_error_if(_cinfo.data_precision!=8,"jpeg_reader_color_covert::apply(): this image file is not supported");
- io_error_if(view.dimensions() != get_dimensions(), "jpeg_reader_color_covert::apply(): input view dimensions don't match the image file");
- switch (_cinfo.out_color_space) {
- case JCS_GRAYSCALE: {
- std::vector<gray8_pixel_t> row(view.width());
- JSAMPLE* row_address=(JSAMPLE*)&row.front();
- for(int y=0;y<view.height();++y) {
- io_error_if(jpeg_read_scanlines(&_cinfo,(JSAMPARRAY)&row_address,1)!=1,
- "jpeg_reader_color_covert::apply(): fail to read JPEG file");
- std::transform(row.begin(),row.end(),view.row_begin(y),color_convert_deref_fn<gray8_ref_t, typename View::value_type,CC>(_cc));
- }
- break;
- }
- case JCS_RGB: {
- std::vector<rgb8_pixel_t> row(view.width());
- JSAMPLE* row_address=(JSAMPLE*)&row.front();
- for(int y=0;y<view.height();++y) {
- io_error_if(jpeg_read_scanlines(&_cinfo,(JSAMPARRAY)&row_address,1)!=1,
- "jpeg_reader_color_covert::apply(): fail to read JPEG file");
- std::transform(row.begin(),row.end(),view.row_begin(y),color_convert_deref_fn<rgb8_ref_t, typename View::value_type,CC>(_cc));
- }
- break;
- }
- case JCS_CMYK: {
- std::vector<cmyk8_pixel_t> row(view.width());
- JSAMPLE* row_address=(JSAMPLE*)&row.front();
- for(int y=0;y<view.height();++y) {
- io_error_if(jpeg_read_scanlines(&_cinfo,(JSAMPARRAY)&row_address,1)!=1,
- "jpeg_reader_color_covert::apply(): fail to read JPEG file");
- std::transform(row.begin(),row.end(),view.row_begin(y),color_convert_deref_fn<cmyk8_ref_t, typename View::value_type,CC>(_cc));
- }
- break;
- }
- default:
- io_error("jpeg_reader_color_covert::apply(): unknown color type");
- }
- jpeg_finish_decompress(&_cinfo);
- }
- template <typename Image>
- void read_image(Image& im) {
- im.recreate(get_dimensions());
- apply(view(im));
- }
-};
-
-class jpeg_writer : public file_mgr {
- jpeg_compress_struct _cinfo;
- jpeg_error_mgr _jerr;
-
- void init() {
- _cinfo.err=jpeg_std_error(&_jerr);
- jpeg_create_compress(&_cinfo);
- jpeg_stdio_dest(&_cinfo,_fp.get());
- }
-public:
- jpeg_writer(FILE* file) : file_mgr(file) { init(); }
- jpeg_writer(const char* filename) : file_mgr(filename, "wb") { init(); }
- ~jpeg_writer() { jpeg_destroy_compress(&_cinfo); }
-
- template <typename View>
- void apply(const View& view,int quality=100) {
- _cinfo.image_width = (JDIMENSION)view.width();
- _cinfo.image_height = (JDIMENSION)view.height();
- _cinfo.input_components=num_channels<View>::value;
- _cinfo.in_color_space = jpeg_write_support_private<typename channel_type<View>::type,
- typename color_space_type<View>::type>::color_type;
- jpeg_set_defaults(&_cinfo);
- jpeg_set_quality(&_cinfo, quality, TRUE);
- jpeg_start_compress(&_cinfo, TRUE);
- std::vector<pixel<bits8,layout<typename color_space_type<View>::type> > > row(view.width());
- JSAMPLE* row_address=(JSAMPLE*)&row.front();
- for (int y=0;y<view.height(); ++y) {
- std::copy(view.row_begin(y),view.row_end(y),row.begin());
- io_error_if(jpeg_write_scanlines(&_cinfo,(JSAMPARRAY)&row_address,1) != 1,
- "jpeg_writer::apply(): fail to write file");
- }
- jpeg_finish_compress(&_cinfo);
- }
-};
-
-} // namespace detail
-
-} } // namespace boost::gil
-
-#endif

Deleted: sandbox/gil/boost/gil/extension/io2/png_dynamic_io.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/png_dynamic_io.hpp 2010-10-10 12:50:29 EDT (Sun, 10 Oct 2010)
+++ (empty file)
@@ -1,141 +0,0 @@
-/*
- Copyright 2005-2007 Adobe Systems Incorporated
-
- Use, modification and distribution are subject to the Boost Software License,
- Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt).
-
- See http://opensource.adobe.com/gil for most recent version including documentation.
-*/
-
-/*************************************************************************************************/
-
-#ifndef GIL_PNG_DYNAMIC_IO_H
-#define GIL_PNG_DYNAMIC_IO_H
-
-/// \file
-/// \brief Support for reading and writing PNG files
-/// Requires libpng and zlib!
-///
-/// \author Hailin Jin and Lubomir Bourdev \n
-/// Adobe Systems Incorporated
-/// \date 2005-2007 \n Last updated June 10, 2006
-//
-// We are currently providing the following functions:
-// template <typename Images> void png_read_image(const char*,any_image<Images>&)
-// template <typename Images> void png_read_image(FILE*,any_image<Images>&,std::size_t)
-// template <typename Views> void png_write_view(const char*,const any_image_view<View>&)
-// template <typename Views> void png_write_view(FILE*,const any_image_view<View>&)
-
-
-#include <string>
-#include <stdio.h>
-#include <boost/mpl/bool.hpp>
-#include <boost/shared_ptr.hpp>
-#include "../dynamic_image/dynamic_image_all.hpp"
-#include "io_error.hpp"
-#include "png_io.hpp"
-#include "png_io_private.hpp"
-#include "dynamic_io.hpp"
-
-namespace boost { namespace gil {
-
-namespace detail {
-
-struct png_write_is_supported {
- template<typename View> struct apply
- : public mpl::bool_<png_write_support<View>::is_supported> {};
-};
-
-class png_writer_dynamic : public png_writer {
-public:
- png_writer_dynamic(FILE* file ) : png_writer(file) {}
- png_writer_dynamic(const char* filename) : png_writer(filename){}
-
- template <typename Views>
- void write_view(const any_image_view<Views>& runtime_view) {
- dynamic_io_fnobj<png_write_is_supported, png_writer> op(this);
- apply_operation(runtime_view,op);
- }
-};
-
-class png_type_format_checker {
- int _bit_depth;
- int _color_type;
-public:
- png_type_format_checker(int bit_depth_in,int color_type_in) :
- _bit_depth(bit_depth_in),_color_type(color_type_in) {}
- template <typename Image>
- bool apply() {
- return png_read_support<typename Image::view_t>::bit_depth==_bit_depth &&
- png_read_support<typename Image::view_t>::color_type==_color_type;
- }
-};
-
-struct png_read_is_supported {
- template<typename View> struct apply
- : public mpl::bool_<png_read_support<View>::is_supported> {};
-};
-
-class png_reader_dynamic : public png_reader {
-public:
- png_reader_dynamic(FILE* file) : png_reader(file) {}
- png_reader_dynamic(const char* filename) : png_reader(filename){}
-
- template <typename Images>
- void read_image(any_image<Images>& im) {
- png_uint_32 width, height;
- int bit_depth, color_type, interlace_type;
- png_get_IHDR(_png_ptr, _info_ptr,
- &width, &height,&bit_depth,&color_type,&interlace_type,
- int_p_NULL, int_p_NULL);
- if (!construct_matched(im,png_type_format_checker(bit_depth,color_type))) {
- io_error("png_reader_dynamic::read_image(): no matching image type between those of the given any_image and that of the file");
- } else {
- im.recreate(width,height);
- dynamic_io_fnobj<png_read_is_supported, png_reader> op(this);
- apply_operation(view(im),op);
- }
- }
-};
-
-} // namespace detail
-
-/// \ingroup PNG_IO
-/// \brief reads a PNG image into a run-time instantiated image
-/// Opens the given png file name, selects the first type in Images whose color space and channel are compatible to those of the image file
-/// and creates a new image of that type with the dimensions specified by the image file.
-/// Throws std::ios_base::failure if none of the types in Images are compatible with the type on disk.
-template <typename Images>
-inline void png_read_image(const char* filename,any_image<Images>& im) {
- detail::png_reader_dynamic m(filename);
- m.read_image(im);
-}
-
-/// \ingroup PNG_IO
-/// \brief reads a PNG image into a run-time instantiated image
-template <typename Images>
-inline void png_read_image(const std::string& filename,any_image<Images>& im) {
- png_read_image(filename.c_str(),im);
-}
-
-/// \ingroup PNG_IO
-/// \brief Saves the currently instantiated view to a png file specified by the given png image file name.
-/// Throws std::ios_base::failure if the currently instantiated view type is not supported for writing by the I/O extension
-/// or if it fails to create the file.
-template <typename Views>
-inline void png_write_view(const char* filename,const any_image_view<Views>& runtime_view) {
- detail::png_writer_dynamic m(filename);
- m.write_view(runtime_view);
-}
-
-/// \ingroup PNG_IO
-/// \brief Saves the currently instantiated view to a png file specified by the given png image file name.
-template <typename Views>
-inline void png_write_view(const std::string& filename,const any_image_view<Views>& runtime_view) {
- png_write_view(filename.c_str(),runtime_view);
-}
-
-} } // namespace boost::gil
-
-#endif

Deleted: sandbox/gil/boost/gil/extension/io2/png_io.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/png_io.hpp 2010-10-10 12:50:29 EDT (Sun, 10 Oct 2010)
+++ (empty file)
@@ -1,169 +0,0 @@
-/*
- Copyright 2005-2007 Adobe Systems Incorporated
-
- Use, modification and distribution are subject to the Boost Software License,
- Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt).
-
- See http://opensource.adobe.com/gil for most recent version including documentation.
-*/
-
-/*************************************************************************************************/
-
-#ifndef GIL_PNG_IO_H
-#define GIL_PNG_IO_H
-
-/// \file
-/// \brief Support for reading and writing PNG files
-/// Requires libpng and zlib! (or GDI+)
-//
-// We are currently providing the following functions:
-// point2<std::ptrdiff_t> png_read_dimensions(const char*)
-// template <typename View> void png_read_view(const char*,const View&)
-// template <typename View> void png_read_image(const char*,image<View>&)
-// template <typename View> void png_write_view(const char*,const View&)
-// template <typename View> struct png_read_support;
-// template <typename View> struct png_write_support;
-//
-/// \author Hailin Jin and Lubomir Bourdev \n
-/// Adobe Systems Incorporated
-/// \date 2005-2007 \n Last updated September 24, 2006
-
-#include <cstddef>
-#include <string>
-
-#include "../../gil_config.hpp"
-#include "../../utilities.hpp"
-
-namespace boost { namespace gil {
-
-/// \ingroup PNG_IO
-/// \brief Returns the width and height of the PNG file at the specified location.
-/// Throws std::ios_base::failure if the location does not correspond to a valid PNG file
-template <typename Source>
-point2<std::ptrdiff_t> png_read_dimensions( Source const & );
-
-/// \ingroup PNG_IO
-/// \brief Returns the width and height of the PNG file at the specified location.
-/// Throws std::ios_base::failure if the location does not correspond to a valid PNG file
-inline point2<std::ptrdiff_t> png_read_dimensions(const std::string& filename) {
- return png_read_dimensions(filename.c_str());
-}
-
-/// \ingroup PNG_IO
-/// \brief Loads the image specified by the given png image file name into the given view.
-/// Triggers a compile assert if the view color space and channel depth are not supported by the PNG library or by the I/O extension.
-/// Throws std::ios_base::failure if the file is not a valid PNG file, or if its color space or channel depth are not
-/// compatible with the ones specified by View, or if its dimensions don't match the ones of the view.
-template <typename View, typename Source>
-void png_read_view( Source const &, View const & );
-
-/// \ingroup PNG_IO
-/// \brief Loads the image specified by the given png image file name into the given view.
-template <typename View>
-inline void png_read_view(const std::string& filename,const View& view) {
- png_read_view(filename.c_str(),view);
-}
-
-/// \ingroup PNG_IO
-/// \brief Allocates a new image whose dimensions are determined by the given png image file, and loads the pixels into it.
-/// Triggers a compile assert if the image color space or channel depth are not supported by the PNG library or by the I/O extension.
-/// Throws std::ios_base::failure if the file is not a valid PNG file, or if its color space or channel depth are not
-/// compatible with the ones specified by Image
-template <typename Image, typename Source>
-void png_read_image( Source const &, Image & );
-
-/// \ingroup PNG_IO
-/// \brief Allocates a new image whose dimensions are determined by the given png image file, and loads the pixels into it.
-template <typename Image>
-inline void png_read_image(const std::string& filename,Image& im) {
- png_read_image(filename.c_str(),im);
-}
-
-/// \ingroup PNG_IO
-/// \brief Loads the image specified by the given png image file name and color-converts it into the given view.
-/// Throws std::ios_base::failure if the file is not a valid PNG file, or if its dimensions don't match the ones of the view.
-template <typename View, typename CC, typename Source>
-void png_read_and_convert_view( Source const &, View const &, CC );
-
-/// \ingroup PNG_IO
-/// \brief Loads the image specified by the given png image file name and color-converts it into the given view.
-/// Throws std::ios_base::failure if the file is not a valid PNG file, or if its dimensions don't match the ones of the view.
-template <typename View, typename Source>
-void png_read_and_convert_view( Source const &, View const & );
-
-/// \ingroup PNG_IO
-/// \brief Loads the image specified by the given png image file name and color-converts it into the given view.
-template <typename View,typename CC>
-inline void png_read_and_convert_view(const std::string& filename,const View& view,CC cc) {
- png_read_and_convert_view(filename.c_str(),view,cc);
-}
-
-/// \ingroup PNG_IO
-/// \brief Loads the image specified by the given png image file name and color-converts it into the given view.
-template <typename View>
-inline void png_read_and_convert_view(const std::string& filename,const View& view) {
- png_read_and_convert_view(filename.c_str(),view);
-}
-
-/// \ingroup PNG_IO
-/// \brief Allocates a new image whose dimensions are determined by the given png image file, loads and color-converts the pixels into it.
-/// Throws std::ios_base::failure if the file is not a valid PNG file
-template <typename Image,typename CC, typename Source>
-void png_read_and_convert_image( Source const &, Image &, CC );
-
-/// \ingroup PNG_IO
-/// \brief Allocates a new image whose dimensions are determined by the given png image file, loads and color-converts the pixels into it.
-/// Throws std::ios_base::failure if the file is not a valid PNG file
-template <typename Image, typename Source>
-void png_read_and_convert_image( Source const &, Image & );
-
-/// \ingroup PNG_IO
-/// \brief Allocates a new image whose dimensions are determined by the given png image file, loads and color-converts the pixels into it.
-template <typename Image,typename CC>
-inline void png_read_and_convert_image(const std::string& filename,Image& im,CC cc) {
- png_read_and_convert_image(filename.c_str(),im,cc);
-}
-
-/// \ingroup PNG_IO
-/// \brief Allocates a new image whose dimensions are determined by the given png image file, loads and color-converts the pixels into it.
-template <typename Image>
-inline void png_read_and_convert_image(const std::string& filename,Image& im) {
- png_read_and_convert_image(filename.c_str(),im);
-}
-
-/// \ingroup PNG_IO
-/// \brief Saves the view to a png file specified by the given png image file name.
-/// Triggers a compile assert if the view color space and channel depth are not supported by the PNG library or by the I/O extension.
-/// Throws std::ios_base::failure if it fails to create the file.
-template <typename View, typename Source>
-void png_write_view( Source const &, View const & );
-
-/// \ingroup PNG_IO
-/// \brief Saves the view to a png file specified by the given png image file name.
-template <typename View>
-inline void png_write_view(const std::string& filename,const View& view) {
- png_write_view(filename.c_str(),view);
-}
-
-} } // namespace boost::gil
-
-
-#if !defined( _WIN32 )
- #undef BOOST_GIL_USE_NATIVE_IO
-#endif // (un)supported platforms for native IO
-
-
-#ifdef BOOST_GIL_USE_NATIVE_IO
-
- #ifdef _WIN32
- #include "gp_private_png_io.ipp"
- #endif
-
-#else // BOOST_GIL_USE_NATIVE_IO
-
- #include "png_io_libpng.ipp"
-
-#endif // BOOST_GIL_USE_NATIVE_IO
-
-#endif

Deleted: sandbox/gil/boost/gil/extension/io2/png_io_libpng.ipp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/png_io_libpng.ipp 2010-10-10 12:50:29 EDT (Sun, 10 Oct 2010)
+++ (empty file)
@@ -1,145 +0,0 @@
-/*
- Copyright 2005-2007 Adobe Systems Incorporated
-
- Use, modification and distribution are subject to the Boost Software License,
- Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt).
-
- See http://opensource.adobe.com/gil for most recent version including documentation.
-*/
-
-/*************************************************************************************************/
-
-#include <cstdio>
-#include <string>
-extern "C" {
-#include "png.h"
-}
-#include <boost/static_assert.hpp>
-#include "../../gil_config.hpp"
-#include "../../utilities.hpp"
-#include "io_error.hpp"
-#include "png_io_private.hpp"
-
-namespace boost { namespace gil {
-
-
-/// \ingroup PNG_IO
-/// \brief Returns the width and height of the PNG file at the specified location.
-/// Throws std::ios_base::failure if the location does not correspond to a valid PNG file
-template <typename Source>
-point2<std::ptrdiff_t> png_read_dimensions( Source const & source ) {
- detail::png_reader m(source);
- return m.get_dimensions();
-}
-
-/// \ingroup PNG_IO
-/// \brief Determines whether the given view type is supported for reading
-template <typename View>
-struct png_read_support {
- BOOST_STATIC_CONSTANT(bool,is_supported=
- (detail::png_read_support_private<typename channel_type<View>::type,
- typename color_space_type<View>::type>::is_supported));
- BOOST_STATIC_CONSTANT(int,bit_depth=
- (detail::png_read_support_private<typename channel_type<View>::type,
- typename color_space_type<View>::type>::bit_depth));
- BOOST_STATIC_CONSTANT(int,color_type=
- (detail::png_read_support_private<typename channel_type<View>::type,
- typename color_space_type<View>::type>::color_type));
- BOOST_STATIC_CONSTANT(bool, value=is_supported);
-};
-
-/// \ingroup PNG_IO
-/// \brief Loads the image specified by the given png image file name into the given view.
-/// Triggers a compile assert if the view color space and channel depth are not supported by the PNG library or by the I/O extension.
-/// Throws std::ios_base::failure if the file is not a valid PNG file, or if its color space or channel depth are not
-/// compatible with the ones specified by View, or if its dimensions don't match the ones of the view.
-template <typename View, typename Source>
-void png_read_view( Source const & source, View const & view ) {
- BOOST_STATIC_ASSERT(png_read_support<View>::is_supported);
- detail::png_reader m(source);
- m.apply(view);
-}
-
-
-/// \ingroup PNG_IO
-/// \brief Allocates a new image whose dimensions are determined by the given png image file, and loads the pixels into it.
-/// Triggers a compile assert if the image color space or channel depth are not supported by the PNG library or by the I/O extension.
-/// Throws std::ios_base::failure if the file is not a valid PNG file, or if its color space or channel depth are not
-/// compatible with the ones specified by Image
-template <typename Image, typename Source>
-void png_read_image( Source const & source, Image & im ) {
- BOOST_STATIC_ASSERT(png_read_support<typename Image::view_t>::is_supported);
- detail::png_reader m(source);
- m.read_image(im);
-}
-
-
-/// \ingroup PNG_IO
-/// \brief Loads the image specified by the given png image file name and color-converts it into the given view.
-/// Throws std::ios_base::failure if the file is not a valid PNG file, or if its dimensions don't match the ones of the view.
-template <typename View, typename CC, typename Source>
-void png_read_and_convert_view( Source const & source, View const & view, CC cc ) {
- detail::png_reader_color_convert<CC> m(source,cc);
- m.apply(view);
-}
-
-/// \ingroup PNG_IO
-/// \brief Loads the image specified by the given png image file name and color-converts it into the given view.
-/// Throws std::ios_base::failure if the file is not a valid PNG file, or if its dimensions don't match the ones of the view.
-template <typename View, typename Source>
-void png_read_and_convert_view( Source const & source, View const & view ) {
- detail::png_reader_color_convert<default_color_converter> m(source,default_color_converter());
- m.apply(view);
-}
-
-
-/// \ingroup PNG_IO
-/// \brief Allocates a new image whose dimensions are determined by the given png image file, loads and color-converts the pixels into it.
-/// Throws std::ios_base::failure if the file is not a valid PNG file
-template <typename Image,typename CC, typename Source>
-void png_read_and_convert_image( Source const & source, Image & im, CC cc ) {
- detail::png_reader_color_convert<CC> m(source,cc);
- m.read_image(im);
-}
-
-
-/// \ingroup PNG_IO
-/// \brief Allocates a new image whose dimensions are determined by the given png image file, loads and color-converts the pixels into it.
-/// Throws std::ios_base::failure if the file is not a valid PNG file
-template <typename Image, typename Source>
-void png_read_and_convert_image( Source const & source, Image & im ) {
- detail::png_reader_color_convert<default_color_converter> m(source,default_color_converter());
- m.read_image(im);
-}
-
-
-/// \ingroup PNG_IO
-/// \brief Determines whether the given view type is supported for writing
-template <typename View>
-struct png_write_support {
- BOOST_STATIC_CONSTANT(bool,is_supported=
- (detail::png_write_support_private<typename channel_type<View>::type,
- typename color_space_type<View>::type>::is_supported));
- BOOST_STATIC_CONSTANT(int,bit_depth=
- (detail::png_write_support_private<typename channel_type<View>::type,
- typename color_space_type<View>::type>::bit_depth));
- BOOST_STATIC_CONSTANT(int,color_type=
- (detail::png_write_support_private<typename channel_type<View>::type,
- typename color_space_type<View>::type>::color_type));
- BOOST_STATIC_CONSTANT(bool, value=is_supported);
-};
-
-/// \ingroup PNG_IO
-/// \brief Saves the view to a png file specified by the given png image file name.
-/// Triggers a compile assert if the view color space and channel depth are not supported by the PNG library or by the I/O extension.
-/// Throws std::ios_base::failure if it fails to create the file.
-template <typename View, typename Source>
-void png_write_view( Source const & source, View const & view ) {
- BOOST_STATIC_ASSERT(png_write_support<View>::is_supported);
- detail::png_writer m(source);
- m.apply(view);
-}
-
-
-} } // namespace boost::gil

Deleted: sandbox/gil/boost/gil/extension/io2/png_io_private.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/png_io_private.hpp 2010-10-10 12:50:29 EDT (Sun, 10 Oct 2010)
+++ (empty file)
@@ -1,360 +0,0 @@
-/*
- Copyright 2005-2007 Adobe Systems Incorporated
-
- Use, modification and distribution are subject to the Boost Software License,
- Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt).
-
- See http://stlab.adobe.com/gil for most recent version including documentation.
-*/
-/*************************************************************************************************/
-
-#ifndef GIL_PNG_IO_PRIVATE_H
-#define GIL_PNG_IO_PRIVATE_H
-
-/// \file
-/// \brief Internal support for reading and writing PNG files
-/// \author Hailin Jin and Lubomir Bourdev \n
-/// Adobe Systems Incorporated
-/// \date 2005-2007 \n Last updated August 14, 2007
-
-#include <algorithm>
-#include <vector>
-#include <boost/static_assert.hpp>
-#include "../../gil_all.hpp"
-#include "io_error.hpp"
-#include <png.h>
-
-namespace boost { namespace gil {
-
-namespace detail {
-
-static const std::size_t PNG_BYTES_TO_CHECK = 4;
-
-// lbourdev: These can be greatly simplified, for example:
-template <typename Cs> struct png_color_type {BOOST_STATIC_CONSTANT(int,color_type=0);};
-template<> struct png_color_type<gray_t> { BOOST_STATIC_CONSTANT(int,color_type=PNG_COLOR_TYPE_GRAY); };
-template<> struct png_color_type<rgb_t> { BOOST_STATIC_CONSTANT(int,color_type=PNG_COLOR_TYPE_RGB); };
-template<> struct png_color_type<rgba_t> { BOOST_STATIC_CONSTANT(int,color_type=PNG_COLOR_TYPE_RGBA); };
-
-template <typename Channel,typename ColorSpace> struct png_is_supported {BOOST_STATIC_CONSTANT(bool,value=false);};
-template <> struct png_is_supported<bits8,gray_t> {BOOST_STATIC_CONSTANT(bool,value=true);};
-template <> struct png_is_supported<bits8,rgb_t> {BOOST_STATIC_CONSTANT(bool,value=true);};
-template <> struct png_is_supported<bits8,rgba_t> {BOOST_STATIC_CONSTANT(bool,value=true);};
-template <> struct png_is_supported<bits16,gray_t> {BOOST_STATIC_CONSTANT(bool,value=true);};
-template <> struct png_is_supported<bits16,rgb_t> {BOOST_STATIC_CONSTANT(bool,value=true);};
-template <> struct png_is_supported<bits16,rgba_t> {BOOST_STATIC_CONSTANT(bool,value=true);};
-
-template <typename Channel> struct png_bit_depth {BOOST_STATIC_CONSTANT(int,bit_depth=sizeof(Channel)*8);};
-
-template <typename Channel,typename ColorSpace>
-struct png_read_support_private {
- BOOST_STATIC_CONSTANT(bool,is_supported=false);
- BOOST_STATIC_CONSTANT(int,bit_depth=0);
- BOOST_STATIC_CONSTANT(int,color_type=0);
-};
-template <>
-struct png_read_support_private<bits8,gray_t> {
- BOOST_STATIC_CONSTANT(bool,is_supported=true);
- BOOST_STATIC_CONSTANT(int,bit_depth=8);
- BOOST_STATIC_CONSTANT(int,color_type=PNG_COLOR_TYPE_GRAY);
-};
-template <>
-struct png_read_support_private<bits8,rgb_t> {
- BOOST_STATIC_CONSTANT(bool,is_supported=true);
- BOOST_STATIC_CONSTANT(int,bit_depth=8);
- BOOST_STATIC_CONSTANT(int,color_type=PNG_COLOR_TYPE_RGB);
-};
-template <>
-struct png_read_support_private<bits8,rgba_t> {
- BOOST_STATIC_CONSTANT(bool,is_supported=true);
- BOOST_STATIC_CONSTANT(int,bit_depth=8);
- BOOST_STATIC_CONSTANT(int,color_type=PNG_COLOR_TYPE_RGBA);
-};
-template <>
-struct png_read_support_private<bits16,gray_t> {
- BOOST_STATIC_CONSTANT(bool,is_supported=true);
- BOOST_STATIC_CONSTANT(int,bit_depth=16);
- BOOST_STATIC_CONSTANT(int,color_type=PNG_COLOR_TYPE_GRAY);
-};
-template <>
-struct png_read_support_private<bits16,rgb_t> {
- BOOST_STATIC_CONSTANT(bool,is_supported=true);
- BOOST_STATIC_CONSTANT(int,bit_depth=16);
- BOOST_STATIC_CONSTANT(int,color_type=PNG_COLOR_TYPE_RGB);
-};
-template <>
-struct png_read_support_private<bits16,rgba_t> {
- BOOST_STATIC_CONSTANT(bool,is_supported=true);
- BOOST_STATIC_CONSTANT(int,bit_depth=16);
- BOOST_STATIC_CONSTANT(int,color_type=PNG_COLOR_TYPE_RGBA);
-};
-
-template <typename Channel,typename ColorSpace>
-struct png_write_support_private {
- BOOST_STATIC_CONSTANT(bool,is_supported=false);
- BOOST_STATIC_CONSTANT(int,bit_depth=0);
- BOOST_STATIC_CONSTANT(int,color_type=0);
-};
-template <>
-struct png_write_support_private<bits8,gray_t> {
- BOOST_STATIC_CONSTANT(bool,is_supported=true);
- BOOST_STATIC_CONSTANT(int,bit_depth=8);
- BOOST_STATIC_CONSTANT(int,color_type=PNG_COLOR_TYPE_GRAY);
-};
-template <>
-struct png_write_support_private<bits8,rgb_t> {
- BOOST_STATIC_CONSTANT(bool,is_supported=true);
- BOOST_STATIC_CONSTANT(int,bit_depth=8);
- BOOST_STATIC_CONSTANT(int,color_type=PNG_COLOR_TYPE_RGB);
-};
-template <>
-struct png_write_support_private<bits8,rgba_t> {
- BOOST_STATIC_CONSTANT(bool,is_supported=true);
- BOOST_STATIC_CONSTANT(int,bit_depth=8);
- BOOST_STATIC_CONSTANT(int,color_type=PNG_COLOR_TYPE_RGBA);
-};
-template <>
-struct png_write_support_private<bits16,gray_t> {
- BOOST_STATIC_CONSTANT(bool,is_supported=true);
- BOOST_STATIC_CONSTANT(int,bit_depth=16);
- BOOST_STATIC_CONSTANT(int,color_type=PNG_COLOR_TYPE_GRAY);
-};
-template <>
-struct png_write_support_private<bits16,rgb_t> {
- BOOST_STATIC_CONSTANT(bool,is_supported=true);
- BOOST_STATIC_CONSTANT(int,bit_depth=16);
- BOOST_STATIC_CONSTANT(int,color_type=PNG_COLOR_TYPE_RGB);
-};
-template <>
-struct png_write_support_private<bits16,rgba_t> {
- BOOST_STATIC_CONSTANT(bool,is_supported=true);
- BOOST_STATIC_CONSTANT(int,bit_depth=16);
- BOOST_STATIC_CONSTANT(int,color_type=PNG_COLOR_TYPE_RGBA);
-};
-
-class png_reader : public file_mgr {
-protected:
- png_structp _png_ptr;
- png_infop _info_ptr;
-
- void init() {
- char buf[PNG_BYTES_TO_CHECK];
- // read in some of the signature bytes
- io_error_if(fread(buf, 1, PNG_BYTES_TO_CHECK, get()) != detail::PNG_BYTES_TO_CHECK,
- "png_check_validity: fail to read file");
- // compare the first PNG_BYTES_TO_CHECK bytes of the signature.
- io_error_if(png_sig_cmp((png_bytep)buf, (png_size_t)0, detail::PNG_BYTES_TO_CHECK)!=0,
- "png_check_validity: invalid png file");
-
- _png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,NULL,NULL,NULL);
- io_error_if(_png_ptr==NULL,"png_get_file_size: fail to call png_create_write_struct()");
- // allocate/initialize the image information data
- _info_ptr = png_create_info_struct(_png_ptr);
- if (_info_ptr == NULL) {
- png_destroy_read_struct(&_png_ptr,0/*png_infopp_NULL*/,0/*png_infopp_NULL*/);
- io_error("png_get_file_size: fail to call png_create_info_struct()");
- }
- if (setjmp(png_jmpbuf(_png_ptr))) {
- //free all of the memory associated with the png_ptr and info_ptr
- png_destroy_read_struct(&_png_ptr, &_info_ptr, 0/*png_infopp_NULL*/);
- io_error("png_get_file_size: fail to call setjmp()");
- }
- png_init_io(_png_ptr, get());
- png_set_sig_bytes(_png_ptr,PNG_BYTES_TO_CHECK);
- png_read_info(_png_ptr, _info_ptr);
- if (little_endian() && png_get_bit_depth(_png_ptr,_info_ptr)>8)
- png_set_swap(_png_ptr);
- }
-public:
- png_reader(FILE* file ) : file_mgr(file) { init(); }
- png_reader(const char* filename) : file_mgr(filename, "rb") { init(); }
-
- ~png_reader() {
- png_destroy_read_struct(&_png_ptr,&_info_ptr,0/*png_infopp_NULL*/);
- }
- point2<std::ptrdiff_t> get_dimensions() {
- return point2<std::ptrdiff_t>(png_get_image_width(_png_ptr,_info_ptr),
- png_get_image_height(_png_ptr,_info_ptr));
- }
- template <typename View>
- void apply(const View& view) {
- png_uint_32 width, height;
- int bit_depth, color_type, interlace_type;
- png_get_IHDR(_png_ptr, _info_ptr,
- &width, &height,&bit_depth,&color_type,&interlace_type,
- 0/*int_p_NULL*/, 0/*int_p_NULL*/);
- io_error_if(((png_uint_32)view.width()!=width || (png_uint_32)view.height()!= height),
- "png_read_view: input view size does not match PNG file size");
-
- if(png_read_support_private<typename channel_type<View>::type,
- typename color_space_type<View>::type>::bit_depth!=bit_depth ||
- png_read_support_private<typename channel_type<View>::type,
- typename color_space_type<View>::type>::color_type!=color_type)
- io_error("png_read_view: input view type is incompatible with the image type");
-
- std::vector<pixel<typename channel_type<View>::type,
- layout<typename color_space_type<View>::type> > > row(width);
- for(png_uint_32 y=0;y<height;++y) {
- png_read_row(_png_ptr,(png_bytep)&row.front(),NULL);
- std::copy(row.begin(),row.end(),view.row_begin(y));
- }
- png_read_end(_png_ptr,NULL);
- }
-
- template <typename Image>
- void read_image(Image& im) {
- im.recreate(get_dimensions());
- apply(view(im));
- }
-};
-
-// This code will be simplified...
-template <typename CC>
-class png_reader_color_convert : public png_reader {
-private:
- CC _cc;
-public:
- png_reader_color_convert(FILE* file ,CC cc_in) : png_reader(file),_cc(cc_in) {}
- png_reader_color_convert(FILE* file ) : png_reader(file) {}
- png_reader_color_convert(const char* filename,CC cc_in) : png_reader(filename),_cc(cc_in) {}
- png_reader_color_convert(const char* filename) : png_reader(filename) {}
- template <typename View>
- void apply(const View& view) {
- png_uint_32 width, height;
- int bit_depth, color_type, interlace_type;
- png_get_IHDR(_png_ptr, _info_ptr,
- &width, &height,&bit_depth,&color_type,&interlace_type,
- 0/*int_p_NULL*/, 0/*int_p_NULL*/);
- io_error_if(((png_uint_32)view.width()!=width || (png_uint_32)view.height()!= height),
- "png_reader_color_convert::apply(): input view size does not match PNG file size");
- switch (color_type) {
- case PNG_COLOR_TYPE_GRAY:
- switch (bit_depth) {
- case 8: {
- std::vector<gray8_pixel_t> row(width);
- for(png_uint_32 y=0;y<height;++y) {
- png_read_row(_png_ptr,(png_bytep)&row.front(),NULL);
- std::transform(row.begin(),row.end(),view.row_begin(y),color_convert_deref_fn<gray8_ref_t,typename View::value_type,CC>(_cc));
- }
- break;
- }
- case 16: {
- std::vector<gray16_pixel_t> row(width);
- for(png_uint_32 y=0;y<height;++y) {
- png_read_row(_png_ptr,(png_bytep)&row.front(),NULL);
- std::transform(row.begin(),row.end(),view.row_begin(y),color_convert_deref_fn<gray16_ref_t,typename View::value_type,CC>(_cc));
- }
- break;
- }
- default: io_error("png_reader_color_convert::apply(): unknown combination of color type and bit depth");
- }
- break;
- case PNG_COLOR_TYPE_RGB:
- switch (bit_depth) {
- case 8: {
- std::vector<rgb8_pixel_t> row(width);
- for(png_uint_32 y=0;y<height;++y) {
- png_read_row(_png_ptr,(png_bytep)&row.front(),NULL);
- std::transform(row.begin(),row.end(),view.row_begin(y),color_convert_deref_fn<rgb8_ref_t,typename View::value_type,CC>(_cc));
- }
- break;
- }
- case 16: {
- std::vector<rgb16_pixel_t> row(width);
- for(png_uint_32 y=0;y<height;++y) {
- png_read_row(_png_ptr,(png_bytep)&row.front(),NULL);
- std::transform(row.begin(),row.end(),view.row_begin(y),color_convert_deref_fn<rgb16_ref_t,typename View::value_type,CC>(_cc));
- }
- break;
- }
- default: io_error("png_reader_color_convert::apply(): unknown combination of color type and bit depth");
- }
- break;
- case PNG_COLOR_TYPE_RGBA:
- switch (bit_depth) {
- case 8: {
- std::vector<rgba8_pixel_t> row(width);
- for(png_uint_32 y=0;y<height;++y) {
- png_read_row(_png_ptr,(png_bytep)&row.front(),NULL);
- std::transform(row.begin(),row.end(),view.row_begin(y),color_convert_deref_fn<rgba8_ref_t,typename View::value_type,CC>(_cc));
- }
- break;
- }
- case 16: {
- std::vector<rgba16_pixel_t> row(width);
- for(png_uint_32 y=0;y<height;++y) {
- png_read_row(_png_ptr,(png_bytep)&row.front(),NULL);
- std::transform(row.begin(),row.end(),view.row_begin(y),color_convert_deref_fn<rgba16_ref_t,typename View::value_type,CC>(_cc));
- }
- break;
- }
- default: io_error("png_reader_color_convert::apply(): unknown combination of color type and bit depth");
- }
- break;
- default: io_error("png_reader_color_convert::apply(): unknown color type");
- }
- png_read_end(_png_ptr,NULL);
- }
- template <typename Image>
- void read_image(Image& im) {
- im.recreate(get_dimensions());
- apply(view(im));
- }
-};
-
-
-class png_writer : public file_mgr {
-protected:
- png_structp _png_ptr;
- png_infop _info_ptr;
-
- void init() {
- _png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,NULL,NULL,NULL);
- io_error_if(!_png_ptr,"png_write_initialize: fail to call png_create_write_struct()");
- _info_ptr = png_create_info_struct(_png_ptr);
- if (!_info_ptr) {
- png_destroy_write_struct(&_png_ptr,0/*png_infopp_NULL*/);
- io_error("png_write_initialize: fail to call png_create_info_struct()");
- }
- if (setjmp(png_jmpbuf(_png_ptr))) {
- png_destroy_write_struct(&_png_ptr, &_info_ptr);
- io_error("png_write_initialize: fail to call setjmp(png_jmpbuf())");
- }
- png_init_io(_png_ptr,get());
- }
-public:
- png_writer(FILE* file ) : file_mgr(file) { init(); }
- png_writer(const char* filename) : file_mgr(filename, "wb") { init(); }
-
- ~png_writer() {
- png_destroy_write_struct(&_png_ptr,&_info_ptr);
- }
- template <typename View>
- void apply(const View& view) {
- png_set_IHDR(_png_ptr, _info_ptr, view.width(), view.height(),
- png_write_support_private<typename channel_type<View>::type,
- typename color_space_type<View>::type>::bit_depth,
- png_write_support_private<typename channel_type<View>::type,
- typename color_space_type<View>::type>::color_type,
- PNG_INTERLACE_NONE,
- PNG_COMPRESSION_TYPE_DEFAULT,PNG_FILTER_TYPE_DEFAULT);
- png_write_info(_png_ptr,_info_ptr);
- if (little_endian() &&
- png_write_support_private<typename channel_type<View>::type,
- typename color_space_type<View>::type>::bit_depth>8)
- png_set_swap(_png_ptr);
- std::vector<pixel<typename channel_type<View>::type,
- layout<typename color_space_type<View>::type> > > row(view.width());
- for(int y=0;y<view.height();++y) {
- std::copy(view.row_begin(y),view.row_end(y),row.begin());
- png_write_row(_png_ptr,(png_bytep)&row.front());
- }
- png_write_end(_png_ptr,_info_ptr);
- }
-};
-
-} // namespace detail
-} } // namespace boost::gil
-
-#endif

Deleted: sandbox/gil/boost/gil/extension/io2/tiff_dynamic_io.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/tiff_dynamic_io.hpp 2010-10-10 12:50:29 EDT (Sun, 10 Oct 2010)
+++ (empty file)
@@ -1,135 +0,0 @@
-/*
- Copyright 2005-2007 Adobe Systems Incorporated
-
- Use, modification and distribution are subject to the Boost Software License,
- Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt).
-
- See http://opensource.adobe.com/gil for most recent version including documentation.
-*/
-
-/*************************************************************************************************/
-
-#ifndef GIL_TIFF_DYNAMIC_IO_H
-#define GIL_TIFF_DYNAMIC_IO_H
-
-/// \file
-/// \brief Support for reading and writing TIFF files
-/// Requires libtiff!
-/// \author Hailin Jin and Lubomir Bourdev \n
-/// Adobe Systems Incorporated
-/// \date 2005-2007 \n Last updated June 10, 2006
-//
-// We are currently providing the following functions:
-// template <typename Images> void tiff_read_image(const char*,any_image<Images>)
-// template <typename Views> void tiff_write_view(const char*,any_image_view<Views>)
-//
-
-#include <string>
-#include <boost/mpl/bool.hpp>
-#include "../dynamic_image/dynamic_image_all.hpp"
-#include "io_error.hpp"
-#include "tiff_io.hpp"
-#include "dynamic_io.hpp"
-
-namespace boost { namespace gil {
-
-namespace detail {
-
-struct tiff_write_is_supported {
- template<typename View> struct apply
- : public mpl::bool_<tiff_write_support<View>::is_supported> {};
-};
-
-class tiff_writer_dynamic : public tiff_writer {
-public:
- typedef void result_type;
- tiff_writer_dynamic(const char* filename) : tiff_writer(filename) {}
-
- template <typename Views>
- void write_view(const any_image_view<Views>& runtime_view) {
- dynamic_io_fnobj<tiff_write_is_supported, tiff_writer> op(this);
- apply_operation(runtime_view,op);
- }
-};
-
-class tiff_type_format_checker {
- int _bit_depth;
- int _color_type;
-public:
- tiff_type_format_checker(int bit_depth_in,int color_type_in) :
- _bit_depth(bit_depth_in),_color_type(color_type_in) {}
- template <typename Image>
- bool apply() {
- return tiff_read_support<typename Image::view_t>::bit_depth==_bit_depth &&
- tiff_read_support<typename Image::view_t>::color_type==_color_type;
- }
-};
-
-struct tiff_read_is_supported {
- template<typename View> struct apply
- : public mpl::bool_<tiff_read_support<View>::is_supported> {};
-};
-
-class tiff_reader_dynamic : public tiff_reader {
-public:
- tiff_reader_dynamic(const char* filename) : tiff_reader(filename) {}
-
- template <typename Images>
- void read_image(any_image<Images>& im) {
- int width,height;
- unsigned short bps,photometric;
- TIFFGetField(_tp,TIFFTAG_IMAGEWIDTH,&width);
- TIFFGetField(_tp,TIFFTAG_IMAGELENGTH,&height);
- TIFFGetField(_tp,TIFFTAG_BITSPERSAMPLE,&bps);
- TIFFGetField(_tp,TIFFTAG_PHOTOMETRIC,&photometric);
- if (!construct_matched(im,tiff_type_format_checker(bps,photometric))) {
- io_error("tiff_reader_dynamic::read_image(): no matching image type between those of the given any_image and that of the file");
- } else {
- im.recreate(width,height);
- dynamic_io_fnobj<tiff_read_is_supported, tiff_reader> op(this);
- apply_operation(view(im),op);
- }
- }
-};
-
-} // namespace detail
-
-/// \ingroup TIFF_IO
-/// \brief reads a TIFF image into a run-time instantiated image
-/// Opens the given tiff file name, selects the first type in Images whose color space and channel are compatible to those of the image file
-/// and creates a new image of that type with the dimensions specified by the image file.
-/// Throws std::ios_base::failure if none of the types in Images are compatible with the type on disk.
-template <typename Images>
-inline void tiff_read_image(const char* filename,any_image<Images>& im) {
- detail::tiff_reader_dynamic m(filename);
- m.read_image(im);
-}
-
-/// \ingroup TIFF_IO
-/// \brief reads a TIFF image into a run-time instantiated image
-template <typename Images>
-inline void tiff_read_image(const std::string& filename,any_image<Images>& im) {
- tiff_read_image(filename.c_str(),im);
-}
-
-/// \ingroup TIFF_IO
-/// \brief Saves the currently instantiated view to a tiff file specified by the given tiff image file name.
-/// Throws std::ios_base::failure if the currently instantiated view type is not supported for writing by the I/O extension
-/// or if it fails to create the file.
-template <typename Views>
-inline void tiff_write_view(const char* filename,const any_image_view<Views>& runtime_view) {
- detail::tiff_writer_dynamic m(filename);
- m.write_view(runtime_view);
-}
-
-/// \ingroup TIFF_IO
-/// \brief Saves the currently instantiated view to a tiff file specified by the given tiff image file name.
-template <typename Views>
-inline void tiff_write_view(const std::string& filename,const any_image_view<Views>& runtime_view) {
- tiff_write_view(filename.c_str(),runtime_view);
-}
-
-} } // namespace boost::gil
-
-#endif

Deleted: sandbox/gil/boost/gil/extension/io2/tiff_io.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/tiff_io.hpp 2010-10-10 12:50:29 EDT (Sun, 10 Oct 2010)
+++ (empty file)
@@ -1,491 +0,0 @@
-/*
- Copyright 2005-2007 Adobe Systems Incorporated
-
- Use, modification and distribution are subject to the Boost Software License,
- Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt).
-
- See http://opensource.adobe.com/gil for most recent version including documentation.
-*/
-
-/*************************************************************************************************/
-
-#ifndef GIL_TIFF_IO_H
-#define GIL_TIFF_IO_H
-
-/// \file
-/// \brief Support for reading and writing TIFF files
-/// Requires libtiff!
-/// \author Hailin Jin and Lubomir Bourdev \n
-/// Adobe Systems Incorporated
-/// \date 2005-2007 \n Last updated September 24, 2006
-
-#include <vector>
-#include <string>
-#include <algorithm>
-#include <boost/static_assert.hpp>
-#include <tiffio.h>
-#include "../../gil_all.hpp"
-#include "io_error.hpp"
-
-namespace boost { namespace gil {
-
-namespace detail {
-
-template <typename Channel,typename ColorSpace>
-struct tiff_read_support_private {
- BOOST_STATIC_CONSTANT(bool,is_supported=false);
- BOOST_STATIC_CONSTANT(int,bit_depth=0);
- BOOST_STATIC_CONSTANT(int,color_type=0);
-};
-template <>
-struct tiff_read_support_private<bits8,gray_t> {
- BOOST_STATIC_CONSTANT(bool,is_supported=true);
- BOOST_STATIC_CONSTANT(int,bit_depth=8);
- BOOST_STATIC_CONSTANT(int,color_type=PHOTOMETRIC_MINISBLACK);
-};
-template <>
-struct tiff_read_support_private<bits8,rgb_t> {
- BOOST_STATIC_CONSTANT(bool,is_supported=true);
- BOOST_STATIC_CONSTANT(int,bit_depth=8);
- BOOST_STATIC_CONSTANT(int,color_type=PHOTOMETRIC_RGB);
-};
-template <>
-struct tiff_read_support_private<bits16,gray_t> {
- BOOST_STATIC_CONSTANT(bool,is_supported=true);
- BOOST_STATIC_CONSTANT(int,bit_depth=16);
- BOOST_STATIC_CONSTANT(int,color_type=PHOTOMETRIC_MINISBLACK);
-};
-template <>
-struct tiff_read_support_private<bits16,rgb_t> {
- BOOST_STATIC_CONSTANT(bool,is_supported=true);
- BOOST_STATIC_CONSTANT(int,bit_depth=16);
- BOOST_STATIC_CONSTANT(int,color_type=PHOTOMETRIC_RGB);
-};
-template <>
-struct tiff_read_support_private<bits32f,gray_t> {
- BOOST_STATIC_CONSTANT(bool,is_supported=true);
- BOOST_STATIC_CONSTANT(int,bit_depth=32);
- BOOST_STATIC_CONSTANT(int,color_type=PHOTOMETRIC_MINISBLACK);
-};
-template <>
-struct tiff_read_support_private<bits32f,rgb_t> {
- BOOST_STATIC_CONSTANT(bool,is_supported=true);
- BOOST_STATIC_CONSTANT(int,bit_depth=32);
- BOOST_STATIC_CONSTANT(int,color_type=PHOTOMETRIC_RGB);
-};
-
-template <typename Channel,typename ColorSpace>
-struct tiff_write_support_private {
- BOOST_STATIC_CONSTANT(bool,is_supported=false);
- BOOST_STATIC_CONSTANT(int,bit_depth=0);
- BOOST_STATIC_CONSTANT(int,color_type=0);
-};
-template <>
-struct tiff_write_support_private<bits8,gray_t> {
- BOOST_STATIC_CONSTANT(bool,is_supported=true);
- BOOST_STATIC_CONSTANT(int,bit_depth=8);
- BOOST_STATIC_CONSTANT(int,color_type=PHOTOMETRIC_MINISBLACK);
-};
-template <>
-struct tiff_write_support_private<bits8,rgb_t> {
- BOOST_STATIC_CONSTANT(bool,is_supported=true);
- BOOST_STATIC_CONSTANT(int,bit_depth=8);
- BOOST_STATIC_CONSTANT(int,color_type=PHOTOMETRIC_RGB);
-};
-template <>
-struct tiff_write_support_private<bits16,gray_t> {
- BOOST_STATIC_CONSTANT(bool,is_supported=true);
- BOOST_STATIC_CONSTANT(int,bit_depth=16);
- BOOST_STATIC_CONSTANT(int,color_type=PHOTOMETRIC_MINISBLACK);
-};
-template <>
-struct tiff_write_support_private<bits16,rgb_t> {
- BOOST_STATIC_CONSTANT(bool,is_supported=true);
- BOOST_STATIC_CONSTANT(int,bit_depth=16);
- BOOST_STATIC_CONSTANT(int,color_type=PHOTOMETRIC_RGB);
-};
-template <>
-struct tiff_write_support_private<bits32f,gray_t> {
- BOOST_STATIC_CONSTANT(bool,is_supported=true);
- BOOST_STATIC_CONSTANT(int,bit_depth=32);
- BOOST_STATIC_CONSTANT(int,color_type=PHOTOMETRIC_MINISBLACK);
-};
-template <>
-struct tiff_write_support_private<bits32f,rgb_t> {
- BOOST_STATIC_CONSTANT(bool,is_supported=true);
- BOOST_STATIC_CONSTANT(int,bit_depth=32);
- BOOST_STATIC_CONSTANT(int,color_type=PHOTOMETRIC_RGB);
-};
-
-class tiff_reader {
-protected:
- TIFF *_tp;
-public:
- tiff_reader(const char* filename) {
- io_error_if((_tp=TIFFOpen(filename,"r"))==NULL,
- "tiff_reader: fail to open file");
- }
- ~tiff_reader() { TIFFClose(_tp); }
- template <typename View>
- void apply(const View& view) {
- unsigned short bps,photometric;
- point2<std::ptrdiff_t> dims=get_dimensions();
- io_error_if(TIFFGetField(_tp,TIFFTAG_BITSPERSAMPLE,&bps)!=1);
- io_error_if(TIFFGetField(_tp,TIFFTAG_PHOTOMETRIC,&photometric)!=1);
- io_error_if(dims!=view.dimensions(),
- "tiff_read_view: input view size does not match TIFF file size");
- io_error_if(tiff_read_support_private<typename channel_type<View>::type,
- typename color_space_type<View>::type>::bit_depth!=bps ||
- tiff_read_support_private<typename channel_type<View>::type,
- typename color_space_type<View>::type>::color_type!=photometric,
- "tiff_read_view: input view type is incompatible with the image type");
- std::size_t element_size=sizeof(pixel<typename channel_type<View>::type,
- layout<typename color_space_type<View>::type> >);
- std::size_t size_to_allocate = (std::max)((std::size_t)view.width(),
- (std::size_t)(TIFFScanlineSize(_tp)+element_size-1)/element_size);
- std::vector<pixel<typename channel_type<View>::type,
- layout<typename color_space_type<View>::type> > > row(size_to_allocate);
- for (int y=0;y<view.height();++y) {
- io_error_if(TIFFReadScanline(_tp,&row.front(), y)!=1);
- std::copy(row.begin(),row.begin()+view.width(),view.row_begin(y));
- }
- }
- point2<std::ptrdiff_t> get_dimensions() {
- int w,h;
- io_error_if(TIFFGetField(_tp,TIFFTAG_IMAGEWIDTH, &w)!=1);
- io_error_if(TIFFGetField(_tp,TIFFTAG_IMAGELENGTH,&h)!=1);
- return point2<std::ptrdiff_t>(w,h);
- }
-
- template <typename Image>
- void read_image(Image& im) {
- im.recreate(get_dimensions());
- apply(view(im));
- }
-};
-
-// This code will be simplified...
-template <typename CC>
-class tiff_reader_color_convert : public tiff_reader {
-private:
- CC _cc;
-public:
- tiff_reader_color_convert(const char* filename) :
- tiff_reader(filename) {}
- tiff_reader_color_convert(const char* filename,CC cc_in) :
- tiff_reader(filename),_cc(cc_in) {}
- template <typename View>
- void apply(const View& view) {
- point2<std::ptrdiff_t> dims=get_dimensions();
- unsigned short bps,photometric;
- io_error_if(TIFFGetField(_tp,TIFFTAG_BITSPERSAMPLE,&bps)!=1);
- io_error_if(TIFFGetField(_tp,TIFFTAG_PHOTOMETRIC,&photometric)!=1);
- io_error_if(dims!=view.dimensions(),
- "tiff_reader_color_convert::apply(): input view size does not match TIFF file size");
- switch (photometric) {
- case PHOTOMETRIC_MINISBLACK: {
- switch (bps) {
- case 8: {
- std::size_t element_size=sizeof(gray8_pixel_t);
- std::size_t size_to_allocate = (std::max)((std::size_t)view.width(),
- (std::size_t)(TIFFScanlineSize(_tp)+element_size-1)/element_size);
- std::vector<gray8_pixel_t> row(size_to_allocate);
- for (int y=0;y<view.height();++y) {
- io_error_if(TIFFReadScanline(_tp,&row.front(), y)!=1);
- std::transform(row.begin(),row.begin()+view.width(),view.row_begin(y),
- color_convert_deref_fn<gray8_ref_t,typename View::value_type,CC>(_cc));
- }
- break;
- }
- case 16: {
- std::size_t element_size=sizeof(gray16_pixel_t);
- std::size_t size_to_allocate = (std::max)((std::size_t)view.width(),
- (std::size_t)(TIFFScanlineSize(_tp)+element_size-1)/element_size);
- std::vector<gray16_pixel_t> row(size_to_allocate);
- for (int y=0;y<view.height();++y) {
- io_error_if(TIFFReadScanline(_tp,&row.front(), y)!=1);
- std::transform(row.begin(),row.begin()+view.width(),view.row_begin(y),
- color_convert_deref_fn<gray16_ref_t,typename View::value_type,CC>(_cc));
- }
- break;
- }
- case 32: {
- std::size_t element_size=sizeof(gray32f_pixel_t);
- std::size_t size_to_allocate = (std::max)((std::size_t)view.width(),
- (std::size_t)(TIFFScanlineSize(_tp)+element_size-1)/element_size);
- std::vector<gray32f_pixel_t> row(size_to_allocate);
- for (int y=0;y<view.height();++y) {
- io_error_if(TIFFReadScanline(_tp,&row.front(), y)!=1);
- std::transform(row.begin(),row.begin()+view.width(),view.row_begin(y),
- color_convert_deref_fn<gray32f_ref_t,typename View::value_type,CC>(_cc));
- }
- break;
- }
- default:
- io_error("tiff_reader_color_convert::apply(): unknown combination of color type and bit depth");
- }
- break;
- }
- case PHOTOMETRIC_RGB: {
- switch (bps) {
- case 8: {
- std::size_t element_size=sizeof(rgb8_pixel_t);
- std::size_t size_to_allocate = (std::max)((std::size_t)view.width(),
- (std::size_t)(TIFFScanlineSize(_tp)+element_size-1)/element_size);
- std::vector<rgb8_pixel_t> row(size_to_allocate);
- for (int y=0;y<view.height();++y) {
- io_error_if(TIFFReadScanline(_tp,&row.front(), y)!=1);
- std::transform(row.begin(),row.begin()+view.width(),view.row_begin(y),
- color_convert_deref_fn<rgb8_ref_t,typename View::value_type,CC>(_cc));
- }
- break;
- }
- case 16: {
- std::size_t element_size=sizeof(rgb16_pixel_t);
- std::size_t size_to_allocate = (std::max)((std::size_t)view.width(),
- (std::size_t)(TIFFScanlineSize(_tp)+element_size-1)/element_size);
- std::vector<rgb16_pixel_t> row(size_to_allocate);
- for (int y=0;y<view.height();++y) {
- io_error_if(TIFFReadScanline(_tp,&row.front(), y)!=1);
- std::transform(row.begin(),row.begin()+view.width(),view.row_begin(y),
- color_convert_deref_fn<rgb16_ref_t,typename View::value_type,CC>(_cc));
- }
- break;
- }
- case 32: {
- std::size_t element_size=sizeof(rgb32f_pixel_t);
- std::size_t size_to_allocate = (std::max)((std::size_t)view.width(),
- (std::size_t)(TIFFScanlineSize(_tp)+element_size-1)/element_size);
- std::vector<rgb32f_pixel_t> row(size_to_allocate);
- for (int y=0;y<view.height();++y) {
- io_error_if(TIFFReadScanline(_tp,&row.front(), y)!=1);
- std::transform(row.begin(),row.begin()+view.width(),view.row_begin(y),
- color_convert_deref_fn<rgb32f_ref_t,typename View::value_type,CC>(_cc));
- }
- break;
- }
- default:
- io_error("tiff_reader_color_convert::apply(): unknown combination of color type and bit depth");
- }
- break;
- }
- default: {
- // reads an image in incompatible format via TIFFReadRGBAImage
- rgba8_image_t rgbaImg(dims);
- io_error_if(!TIFFReadRGBAImage(_tp, dims.x, dims.y, (uint32*)&gil::view(rgbaImg)(0,0), 0),
- "tiff_reader_color_convert::unsupported image format");
- copy_and_convert_pixels(flipped_up_down_view(const_view(rgbaImg)), view, _cc);
- }
- }
- }
- template <typename Image>
- void read_image(Image& im) {
- im.recreate(get_dimensions());
- apply(view(im));
- }
-};
-
-class tiff_writer {
-protected:
- TIFF* _tp;
-public:
- tiff_writer(const char *filename) {
- io_error_if((_tp=TIFFOpen(filename,"w"))==NULL,
- "tiff_writer: fail to open file");
- }
- ~tiff_writer() {TIFFClose(_tp);}
- template <typename View>
- void apply(const View& view) {
- io_error_if(TIFFSetField(_tp,TIFFTAG_IMAGELENGTH, view.height())!=1);
- io_error_if(TIFFSetField(_tp,TIFFTAG_IMAGEWIDTH, view.width())!=1);
- io_error_if(TIFFSetField(_tp,TIFFTAG_PHOTOMETRIC, tiff_write_support_private<typename channel_type<View>::type,
- typename color_space_type<View>::type>::color_type)!=1);
- io_error_if(TIFFSetField(_tp,TIFFTAG_RESOLUTIONUNIT, RESUNIT_NONE)!=1);
- io_error_if(TIFFSetField(_tp,TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG)!=1);
- io_error_if(TIFFSetField(_tp,TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT)!=1);
- io_error_if(TIFFSetField(_tp,TIFFTAG_SAMPLESPERPIXEL,num_channels<View>::value)!=1);
- io_error_if(TIFFSetField(_tp,TIFFTAG_BITSPERSAMPLE, tiff_write_support_private<typename channel_type<View>::type,
- typename color_space_type<View>::type>::bit_depth)!=1);
- io_error_if(TIFFSetField(_tp,TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(_tp, 0))!=1);
- std::vector<pixel<typename channel_type<View>::type,
- layout<typename color_space_type<View>::type> > > row(view.width());
- for (int y=0;y<view.height();++y) {
- std::copy(view.row_begin(y),view.row_end(y),row.begin());
- io_error_if(TIFFWriteScanline(_tp,&row.front(),y,0)!=1,
- "tiff_write_view: fail to write file");
- }
- }
-};
-
-} // namespace detail
-
-/// \ingroup TIFF_IO
-/// \brief Determines whether the given view type is supported for reading
-template <typename View>
-struct tiff_read_support {
- BOOST_STATIC_CONSTANT(bool,is_supported=
- (detail::tiff_read_support_private<typename channel_type<View>::type,
- typename color_space_type<View>::type>::is_supported));
- BOOST_STATIC_CONSTANT(int,bit_depth=
- (detail::tiff_read_support_private<typename channel_type<View>::type,
- typename color_space_type<View>::type>::bit_depth));
- BOOST_STATIC_CONSTANT(int,color_type=
- (detail::tiff_read_support_private<typename channel_type<View>::type,
- typename color_space_type<View>::type>::color_type));
-};
-
-/// \ingroup TIFF_IO
-/// \brief Returns the width and height of the TIFF file at the specified location.
-/// Throws std::ios_base::failure if the location does not correspond to a valid TIFF file
-inline point2<std::ptrdiff_t> tiff_read_dimensions(const char* filename) {
- detail::tiff_reader m(filename);
- return m.get_dimensions();
-}
-
-/// \ingroup TIFF_IO
-/// \brief Returns the width and height of the TIFF file at the specified location.
-/// Throws std::ios_base::failure if the location does not correspond to a valid TIFF file
-inline point2<std::ptrdiff_t> tiff_read_dimensions(const std::string& filename) {
- return tiff_read_dimensions(filename.c_str());
-}
-
-/// \ingroup TIFF_IO
-/// \brief Loads the image specified by the given tiff image file name into the given view.
-/// Triggers a compile assert if the view color space and channel depth are not supported by the TIFF library or by the I/O extension.
-/// Throws std::ios_base::failure if the file is not a valid TIFF file, or if its color space or channel depth are not
-/// compatible with the ones specified by View, or if its dimensions don't match the ones of the view.
-template <typename View>
-inline void tiff_read_view(const char* filename,const View& view) {
- BOOST_STATIC_ASSERT(tiff_read_support<View>::is_supported);
- detail::tiff_reader m(filename);
- m.apply(view);
-}
-
-/// \ingroup TIFF_IO
-/// \brief Loads the image specified by the given tiff image file name into the given view.
-template <typename View>
-inline void tiff_read_view(const std::string& filename,const View& view) {
- tiff_read_view(filename.c_str(),view);
-}
-
-/// \ingroup TIFF_IO
-/// \brief Allocates a new image whose dimensions are determined by the given tiff image file, and loads the pixels into it.
-/// Triggers a compile assert if the image color space or channel depth are not supported by the TIFF library or by the I/O extension.
-/// Throws std::ios_base::failure if the file is not a valid TIFF file, or if its color space or channel depth are not
-/// compatible with the ones specified by Image
-template <typename Image>
-void tiff_read_image(const char* filename,Image& im) {
- BOOST_STATIC_ASSERT(tiff_read_support<typename Image::view_t>::is_supported);
- detail::tiff_reader m(filename);
- m.read_image(im);
-}
-
-/// \ingroup TIFF_IO
-/// \brief Allocates a new image whose dimensions are determined by the given tiff image file, and loads the pixels into it.
-template <typename Image>
-inline void tiff_read_image(const std::string& filename,Image& im) {
- tiff_read_image(filename.c_str(),im);
-}
-
-/// \ingroup TIFF_IO
-/// \brief Loads and color-converts the image specified by the given tiff image file name into the given view.
-/// Throws std::ios_base::failure if the file is not a valid TIFF file, or if its dimensions don't match the ones of the view.
-template <typename View,typename CC>
-inline void tiff_read_and_convert_view(const char* filename,const View& view,CC cc) {
- detail::tiff_reader_color_convert<CC> m(filename,cc);
- m.apply(view);
-}
-
-/// \ingroup TIFF_IO
-/// \brief Loads and color-converts the image specified by the given tiff image file name into the given view.
-/// Throws std::ios_base::failure if the file is not a valid TIFF file, or if its dimensions don't match the ones of the view.
-template <typename View>
-inline void tiff_read_and_convert_view(const char* filename,const View& view) {
- detail::tiff_reader_color_convert<default_color_converter> m(filename,default_color_converter());
- m.apply(view);
-}
-
-/// \ingroup TIFF_IO
-/// \brief Loads and color-converts the image specified by the given tiff image file name into the given view.
-template <typename View,typename CC>
-inline void tiff_read_and_convert_view(const std::string& filename,const View& view,CC cc) {
- tiff_read_and_convert_view(filename.c_str(),view,cc);
-}
-
-/// \ingroup TIFF_IO
-/// \brief Loads and color-converts the image specified by the given tiff image file name into the given view.
-template <typename View>
-inline void tiff_read_and_convert_view(const std::string& filename,const View& view) {
- tiff_read_and_convert_view(filename.c_str(),view);
-}
-
-/// \ingroup TIFF_IO
-/// \brief Allocates a new image whose dimensions are determined by the given tiff image file, loads and color-converts the pixels into it.
-/// Throws std::ios_base::failure if the file is not a valid TIFF file
-template <typename Image,typename CC>
-void tiff_read_and_convert_image(const char* filename,Image& im,CC cc) {
- detail::tiff_reader_color_convert<CC> m(filename,cc);
- m.read_image(im);
-}
-
-/// \ingroup TIFF_IO
-/// \brief Allocates a new image whose dimensions are determined by the given tiff image file, loads and color-converts the pixels into it.
-/// Throws std::ios_base::failure if the file is not a valid TIFF file
-template <typename Image>
-void tiff_read_and_convert_image(const char* filename,Image& im) {
- detail::tiff_reader_color_convert<default_color_converter> m(filename,default_color_converter());
- m.read_image(im);
-}
-
-/// \ingroup TIFF_IO
-/// \brief Allocates a new image whose dimensions are determined by the given tiff image file, loads and color-converts the pixels into it.
-template <typename Image,typename CC>
-inline void tiff_read_and_convert_image(const std::string& filename,Image& im,CC cc) {
- tiff_read_and_convert_image(filename.c_str(),im,cc);
-}
-
-/// \ingroup TIFF_IO
-/// \brief Allocates a new image whose dimensions are determined by the given tiff image file, loads and color-converts the pixels into it.
-template <typename Image>
-inline void tiff_read_and_convert_image(const std::string& filename,Image& im) {
- tiff_read_and_convert_image(filename.c_str(),im);
-}
-
-/// \ingroup TIFF_IO
-/// \brief Determines whether the given view type is supported for writing
-template <typename View>
-struct tiff_write_support {
- BOOST_STATIC_CONSTANT(bool,is_supported=
- (detail::tiff_write_support_private<typename channel_type<View>::type,
- typename color_space_type<View>::type>::is_supported));
- BOOST_STATIC_CONSTANT(int,bit_depth=
- (detail::tiff_write_support_private<typename channel_type<View>::type,
- typename color_space_type<View>::type>::bit_depth));
- BOOST_STATIC_CONSTANT(int,color_type=
- (detail::tiff_write_support_private<typename channel_type<View>::type,
- typename color_space_type<View>::type>::color_type));
- BOOST_STATIC_CONSTANT(bool, value=is_supported);
-};
-
-/// \ingroup TIFF_IO
-/// \brief Saves the view to a tiff file specified by the given tiff image file name.
-/// Triggers a compile assert if the view color space and channel depth are not supported by the TIFF library or by the I/O extension.
-/// Throws std::ios_base::failure if it fails to create the file.
-template <typename View>
-inline void tiff_write_view(const char* filename,const View& view) {
- BOOST_STATIC_ASSERT(tiff_write_support<View>::is_supported);
- detail::tiff_writer m(filename);
- m.apply(view);
-}
-
-/// \ingroup TIFF_IO
-/// \brief Saves the view to a tiff file specified by the given tiff image file name.
-template <typename View>
-inline void tiff_write_view(const std::string& filename,const View& view) {
- tiff_write_view(filename.c_str(),view);
-}
-
-} } // namespace boost::gil
-
-#endif


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