Page principale | Hiérarchie des classes | Liste des composants | Liste des fichiers | Composants

Png.h

00001 #ifndef __W_PNG_H
00002 #define __W_PNG_H
00003 
00004 #include <string>
00005 #include <png.h>
00006 #include <iostream>
00007 
00008 class PNGImage
00009 {
00010 
00011 
00012 public:
00013   std::string filename;
00014   png_structp png_ptr;
00015   png_infop   info_ptr;
00016   unsigned    width, height;
00017   png_byte  **image;
00018   png_byte  **row_pointers;
00019   FILE       *fp;
00020   int bytes_per_pixel;
00021   
00022 public:
00023   PNGImage() {  std::cerr.rdbuf(0);};
00024 
00025   // appelé pour charger une image..
00026   PNGImage(int _width, int _height) : fp(NULL), bytes_per_pixel(3)
00027   {
00028 
00029     std::cerr << "Void cstor";
00030     width = _width;
00031     height = _height;
00032     row_pointers = new png_byte*[width*bytes_per_pixel];
00033     std::cerr.rdbuf(0);
00034   }
00035 
00036   // constructeur que l'on va appeler pour creer une image
00037   PNGImage(const std::string& _filename, int _width, int _height)
00038     : filename(_filename),
00039       png_ptr(NULL), info_ptr(NULL),
00040       width(_width), height(_height),
00041       fp(NULL),
00042       bytes_per_pixel(3)
00043   {
00044 
00045     // allocation de ** image
00046     // [height][width*bytes_per_pixel]
00047     std::cerr.rdbuf(0);
00048 
00049     image = new png_byte* [height];
00050     for (unsigned i=0;i<height;i++)
00051         image[i] = new png_byte [width*bytes_per_pixel];
00052 
00053     row_pointers = new png_byte*[width*bytes_per_pixel];
00054   }
00055 
00056 
00057 
00058   ~PNGImage();
00059 
00060   bool openFileRead();
00061   bool openFileWrite();
00062   bool isPNG(int bytesToCheck);
00063   bool initReadStructs();
00064   bool initWriteStructs();
00065   bool writeHeader();
00066 
00067   png_byte** writeImage_Start();
00068   bool       writeImage_End();
00069 
00070   bool writeEnd();
00071 
00072 };
00073 
00074 #endif

Généré le Mon Jul 18 23:07:41 2005 pour Modelib par doxygen 1.3.6