png++  0.2.9
image_info.hpp
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2007,2008   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               m_gamma(0.0)
00064         {
00065         }
00066 
00067         uint_32 get_width() const
00068         {
00069             return m_width;
00070         }
00071 
00072         void set_width(uint_32 width)
00073         {
00074             m_width = width;
00075         }
00076 
00077         uint_32 get_height() const
00078         {
00079             return m_height;
00080         }
00081 
00082         void set_height(uint_32 height)
00083         {
00084             m_height = height;
00085         }
00086 
00087         color_type get_color_type() const
00088         {
00089             return m_color_type;
00090         }
00091 
00092         void set_color_type(color_type color_space)
00093         {
00094             m_color_type = color_space;
00095         }
00096 
00097         int get_bit_depth() const
00098         {
00099             return m_bit_depth;
00100         }
00101 
00102         void set_bit_depth(int bit_depth)
00103         {
00104             m_bit_depth = bit_depth;
00105         }
00106 
00107         interlace_type get_interlace_type() const
00108         {
00109             return m_interlace_type;
00110         }
00111 
00112         void set_interlace_type(interlace_type interlace)
00113         {
00114             m_interlace_type = interlace;
00115         }
00116 
00117         compression_type get_compression_type() const
00118         {
00119             return m_compression_type;
00120         }
00121 
00122         void set_compression_type(compression_type compression)
00123         {
00124             m_compression_type = compression;
00125         }
00126 
00127         filter_type get_filter_type() const
00128         {
00129             return m_filter_type;
00130         }
00131 
00132         void set_filter_type(filter_type filter)
00133         {
00134             m_filter_type = filter;
00135         }
00136 
00137         palette const& get_palette() const
00138         {
00139             return m_palette;
00140         }
00141 
00142         palette& get_palette()
00143         {
00144             return m_palette;
00145         }
00146 
00147         void set_palette(palette const& plte)
00148         {
00149             m_palette = plte;
00150         }
00151 
00155         void drop_palette()
00156         {
00157             m_palette.clear();
00158         }
00159 
00160         tRNS const& get_tRNS() const
00161         {
00162             return m_tRNS;
00163         }
00164 
00165         tRNS& get_tRNS()
00166         {
00167             return m_tRNS;
00168         }
00169 
00170         void set_tRNS(tRNS const& trns)
00171         {
00172             m_tRNS = trns;
00173         }
00174 
00175         double get_gamma() const
00176         {
00177             return m_gamma;
00178         }
00179 
00180         void set_gamma(double gamma)
00181         {
00182             m_gamma = gamma;
00183         }
00184 
00185     protected:
00186         uint_32 m_width;
00187         uint_32 m_height;
00188         int m_bit_depth;
00189         color_type m_color_type;
00190         interlace_type m_interlace_type;
00191         compression_type m_compression_type;
00192         filter_type m_filter_type;
00193         palette m_palette;
00194         tRNS m_tRNS;
00195         double m_gamma;
00196     };
00197 
00202     template< typename pixel >
00203     image_info
00204     make_image_info()
00205     {
00206         typedef pixel_traits< pixel > traits;
00207         image_info info;
00208         info.set_color_type(traits::get_color_type());
00209         info.set_bit_depth(traits::get_bit_depth());
00210         return info;
00211     }
00212 
00213 } // namespace png
00214 
00215 #endif // PNGPP_IMAGE_INFO_HPP_INCLUDED