Adobe Systems, Inc.

png_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_PNG_IO_H
00010 #define GIL_PNG_IO_H
00011 
00015 //
00016 // We are currently providing the following functions:
00017 // point2<int>               png_read_dimensions(const char*)
00018 // template <typename VIEW>  void png_read_view(const char*,const VIEW&)
00019 // template <typename VIEW>  void png_read_image(const char*,image<VIEW>&)
00020 // template <typename VIEW>  void png_write_view(const char*,const VIEW&)
00021 // template <typename VIEW>  struct png_read_support;
00022 // template <typename VIEW>  struct png_write_support;
00023 //
00027 
00028 #include <stdio.h>
00029 #include <string>
00030 #include <png.h>
00031 #include <boost/static_assert.hpp>
00032 #include "../../core/gil_config.hpp"
00033 #include "../../core/utilities.hpp"
00034 #include "io_error.hpp"
00035 #include "png_io_private.hpp"
00036 
00037 ADOBE_GIL_NAMESPACE_BEGIN
00038 
00042 inline point2<int> png_read_dimensions(const char *filename) {
00043     detail::png_reader m(filename);
00044     return m.get_dimensions();
00045 }
00046 
00050 inline point2<int> png_read_dimensions(const std::string& filename) {
00051     return png_read_dimensions(filename.c_str());
00052 }
00053 
00056 template <typename VIEW>
00057 struct png_read_support {
00058     BOOST_STATIC_CONSTANT(bool,is_supported=
00059                           (detail::png_read_support_private<typename VIEW::channel_t,
00060                                                             typename VIEW::color_space_t::base>::is_supported));
00061     BOOST_STATIC_CONSTANT(int,bit_depth=
00062                           (detail::png_read_support_private<typename VIEW::channel_t,
00063                                                             typename VIEW::color_space_t::base>::bit_depth));
00064     BOOST_STATIC_CONSTANT(int,color_type=
00065                           (detail::png_read_support_private<typename VIEW::channel_t,
00066                                                             typename VIEW::color_space_t::base>::color_type));
00067     BOOST_STATIC_CONSTANT(bool, value=is_supported);
00068 };
00069 
00075 template <typename VIEW>
00076 inline void png_read_view(const char* filename,const VIEW& view) {
00077     BOOST_STATIC_ASSERT(png_read_support<VIEW>::is_supported);
00078     detail::png_reader m(filename);
00079     m.apply(view);
00080 }
00081 
00084 template <typename VIEW>
00085 inline void png_read_view(const std::string& filename,const VIEW& view) {
00086     png_read_view(filename.c_str(),view);
00087 }
00088 
00094 template <typename IMAGE>
00095 inline void png_read_image(const char* filename,IMAGE& im) {
00096     BOOST_STATIC_ASSERT(png_read_support<typename IMAGE::view_t>::is_supported);
00097     detail::png_reader m(filename);
00098     m.read_image(im);
00099 }
00100 
00103 template <typename IMAGE>
00104 inline void png_read_image(const std::string& filename,IMAGE& im) {
00105     png_read_image(filename.c_str(),im);
00106 }
00107 
00111 template <typename VIEW>
00112 inline void png_read_and_convert_view(const char* filename,const VIEW& view) {
00113     detail::png_reader_color_convert m(filename);
00114     m.apply(view);
00115 }
00116 
00119 template <typename VIEW>
00120 inline void png_read_and_convert_view(const std::string& filename,const VIEW& view) {
00121     png_read_and_convert_view(filename.c_str(),view);
00122 }
00123 
00127 template <typename IMAGE>
00128 inline void png_read_and_convert_image(const char* filename,IMAGE& im) {
00129     detail::png_reader_color_convert m(filename);
00130     m.read_image(im);
00131 }
00132 
00135 template <typename IMAGE>
00136 inline void png_read_and_convert_image(const std::string& filename,IMAGE& im) {
00137     png_read_and_convert_image(filename.c_str(),im);
00138 }
00139 
00142 template <typename VIEW>
00143 struct png_write_support {
00144     BOOST_STATIC_CONSTANT(bool,is_supported=
00145                           (detail::png_write_support_private<typename VIEW::channel_t,
00146                                                              typename VIEW::color_space_t::base>::is_supported));
00147     BOOST_STATIC_CONSTANT(int,bit_depth=
00148                           (detail::png_write_support_private<typename VIEW::channel_t,
00149                                                              typename VIEW::color_space_t::base>::bit_depth));
00150     BOOST_STATIC_CONSTANT(int,color_type=
00151                           (detail::png_write_support_private<typename VIEW::channel_t,
00152                                                              typename VIEW::color_space_t::base>::color_type));
00153     BOOST_STATIC_CONSTANT(bool, value=is_supported);
00154 };
00155 
00160 template <typename VIEW>
00161 inline void png_write_view(const char* filename,const VIEW& view) {
00162     BOOST_STATIC_ASSERT(png_write_support<VIEW>::is_supported);
00163     detail::png_writer m(filename);
00164     m.apply(view);
00165 }
00166 
00169 template <typename VIEW>
00170 inline void png_write_view(const std::string& filename,const VIEW& view) {
00171     png_write_view(filename.c_str(),view);
00172 }
00173 
00174 ADOBE_GIL_NAMESPACE_END
00175 
00176 #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