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 "pixel_traits.hpp" 00037 00038 namespace png 00039 { 00040 00046 class image_info 00047 { 00048 public: 00054 image_info() 00055 : m_width(0), 00056 m_height(0), 00057 m_bit_depth(0), 00058 m_color_type(color_type_none), 00059 m_interlace_type(interlace_none), 00060 m_compression_type(compression_type_default), 00061 m_filter_type(filter_type_default) 00062 { 00063 } 00064 00065 size_t get_width() const 00066 { 00067 return m_width; 00068 } 00069 00070 void set_width(size_t width) 00071 { 00072 m_width = width; 00073 } 00074 00075 size_t get_height() const 00076 { 00077 return m_height; 00078 } 00079 00080 void set_height(size_t height) 00081 { 00082 m_height = height; 00083 } 00084 00085 color_type get_color_type() const 00086 { 00087 return m_color_type; 00088 } 00089 00090 void set_color_type(color_type color_space) 00091 { 00092 m_color_type = color_space; 00093 } 00094 00095 size_t get_bit_depth() const 00096 { 00097 return m_bit_depth; 00098 } 00099 00100 void set_bit_depth(size_t bit_depth) 00101 { 00102 m_bit_depth = bit_depth; 00103 } 00104 00105 interlace_type get_interlace_type() const 00106 { 00107 return m_interlace_type; 00108 } 00109 00110 void set_interlace_type(interlace_type interlace) 00111 { 00112 m_interlace_type = interlace; 00113 } 00114 00115 compression_type get_compression_type() const 00116 { 00117 return m_compression_type; 00118 } 00119 00120 void set_compression_type(compression_type compression) 00121 { 00122 m_compression_type = compression; 00123 } 00124 00125 filter_type get_filter_type() const 00126 { 00127 return m_filter_type; 00128 } 00129 00130 void set_filter_type(filter_type filter) 00131 { 00132 m_filter_type = filter; 00133 } 00134 00135 palette const& get_palette() const 00136 { 00137 return m_palette; 00138 } 00139 00140 palette& get_palette() 00141 { 00142 return m_palette; 00143 } 00144 00145 void set_palette(palette const& plte) 00146 { 00147 m_palette = plte; 00148 } 00149 00153 void drop_palette() 00154 { 00155 m_palette.clear(); 00156 } 00157 00158 protected: 00159 uint_32 m_width; 00160 uint_32 m_height; 00161 size_t m_bit_depth; 00162 color_type m_color_type; 00163 interlace_type m_interlace_type; 00164 compression_type m_compression_type; 00165 filter_type m_filter_type; 00166 palette m_palette; 00167 }; 00168 00173 template< typename pixel > 00174 image_info 00175 make_image_info() 00176 { 00177 typedef pixel_traits< pixel > traits; 00178 image_info info; 00179 info.set_color_type(traits::get_color_type()); 00180 info.set_bit_depth(traits::get_bit_depth()); 00181 return info; 00182 } 00183 00184 } // namespace png 00185 00186 #endif // PNGPP_IMAGE_INFO_HPP_INCLUDED