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
00022
00023
00024 #ifndef GNASH_IMAGE_JPEG_H
00025 #define GNASH_IMAGE_JPEG_H
00026
00027 #include <csetjmp>
00028
00029 #include "dsodefs.h"
00030 #include "GnashImage.h"
00031
00032
00033
00034 #undef HAVE_STDLIB_H
00035 extern "C" {
00036 #include <jpeglib.h>
00037 }
00038 #undef HAVE_STDLIB_H
00039
00040
00041 namespace gnash { class IOChannel; }
00042
00043 namespace gnash {
00044 namespace image {
00045
00047
00049 class JpegInput : public Input
00050 {
00051
00052 private:
00053
00054 const char* _errorOccurred;
00055
00056 std::jmp_buf _jmpBuf;
00057
00058
00059 jpeg_decompress_struct m_cinfo;
00060 jpeg_error_mgr m_jerr;
00061
00062 bool _compressorOpened;
00063
00064 public:
00065
00067
00071 DSOEXPORT JpegInput(boost::shared_ptr<IOChannel> in);
00072
00074
00078 void DSOEXPORT readHeader(unsigned int maxHeaderBytes);
00079
00080 ~JpegInput();
00081
00083 void read();
00084
00086
00089 DSOEXPORT void discardPartialBuffer();
00090
00092
00094 void finishImage();
00095
00097
00099 size_t getHeight() const;
00100
00102
00104 size_t getWidth() const;
00105
00107
00109 size_t getComponents() const;
00110
00112
00116 void readScanline(unsigned char* rgbData);
00117
00119
00121 static std::auto_ptr<Input> create(boost::shared_ptr<IOChannel> in)
00122 {
00123 std::auto_ptr<Input> ret(new JpegInput(in));
00124
00125 if (ret.get()) ret->read();
00126 return ret;
00127 }
00128
00132
00136 DSOEXPORT static std::auto_ptr<GnashImage> readSWFJpeg2WithTables(
00137 JpegInput& loader);
00138
00140
00142
00145 static std::auto_ptr<JpegInput> createSWFJpeg2HeaderOnly(
00146 boost::shared_ptr<IOChannel> in, unsigned int maxHeaderBytes)
00147 {
00148 std::auto_ptr<JpegInput> ret (new JpegInput(in));
00149
00150 if (ret.get()) ret->readHeader(maxHeaderBytes);
00151 return ret;
00152 }
00153
00155
00160 void errorOccurred(const char* msg);
00161
00162
00163 };
00164
00165
00166 class JpegOutput : public Output
00167 {
00168
00169 public:
00170
00172
00177 JpegOutput(boost::shared_ptr<IOChannel> out, size_t width,
00178 size_t height, int quality);
00179
00180 ~JpegOutput();
00181
00183
00185 virtual void writeImageRGB(const unsigned char* rgbData);
00186
00188
00190
00192 virtual void writeImageRGBA(const unsigned char* rgbaData);
00193
00195
00200 static std::auto_ptr<Output> create(boost::shared_ptr<IOChannel> out,
00201 size_t width, size_t height, int quality);
00202
00203 private:
00204
00205 jpeg_compress_struct m_cinfo;
00206 jpeg_error_mgr m_jerr;
00207
00208 };
00209
00210 }
00211 }
00212
00213 #endif // JPEG_H
00214
00215
00216
00217
00218
00219
00220