Page principale | Liste des namespaces | Hiérarchie des classes | Liste alphabétique | Liste des classes | Liste des fichiers | Membres de namespace | Membres de classe | Membres de fichier

Png.h

Aller à la documentation de ce fichier.
00001 /*
00002     Copyright (c) 2005, Quentin Lequy and Romain Gaucher
00003     All rights reserved.
00004 
00005     Redistribution and use in source and binary forms, with or 
00006     without modification, are permitted provided that the following 
00007     conditions are met:
00008 
00009         * Redistributions of source code must retain the above copyright 
00010           notice, this list of conditions and the following disclaimer.
00011 
00012         * Redistributions in binary form must reproduce the above copyright 
00013           notice, this list of conditions and the following disclaimer in the 
00014           documentation and/or other materials provided with the distribution.
00015 
00016         * Neither the name of Quentin Lequy or Romain Gaucher nor the names 
00017           of its contributors may 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
00021     AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
00022     IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
00023     ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
00024     LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
00025     DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
00026     SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
00027     AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
00028     (INCLUDING 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 
00032 #ifndef __W_PNG_H
00033 #define __W_PNG_H
00034 
00035 #include <string>
00036 #include <png.h>
00037 #include <iostream>
00038 
00039 namespace Modelib {
00040 
00041 class PNGImage
00042 {
00043 
00044 
00045 public:
00046   std::string filename;
00047   png_structp png_ptr;
00048   png_infop   info_ptr;
00049   unsigned    width, height;
00050   png_byte  **image;
00051   png_byte  **row_pointers;
00052   FILE       *fp;
00053   int bytes_per_pixel;
00054   
00055 public:
00056   PNGImage() {  std::cerr.rdbuf(0);};
00057 
00058   // appelé pour charger une image..
00059   PNGImage(int _width, int _height) : fp(NULL), bytes_per_pixel(3)
00060   {
00061 
00062     std::cerr << "Void cstor";
00063     width = _width;
00064     height = _height;
00065     row_pointers = new png_byte*[width*bytes_per_pixel];
00066     std::cerr.rdbuf(0);
00067   }
00068 
00069   // constructeur que l'on va appeler pour creer une image
00070   PNGImage(const std::string& _filename, int _width, int _height)
00071     : filename(_filename),
00072       png_ptr(NULL), info_ptr(NULL),
00073       width(_width), height(_height),
00074       fp(NULL),
00075       bytes_per_pixel(3)
00076   {
00077 
00078     // allocation de ** image
00079     // [height][width*bytes_per_pixel]
00080     std::cerr.rdbuf(0);
00081 
00082     image = new png_byte* [height];
00083     for (unsigned i=0;i<height;i++)
00084         image[i] = new png_byte [width*bytes_per_pixel];
00085 
00086     row_pointers = new png_byte*[width*bytes_per_pixel];
00087   }
00088 
00089 
00090 
00091   ~PNGImage();
00092 
00093   bool openFileRead();
00094   bool openFileWrite();
00095   bool isPNG(int bytesToCheck);
00096   bool initReadStructs();
00097   bool initWriteStructs();
00098   bool writeHeader();
00099 
00100   png_byte** writeImage_Start();
00101   bool       writeImage_End();
00102 
00103   bool writeEnd();
00104 
00105 };
00106 
00107 }
00108 
00109 #endif

Généré le Sun Oct 2 19:13:11 2005 pour Modelib par  doxygen 1.4.4