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 #ifndef GNASH_IMAGE_JPEG_H
00024 #define GNASH_IMAGE_JPEG_H
00025
00026 #include <csetjmp>
00027
00028 #include "dsodefs.h"
00029 #include "GnashImage.h"
00030
00031
00032
00033 #undef HAVE_STDLIB_H
00034 extern "C" {
00035 #include <jpeglib.h>
00036 }
00037 #undef HAVE_STDLIB_H
00038
00039
00040 namespace gnash { class IOChannel; }
00041
00042 namespace gnash {
00043 namespace image {
00044
00046
00048 class JpegInput : public Input
00049 {
00050
00051 private:
00052
00053 const char* _errorOccurred;
00054
00055 std::jmp_buf _jmpBuf;
00056
00057
00058 jpeg_decompress_struct m_cinfo;
00059 jpeg_error_mgr m_jerr;
00060
00061 bool _compressorOpened;
00062
00063 public:
00064
00066
00070 DSOEXPORT JpegInput(boost::shared_ptr<IOChannel> in);
00071
00073
00077 void DSOEXPORT readHeader(unsigned int maxHeaderBytes);
00078
00079 ~JpegInput();
00080
00082 void read();
00083
00085
00088 DSOEXPORT void discardPartialBuffer();
00089
00091
00093 void finishImage();
00094
00096
00098 size_t getHeight() const;
00099
00101
00103 size_t getWidth() const;
00104
00106
00108 size_t getComponents() const;
00109
00111
00115 void readScanline(unsigned char* rgbData);
00116
00118
00120 static std::auto_ptr<Input> create(boost::shared_ptr<IOChannel> in)
00121 {
00122 std::auto_ptr<Input> ret(new JpegInput(in));
00123
00124 if (ret.get()) ret->read();
00125 return ret;
00126 }
00127
00131
00135 DSOEXPORT static std::auto_ptr<GnashImage> readSWFJpeg2WithTables(
00136 JpegInput& loader);
00137
00139
00141
00144 static std::auto_ptr<JpegInput> createSWFJpeg2HeaderOnly(
00145 boost::shared_ptr<IOChannel> in, unsigned int maxHeaderBytes)
00146 {
00147 std::auto_ptr<JpegInput> ret (new JpegInput(in));
00148
00149 if (ret.get()) ret->readHeader(maxHeaderBytes);
00150 return ret;
00151 }
00152
00154
00159 void errorOccurred(const char* msg);
00160
00161
00162 };
00163
00164
00165 class JpegOutput : public Output
00166 {
00167
00168 public:
00169
00171
00176 JpegOutput(boost::shared_ptr<IOChannel> out, size_t width,
00177 size_t height, int quality);
00178
00179 ~JpegOutput();
00180
00182
00184 void writeImageRGB(const unsigned char* rgbData);
00185
00187
00192 static std::auto_ptr<Output> create(boost::shared_ptr<IOChannel> out,
00193 size_t width, size_t height, int quality);
00194
00195 private:
00196
00197 jpeg_compress_struct m_cinfo;
00198 jpeg_error_mgr m_jerr;
00199
00200 };
00201
00202 }
00203 }
00204
00205 #endif // JPEG_H
00206
00207
00208
00209
00210
00211
00212