Gnash
0.8.10
|
Class for reading JPEG image data. More...
#include <GnashImageJpeg.h>
Public Member Functions | |
DSOEXPORT | JpegInput (boost::shared_ptr< IOChannel > in) |
Construct a JpegInput object to read from an IOChannel. | |
void DSOEXPORT | readHeader (unsigned int maxHeaderBytes) |
Read the JPEG header information only. | |
~JpegInput () | |
void | read () |
Begin processing the image data. | |
DSOEXPORT void | discardPartialBuffer () |
Discard any data sitting in our input buffer. | |
void | finishImage () |
Complete processing the image and clean up. | |
size_t | getHeight () const |
Get the image's height in pixels. | |
size_t | getWidth () const |
Get the image's width in pixels. | |
size_t | getComponents () const |
Get number of components (channels) | |
void | readScanline (unsigned char *rgbData) |
Read a scanline's worth of image data into the given buffer. | |
void | errorOccurred (const char *msg) |
This function is called when libjpeg encounters an error. | |
Static Public Member Functions | |
static std::auto_ptr< Input > | create (boost::shared_ptr< IOChannel > in) |
Create a JpegInput and transfer ownership to the caller. | |
static DSOEXPORT std::auto_ptr < GnashImage > | readSWFJpeg2WithTables (JpegInput &loader) |
For reading SWF JPEG2-style image data, using pre-loaded headers stored in the given JpegInput object. | |
static std::auto_ptr< JpegInput > | createSWFJpeg2HeaderOnly (boost::shared_ptr< IOChannel > in, unsigned int maxHeaderBytes) |
Create a JPEG 'loader' object by reading a JPEG header. |
Class for reading JPEG image data.
This uses the IJG jpeglib to implement the Input interface.
gnash::image::JpegInput::JpegInput | ( | boost::shared_ptr< IOChannel > | in | ) |
Construct a JpegInput object to read from an IOChannel.
in | The stream to read JPEG data from. Ownership is shared between caller and JpegInput, so it is freed automatically when the last owner is destroyed. |
Referenced by create(), and createSWFJpeg2HeaderOnly().
gnash::image::JpegInput::~JpegInput | ( | ) |
static std::auto_ptr<Input> gnash::image::JpegInput::create | ( | boost::shared_ptr< IOChannel > | in | ) | [inline, static] |
Create a JpegInput and transfer ownership to the caller.
in | The IOChannel to read JPEG data from. |
References JpegInput().
Referenced by gnash::image::Input::readImageData().
static std::auto_ptr<JpegInput> gnash::image::JpegInput::createSWFJpeg2HeaderOnly | ( | boost::shared_ptr< IOChannel > | in, |
unsigned int | maxHeaderBytes | ||
) | [inline, static] |
Create a JPEG 'loader' object by reading a JPEG header.
This is for reusing the header information for different JPEGs images.
in | The channel to read JPEG header data from. |
maxHeaderBytes | The maximum number of bytes to read. |
References JpegInput().
Referenced by gnash::SWF::jpeg_tables_loader(), and gnash::image::Input::readSWFJpeg3().
void gnash::image::JpegInput::discardPartialBuffer | ( | ) |
Discard any data sitting in our input buffer.
Use this before/after reading headers or partial image data, to avoid screwing up future reads.
void gnash::image::JpegInput::errorOccurred | ( | const char * | msg | ) |
This function is called when libjpeg encounters an error.
It is needed to avoid memory corruption during stack unwinding by freeing libjpeg resources correctly before throwing an exception.
msg | An error message for logging. |
void gnash::image::JpegInput::finishImage | ( | ) |
Complete processing the image and clean up.
This should close / free all resources from libjpeg.
References _.
Referenced by readSWFJpeg2WithTables().
size_t gnash::image::JpegInput::getComponents | ( | ) | const [virtual] |
Get number of components (channels)
Implements gnash::image::Input.
References assert.
size_t gnash::image::JpegInput::getHeight | ( | ) | const [virtual] |
Get the image's height in pixels.
Implements gnash::image::Input.
References assert.
Referenced by readSWFJpeg2WithTables().
size_t gnash::image::JpegInput::getWidth | ( | ) | const [virtual] |
Get the image's width in pixels.
Implements gnash::image::Input.
References assert.
Referenced by readScanline(), and readSWFJpeg2WithTables().
void gnash::image::JpegInput::read | ( | ) | [virtual] |
Begin processing the image data.
Implements gnash::image::Input.
References assert, _, gnash::image::Input::_type, and gnash::image::TYPE_RGB.
Referenced by readSWFJpeg2WithTables().
void gnash::image::JpegInput::readHeader | ( | unsigned int | maxHeaderBytes | ) |
Read the JPEG header information only.
maxHeaderBytes | The maximum number of bytes to read before Stopping. If the header is shorter, we stop early. |
References _.
void gnash::image::JpegInput::readScanline | ( | unsigned char * | rgbData | ) | [virtual] |
Read a scanline's worth of image data into the given buffer.
The amount of data read is getWidth() * getComponents().
rgbData | The buffer for writing raw RGB data to. |
Implements gnash::image::Input.
References assert, test::w, and getWidth().
Referenced by readSWFJpeg2WithTables().
std::auto_ptr< GnashImage > gnash::image::JpegInput::readSWFJpeg2WithTables | ( | JpegInput & | loader | ) | [static] |
For reading SWF JPEG2-style image data, using pre-loaded headers stored in the given JpegInput object.
loader | The JpegInput object to use for reading the data. This should have been constructed with createSWFJpeg2HeaderOnly(). |
References read(), getWidth(), getHeight(), y, height, readScanline(), gnash::image::scanline(), and finishImage().