Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:36:57

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_JPEG_OLD_HPP
0009 #define BOOST_GIL_EXTENSION_IO_JPEG_OLD_HPP
0010 
0011 #include <boost/gil/extension/io/jpeg.hpp>
0012 
0013 namespace boost { namespace gil {
0014 
0015 /// \ingroup JPEG_IO
0016 /// \brief Returns the width and height of the JPEG file at the specified location.
0017 /// Throws std::ios_base::failure if the location does not correspond to a valid JPEG file
0018 template<typename String>
0019 inline point_t jpeg_read_dimensions(String const& filename)
0020 {
0021     using backend_t = typename get_reader_backend<String, jpeg_tag>::type;
0022     backend_t backend = read_image_info(filename, jpeg_tag());
0023     return { backend._info._width, backend._info._height };
0024 }
0025 
0026 /// \ingroup JPEG_IO
0027 /// \brief Loads the image specified by the given jpeg 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 JPEG library or by the I/O extension.
0029 /// Throws std::ios_base::failure if the file is not a valid JPEG 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 jpeg_read_view( const String& filename
0036                    , const View&   view
0037                    )
0038 {
0039     read_view( filename
0040              , view
0041              , jpeg_tag()
0042              );
0043 }
0044 
0045 /// \ingroup JPEG_IO
0046 /// \brief Allocates a new image whose dimensions are determined by the given jpeg 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 JPEG library or by the I/O extension.
0048 /// Throws std::ios_base::failure if the file is not a valid JPEG 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 jpeg_read_image( const String& filename
0055                     , Image&        img
0056                     )
0057 {
0058     read_image( filename
0059               , img
0060               , jpeg_tag()
0061               );
0062 }
0063 
0064 /// \ingroup JPEG_IO
0065 /// \brief Loads and color-converts the image specified by the given jpeg image file name into the given view.
0066 /// 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.
0067 template< typename String
0068         , typename View
0069         , typename CC
0070         >
0071 inline
0072 void jpeg_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                          , jpeg_tag()
0081                          );
0082 }
0083 
0084 /// \ingroup JPEG_IO
0085 /// \brief Loads and color-converts the image specified by the given jpeg image file name into the given view.
0086 /// 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.
0087 template< typename String
0088         , typename View
0089         >
0090 inline
0091 void jpeg_read_and_convert_view( const String& filename
0092                                , const View&   view
0093                                )
0094 {
0095     read_and_convert_view( filename
0096                          , view
0097                          , jpeg_tag()
0098                          );
0099 }
0100 
0101 /// \ingroup JPEG_IO
0102 /// \brief Allocates a new image whose dimensions are determined by the given jpeg image file, loads and color-converts the pixels into it.
0103 /// Throws std::ios_base::failure if the file is not a valid JPEG file
0104 template< typename String
0105         , typename Image
0106         , typename CC
0107         >
0108 inline
0109 void jpeg_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                           , jpeg_tag()
0118                           );
0119 }
0120 
0121 /// \ingroup JPEG_IO
0122 /// \brief Allocates a new image whose dimensions are determined by the given jpeg image file, loads and color-converts the pixels into it.
0123 /// Throws std::ios_base::failure if the file is not a valid JPEG file
0124 template< typename String
0125         , typename Image
0126         >
0127 inline
0128 void jpeg_read_and_convert_image( const String filename
0129                                 , Image&       img
0130                                 )
0131 {
0132     read_and_convert_image( filename
0133                           , img
0134                           , jpeg_tag()
0135                           );
0136 }
0137 
0138 
0139 /// \ingroup JPEG_IO
0140 /// \brief Saves the view to a jpeg file specified by the given jpeg image file name.
0141 /// 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.
0142 /// Throws std::ios_base::failure if it fails to create the file.
0143 template< typename String
0144         , typename View
0145         >
0146 inline
0147 void jpeg_write_view( const String& filename
0148                     , const View&   view
0149                     , int   quality = jpeg_quality::default_value
0150                     )
0151 {
0152     write_view( filename
0153               , view
0154               , image_write_info< jpeg_tag >( quality )
0155               );
0156 }
0157 
0158 } // namespace gil
0159 } // namespace boost
0160 
0161 #endif