PNG.hpp

Go to the documentation of this file.
00001 #pragma ident "$Id: PNG.hpp 1644 2009-01-27 19:26:14Z ckiesch $"
00002 
00004 
00005 //============================================================================
00006 //
00007 //  This file is part of GPSTk, the GPS Toolkit.
00008 //
00009 //  The GPSTk is free software; you can redistribute it and/or modify
00010 //  it under the terms of the GNU Lesser General Public License as published
00011 //  by the Free Software Foundation; either version 2.1 of the License, or
00012 //  any later version.
00013 //
00014 //  The GPSTk is distributed in the hope that it will be useful,
00015 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 //  GNU Lesser General Public License for more details.
00018 //
00019 //  You should have received a copy of the GNU Lesser General Public
00020 //  License along with GPSTk; if not, write to the Free Software Foundation,
00021 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 //  
00023 //  Copyright 2004, The University of Texas at Austin
00024 //
00025 //============================================================================
00026 
00027 
00028 #ifndef VDRAW_PNG_H
00029 #define VDRAW_PNG_H
00030 
00031 #include<string>
00032 #include<sstream>
00033 #include<cmath>
00034 #include<memory>
00035 
00036 #include "Bitmap.hpp"
00037 #include "Color.hpp"
00038 #include "ColorMap.hpp"
00039 #include "InterpolatedColorMap.hpp"
00040 #include "Palette.hpp"
00041 #include "CRC32.hpp"
00042 #include "Adler32.hpp"
00043 
00044 namespace vdraw
00045 {
00048 
00052   class PNG
00053   {
00054     public:
00056       typedef std::auto_ptr<std::string> string_ptr;
00057 
00062       static std::string png(const Bitmap &b);
00063 
00068       static string_ptr png(const ColorMap &c, int osr=1, int osc=1);
00069 
00074       static string_ptr png(const InterpolatedColorMap &c, int osr=1, int osc=1);
00075 
00078       static int cost_indexed(const Bitmap& b);
00079 
00081       static int cost_indexed(int rows, int cols, int numcol);
00082 
00084       static int cost_constant(const Bitmap& b);
00085 
00087       static int cost_constant(int rows, int cols);
00088 
00089     protected:
00091       static const std::string header;
00092 
00094       static int cost_idat(int stream);
00095 
00097       static string_ptr ihdr_full(int width, int height);
00098 
00100       static string_ptr ihdr_indexed(int width, int height);
00101 
00103       static string_ptr srgb();
00104 
00106       static string_ptr phys();
00107 
00109       static string_ptr plte(const InterpolatedColorMap &c);
00110 
00111       /*
00112        * ZLIB flag information
00113        * First two bytes:
00114        * +-----+-----+
00115        * | CMP | FLG |
00116        * +-----+-----+
00117        * CMP:
00118        *  - Bits 0-3 = 0x08 (deflate compression)
00119        *  - Bits 4-7 = For CM = 8, CINFO is the base-2 logarithm 
00120        *    of the LZ77 window size, minus eight
00121        *
00122        */
00123 
00125       static string_ptr idat(const InterpolatedColorMap &c, int osr, int osc);
00126 
00128       static string_ptr idat(const ColorMap &c, int osr, int osc);
00129 
00131       static string_ptr split(const std::string &str);
00132 
00134       static string_ptr prefix(const std::string &str);
00135 
00137       static string_ptr huff(const std::string &str);
00138 
00140       static string_ptr data(const ColorMap &c, int osr, int osc);
00141 
00143       static string_ptr data(const InterpolatedColorMap &c, int osr, int osc);
00144 
00146       static unsigned int alder(const string_ptr &str);
00147 
00149       static string_ptr iend();
00150 
00152       static string_ptr chunk(const std::string &title, const std::string &text);
00153 
00155       static string_ptr itos(int i);
00156 
00158       static string_ptr ctos(const Color &color);
00159 
00161       static char btoc(int b);
00162 
00163   }; // class PNG
00164 
00166 
00167 } // namespace vdraw
00168 
00169 #endif //VDRAW_PNG_H
00170 
00171 

Generated on Wed Feb 8 03:31:01 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1