00001 /* 00002 * Copyright (C) 2007 Alex Shulgin 00003 * 00004 * This file is part of png++ the C++ wrapper for libpng. Png++ is free 00005 * software; the exact copying conditions are as follows: 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions are met: 00009 * 00010 * 1. Redistributions of source code must retain the above copyright notice, 00011 * this list of conditions and the following disclaimer. 00012 * 00013 * 2. Redistributions in binary form must reproduce the above copyright 00014 * notice, this list of conditions and the following disclaimer in the 00015 * documentation and/or other materials provided with the distribution. 00016 * 00017 * 3. The name of the author may not be used to endorse or promote products 00018 * derived from this software without specific prior written permission. 00019 * 00020 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 00021 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00022 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 00023 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00024 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 00025 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00026 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00027 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00028 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00029 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00030 */ 00031 #ifndef PNGPP_IMAGE_INFO_HPP_INCLUDED 00032 #define PNGPP_IMAGE_INFO_HPP_INCLUDED 00033 00034 #include "types.hpp" 00035 #include "palette.hpp" 00036 #include "tRNS.hpp" 00037 #include "pixel_traits.hpp" 00038 00039 namespace png 00040 { 00041 00047 class image_info 00048 { 00049 public: 00055 image_info() 00056 : m_width(0), 00057 m_height(0), 00058 m_bit_depth(0), 00059 m_color_type(color_type_none), 00060 m_interlace_type(interlace_none), 00061 m_compression_type(compression_type_default), 00062 m_filter_type(filter_type_default) 00063 { 00064 } 00065 00066 size_t get_width() const 00067 { 00068 return m_width; 00069 } 00070 00071 void set_width(size_t width) 00072 { 00073 m_width = width; 00074 } 00075 00076 size_t get_height() const 00077 { 00078 return m_height; 00079 } 00080 00081 void set_height(size_t height) 00082 { 00083 m_height = height; 00084 } 00085 00086 color_type get_color_type() const 00087 { 00088 return m_color_type; 00089 } 00090 00091 void set_color_type(color_type color_space) 00092 { 00093 m_color_type = color_space; 00094 } 00095 00096 size_t get_bit_depth() const 00097 { 00098 return m_bit_depth; 00099 } 00100 00101 void set_bit_depth(size_t bit_depth) 00102 { 00103 m_bit_depth = bit_depth; 00104 } 00105 00106 interlace_type get_interlace_type() const 00107 { 00108 return m_interlace_type; 00109 } 00110 00111 void set_interlace_type(interlace_type interlace) 00112 { 00113 m_interlace_type = interlace; 00114 } 00115 00116 compression_type get_compression_type() const 00117 { 00118 return m_compression_type; 00119 } 00120 00121 void set_compression_type(compression_type compression) 00122 { 00123 m_compression_type = compression; 00124 } 00125 00126 filter_type get_filter_type() const 00127 { 00128 return m_filter_type; 00129 } 00130 00131 void set_filter_type(filter_type filter) 00132 { 00133 m_filter_type = filter; 00134 } 00135 00136 palette const& get_palette() const 00137 { 00138 return m_palette; 00139 } 00140 00141 palette& get_palette() 00142 { 00143 return m_palette; 00144 } 00145 00146 void set_palette(palette const& plte) 00147 { 00148 m_palette = plte; 00149 } 00150 00154 void drop_palette() 00155 { 00156 m_palette.clear(); 00157 } 00158 00159 tRNS const& get_tRNS() const 00160 { 00161 return m_tRNS; 00162 } 00163 00164 tRNS& get_tRNS() 00165 { 00166 return m_tRNS; 00167 } 00168 00169 void set_tRNS(tRNS const& trns) 00170 { 00171 m_tRNS = trns; 00172 } 00173 00174 protected: 00175 uint_32 m_width; 00176 uint_32 m_height; 00177 size_t m_bit_depth; 00178 color_type m_color_type; 00179 interlace_type m_interlace_type; 00180 compression_type m_compression_type; 00181 filter_type m_filter_type; 00182 palette m_palette; 00183 tRNS m_tRNS; 00184 }; 00185 00190 template< typename pixel > 00191 image_info 00192 make_image_info() 00193 { 00194 typedef pixel_traits< pixel > traits; 00195 image_info info; 00196 info.set_color_type(traits::get_color_type()); 00197 info.set_bit_depth(traits::get_bit_depth()); 00198 return info; 00199 } 00200 00201 } // namespace png 00202 00203 #endif // PNGPP_IMAGE_INFO_HPP_INCLUDED