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 { class IOChannel; }
00041
00042 namespace gnash {
00043
00044 class PngImageInput : public ImageInput
00045 {
00046
00047 public:
00048
00050
00054 PngImageInput(boost::shared_ptr<IOChannel> in);
00055
00056 ~PngImageInput();
00057
00059 void read();
00060
00062
00064 size_t getHeight() const;
00065
00067
00069 size_t getWidth() const;
00070
00072
00076 void readScanline(unsigned char* imageData);
00077
00079
00081 DSOEXPORT static std::auto_ptr<ImageInput> create(
00082 boost::shared_ptr<IOChannel> in)
00083 {
00084 std::auto_ptr<ImageInput> ret ( new PngImageInput(in) );
00085 if (ret.get()) ret->read();
00086 return ret;
00087 }
00088
00089 private:
00090
00091
00092 png_structp _pngPtr;
00093 png_infop _infoPtr;
00094 boost::scoped_array<png_bytep> _rowPtrs;
00095 boost::scoped_array<png_byte> _pixelData;
00096
00097
00098 size_t _currentRow;
00099
00100 void init();
00101
00102
00103
00104 size_t getComponents() const;
00105
00106 };
00107
00108
00109 class PngImageOutput : public ImageOutput
00110 {
00111
00112 public:
00113
00115
00119 PngImageOutput(boost::shared_ptr<IOChannel> out, size_t width,
00120 size_t height, int quality);
00121
00122 ~PngImageOutput();
00123
00124 void writeImageRGB(const unsigned char* rgbData);
00125
00126 void writeImageRGBA(const unsigned char* rgbaData);
00127
00128 static std::auto_ptr<ImageOutput> create(boost::shared_ptr<IOChannel> out,
00129 size_t width, size_t height, int quality);
00130
00131 private:
00132
00134 void init();
00135
00137 png_structp _pngPtr;
00138 png_infop _infoPtr;
00139
00140 };
00141
00142 }
00143
00144
00145
00146 #endif