index_pixel.hpp

Go to the documentation of this file.
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_INDEX_PIXEL_HPP_INCLUDED
00032 #define PNGPP_INDEX_PIXEL_HPP_INCLUDED
00033 
00034 #include "types.hpp"
00035 #include "packed_pixel.hpp"
00036 #include "pixel_traits.hpp"
00037 
00038 namespace png
00039 {
00040 
00044     class index_pixel
00045     {
00046     public:
00047         index_pixel(byte index = 0)
00048             : m_index(index)
00049         {
00050         }
00051 
00052         operator byte() const
00053         {
00054             return m_index;
00055         }
00056 
00057     private:
00058         byte m_index;
00059     };
00060 
00065     template< size_t bits >
00066     class packed_index_pixel
00067         : public packed_pixel< bits >
00068     {
00069     public:
00070         packed_index_pixel(byte value = 0)
00071             : packed_pixel< bits >(value)
00072         {
00073         }
00074     };
00075 
00079     typedef packed_index_pixel< 1 > index_pixel_1;
00080 
00084     typedef packed_index_pixel< 2 > index_pixel_2;
00085 
00089     typedef packed_index_pixel< 4 > index_pixel_4;
00090 
00094     template<>
00095     struct pixel_traits< index_pixel >
00096         : basic_pixel_traits< index_pixel, byte, color_type_palette >
00097     {
00098     };
00099 
00103     template< size_t bits >
00104     struct pixel_traits< packed_index_pixel< bits > >
00105         : basic_pixel_traits< packed_index_pixel< bits >, byte,
00106                               color_type_palette, /* channels = */ 1, bits >
00107     {
00108     };
00109 
00110 } // namespace png
00111 
00112 #endif // PNGPP_INDEX_PIXEL_HPP_INCLUDED

Generated on Sun Jul 8 19:33:00 2007 for png++ by  doxygen 1.5.2