Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef GNASH_IMAGE_PNG_H
00022 #define GNASH_IMAGE_PNG_H
00023
00024 #include <memory>
00025
00026 #include "dsodefs.h"
00027 #include "GnashImage.h"
00028 #include <boost/scoped_array.hpp>
00029
00030
00031 extern "C" {
00032 #ifdef HAVE_PNG_H
00033 #include <png.h>
00034 #else
00035 #warning "This system doesn't have png.h installed!"
00036 #endif
00037 }
00038
00039
00040 namespace gnash {
00041 class IOChannel;
00042 }
00043
00044 namespace gnash {
00045 namespace image {
00046
00047 class PngInput : public Input
00048 {
00049
00050 public:
00051
00053
00057 PngInput(boost::shared_ptr<IOChannel> in);
00058
00059 ~PngInput();
00060
00062 void read();
00063
00065
00067 size_t getHeight() const;
00068
00070
00072 size_t getWidth() const;
00073
00075
00079 void readScanline(unsigned char* imageData);
00080
00082
00084 DSOEXPORT static std::auto_ptr<Input> create(
00085 boost::shared_ptr<IOChannel> in)
00086 {
00087 std::auto_ptr<Input> ret ( new PngInput(in) );
00088 if (ret.get()) ret->read();
00089 return ret;
00090 }
00091
00092 private:
00093
00094
00095 png_structp _pngPtr;
00096 png_infop _infoPtr;
00097 boost::scoped_array<png_bytep> _rowPtrs;
00098 boost::scoped_array<png_byte> _pixelData;
00099
00100
00101 size_t _currentRow;
00102
00103 void init();
00104
00105
00106
00107 size_t getComponents() const;
00108
00109 };
00110
00111
00112 class PngOutput : public Output
00113 {
00114
00115 public:
00116
00118
00122 PngOutput(boost::shared_ptr<IOChannel> out, size_t width,
00123 size_t height, int quality);
00124
00125 ~PngOutput();
00126
00127 void writeImageRGB(const unsigned char* rgbData);
00128
00129 void writeImageRGBA(const unsigned char* rgbaData);
00130
00131 static std::auto_ptr<Output> create(boost::shared_ptr<IOChannel> out,
00132 size_t width, size_t height, int quality);
00133
00134 private:
00135
00137 void init();
00138
00140 png_structp _pngPtr;
00141 png_infop _infoPtr;
00142
00143 };
00144
00145 }
00146 }
00147
00148
00149
00150 #endif