Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-01-08 09:49:22

0001 //
0002 // Copyright 2007-2008 Christian Henning
0003 //
0004 // Distributed under the Boost Software License, Version 1.0
0005 // See accompanying file LICENSE_1_0.txt or copy at
0006 // http://www.boost.org/LICENSE_1_0.txt
0007 //
0008 #ifndef BOOST_GIL_EXTENSION_IO_PNG_OLD_HPP
0009 #define BOOST_GIL_EXTENSION_IO_PNG_OLD_HPP
0010 
0011 #include <boost/gil/extension/io/png.hpp>
0012 
0013 namespace boost { namespace gil {
0014 
0015 /// \ingroup PNG_IO
0016 /// \brief Returns the width and height of the PNG file at the specified location.
0017 /// Throws std::ios_base::failure if the location does not correspond to a valid PNG file
0018 template<typename String>
0019 inline point_t png_read_dimensions(String const& filename)
0020 {
0021     using backend_t = typename get_reader_backend<String, png_tag>::type;
0022     backend_t backend = read_image_info(filename, png_tag());
0023     return { static_cast<std::ptrdiff_t>(backend._info._width), static_cast<std::ptrdiff_t>(backend._info._height) };
0024 }
0025 
0026 /// \ingroup PNG_IO
0027 /// \brief Loads the image specified by the given png image file name into the given view.
0028 /// 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.
0029 /// Throws std::ios_base::failure if the file is not a valid PNG file, or if its color space or channel depth are not
0030 /// compatible with the ones specified by View, or if its dimensions don't match the ones of the view.
0031 template< typename String
0032         , typename View
0033         >
0034 inline
0035 void png_read_view( const String& filename
0036                    , const View&   view
0037                    )
0038 {
0039     read_view( filename
0040              , view
0041              , png_tag()
0042              );
0043 }
0044 
0045 /// \ingroup PNG_IO
0046 /// \brief Allocates a new image whose dimensions are determined by the given png image file, and loads the pixels into it.
0047 /// 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.
0048 /// Throws std::ios_base::failure if the file is not a valid PNG file, or if its color space or channel depth are not
0049 /// compatible with the ones specified by Image
0050 template< typename String
0051         , typename Image
0052         >
0053 inline
0054 void png_read_image( const String& filename
0055                    , Image&        img
0056                    )
0057 {
0058     read_image( filename
0059               , img
0060               , png_tag()
0061               );
0062 }
0063 
0064 /// \ingroup PNG_IO
0065 /// \brief Loads the image specified by the given png image file name and color-converts it into the given view.
0066 /// 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.
0067 template< typename String
0068         , typename View
0069         , typename CC
0070         >
0071 inline
0072 void png_read_and_convert_view( const String& filename
0073                                , const View&   view
0074                                , CC            cc
0075                                )
0076 {
0077     read_and_convert_view( filename
0078                          , view
0079                          , cc
0080                          , png_tag()
0081                          );
0082 }
0083 
0084 /// \ingroup PNG_IO
0085 /// \brief Loads the image specified by the given png image file name and color-converts it into the given view.
0086 /// 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.
0087 template< typename String
0088         , typename View
0089         >
0090 inline
0091 void png_read_and_convert_view( const String& filename
0092                                , const View&   view
0093                                )
0094 {
0095     read_and_convert_view( filename
0096                          , view
0097                          , png_tag()
0098                          );
0099 }
0100 
0101 /// \ingroup PNG_IO
0102 /// \brief Allocates a new image whose dimensions are determined by the given png image file, loads and color-converts the pixels into it.
0103 /// Throws std::ios_base::failure if the file is not a valid PNG file
0104 template< typename String
0105         , typename Image
0106         , typename CC
0107         >
0108 inline
0109 void png_read_and_convert_image( const String& filename
0110                                 , Image& img
0111                                 , CC     cc
0112                                 )
0113 {
0114     read_and_convert_image( filename
0115                           , img
0116                           , cc
0117                           , png_tag()
0118                           );
0119 }
0120 
0121 /// \ingroup PNG_IO
0122 /// \brief Allocates a new image whose dimensions are determined by the given png image file, loads and color-converts the pixels into it.
0123 /// Throws std::ios_base::failure if the file is not a valid PNG file
0124 template< typename String
0125         , typename Image
0126         >
0127 inline
0128 void png_read_and_convert_image( const String filename
0129                                 , Image&       img
0130                                 )
0131 {
0132     read_and_convert_image( filename
0133                           , img
0134                           , png_tag()
0135                           );
0136 }
0137 
0138 /// \ingroup PNG_IO
0139 /// \brief Saves the view to a png file specified by the given png image file name.
0140 /// 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.
0141 /// Throws std::ios_base::failure if it fails to create the file.
0142 template< typename String
0143         , typename View
0144         >
0145 inline
0146 void png_write_view( const String& filename
0147                     , const View&   view
0148                     )
0149 {
0150     write_view( filename
0151               , view
0152               , png_tag()
0153               );
0154 }
0155 
0156 }  // namespace gil
0157 }  // namespace boost
0158 
0159 #endif