Gnash  0.8.10
Public Member Functions | Static Public Member Functions
gnash::image::JpegInput Class Reference

Class for reading JPEG image data. More...

#include <GnashImageJpeg.h>

Inheritance diagram for gnash::image::JpegInput:
gnash::image::Input

List of all members.

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< Inputcreate (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< JpegInputcreateSWFJpeg2HeaderOnly (boost::shared_ptr< IOChannel > in, unsigned int maxHeaderBytes)
 Create a JPEG 'loader' object by reading a JPEG header.

Detailed Description

Class for reading JPEG image data.

This uses the IJG jpeglib to implement the Input interface.


Constructor & Destructor Documentation

gnash::image::JpegInput::JpegInput ( boost::shared_ptr< IOChannel in)

Construct a JpegInput object to read from an IOChannel.

Parameters:
inThe 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 ( )

Member Function Documentation

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.

Parameters:
inThe 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.

Parameters:
inThe channel to read JPEG header data from.
maxHeaderBytesThe 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.

Parameters:
msgAn 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)

Returns:
The number of components, e.g. 3 for RGB

Implements gnash::image::Input.

References assert.

size_t gnash::image::JpegInput::getHeight ( ) const [virtual]

Get the image's height in pixels.

Returns:
The height of the image 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.

Returns:
The width of the image 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.

Parameters:
maxHeaderBytesThe 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().

Parameters:
rgbDataThe 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.

Parameters:
loaderThe 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().


The documentation for this class was generated from the following files: