Adobe Systems, Inc.

jpeg_io.hpp

Go to the documentation of this file.
00001 /*
00002   Copyright 2005-2006 Adobe Systems Incorporated
00003   Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
00004   or a copy at http://opensource.adobe.com/licenses.html)
00005 */
00006 
00007 /*************************************************************************************************/
00008 
00009 #ifndef GIL_JPEG_IO_H
00010 #define GIL_JPEG_IO_H
00011 
00015 //
00019 
00020 #include <cstdio>
00021 #include <algorithm>
00022 #include <string>
00023 #include <boost/static_assert.hpp>
00024 #include <boost/shared_ptr.hpp>
00025 #include <jpeglib.h>
00026 #include "io_error.hpp"
00027 #include "jpeg_io_private.hpp"
00028 
00029 ADOBE_GIL_NAMESPACE_BEGIN
00030 
00033 template <typename VIEW>
00034 struct jpeg_read_support {
00035     BOOST_STATIC_CONSTANT(bool,is_supported=
00036                           (detail::jpeg_read_support_private<typename VIEW::channel_t,
00037                                                              typename VIEW::color_space_t::base>::is_supported));
00038     BOOST_STATIC_CONSTANT(J_COLOR_SPACE,color_type=
00039                           (detail::jpeg_read_support_private<typename VIEW::channel_t,
00040                                                              typename VIEW::color_space_t::base>::color_type));
00041     BOOST_STATIC_CONSTANT(bool, value=is_supported);
00042 };
00043 
00047 inline point2<int> jpeg_read_dimensions(const char* filename) {
00048     detail::jpeg_reader m(filename);
00049     return m.get_dimensions();
00050 }
00051 
00055 inline point2<int> jpeg_read_dimensions(const std::string& filename) {
00056     return jpeg_read_dimensions(filename.c_str());
00057 }
00058 
00064 template <typename VIEW>
00065 inline void jpeg_read_view(const char* filename,const VIEW& view) {
00066     BOOST_STATIC_ASSERT(jpeg_read_support<VIEW>::is_supported);
00067 
00068     detail::jpeg_reader m(filename);
00069     m.apply(view);
00070 }
00071 
00074 template <typename VIEW>
00075 inline void jpeg_read_view(const std::string& filename,const VIEW& view) {
00076     jpeg_read_view(filename.c_str(),view);
00077 }
00078 
00084 template <typename IMAGE>
00085 inline void jpeg_read_image(const char* filename,IMAGE& im) {
00086     BOOST_STATIC_ASSERT(jpeg_read_support<typename IMAGE::view_t>::is_supported);
00087 
00088     detail::jpeg_reader m(filename);
00089     m.read_image(im);
00090 }
00091 
00094 template <typename IMAGE>
00095 inline void jpeg_read_image(const std::string& filename,IMAGE& im) {
00096     jpeg_read_image(filename.c_str(),im);
00097 }
00098 
00102 template <typename VIEW>
00103 inline void jpeg_read_and_convert_view(const char* filename,const VIEW& view) {
00104     detail::jpeg_reader_color_convert m(filename);
00105     m.apply(view);
00106 }
00107 
00110 template <typename VIEW>
00111 inline void jpeg_read_and_convert_view(const std::string& filename,const VIEW& view) {
00112     jpeg_read_and_convert_view(filename.c_str(),view);
00113 }
00114 
00118 template <typename IMAGE>
00119 inline void jpeg_read_and_convert_image(const char* filename,IMAGE& im) {
00120     detail::jpeg_reader_color_convert m(filename);
00121     m.read_image(im);
00122 }
00123 
00126 template <typename IMAGE>
00127 inline void jpeg_read_and_convert_image(const std::string& filename,IMAGE& im) {
00128     jpeg_read_and_convert_image(filename.c_str(),im);
00129 }
00130 
00133 template <typename VIEW>
00134 struct jpeg_write_support {
00135     BOOST_STATIC_CONSTANT(bool,is_supported=
00136                           (detail::jpeg_write_support_private<typename VIEW::channel_t,
00137                                                               typename VIEW::color_space_t::base>::is_supported));
00138     BOOST_STATIC_CONSTANT(J_COLOR_SPACE,color_type=
00139                           (detail::jpeg_write_support_private<typename VIEW::channel_t,
00140                                                               typename VIEW::color_space_t::base>::color_type));
00141     BOOST_STATIC_CONSTANT(bool, value=is_supported);
00142 };
00143 
00148 template <typename VIEW>
00149 inline void jpeg_write_view(const char* filename,const VIEW& view,int quality=100) {
00150     BOOST_STATIC_ASSERT(jpeg_write_support<VIEW>::is_supported);
00151 
00152     detail::jpeg_writer m(filename);
00153     m.apply(view,quality);
00154 }
00155 
00158 template <typename VIEW>
00159 inline void jpeg_write_view(const std::string& filename,const VIEW& view,int quality=100) {
00160     jpeg_write_view(filename.c_str(),view,quality);
00161 }
00162 
00163 ADOBE_GIL_NAMESPACE_END
00164 
00165 #endif

Copyright © 2006 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.

Search powered by Google