Public Member Functions | Static Public Member Functions

gnash::JpegImageInput Class Reference

Class for reading JPEG image data. More...

#include <GnashImageJpeg.h>

Inheritance diagram for gnash::JpegImageInput:
gnash::ImageInput

List of all members.

Public Member Functions

DSOEXPORT JpegImageInput (boost::shared_ptr< IOChannel > in)
 Construct a JpegImageInput object to read from an IOChannel.
void DSOEXPORT readHeader (unsigned int maxHeaderBytes)
 Read the JPEG header information only.
 ~JpegImageInput ()
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< ImageInputcreate (boost::shared_ptr< IOChannel > in)
 Create a JpegImageInput and transfer ownership to the caller.
static DSOEXPORT std::auto_ptr
< GnashImage
readSWFJpeg2WithTables (JpegImageInput &loader)
 For reading SWF JPEG2-style image data, using pre-loaded headers stored in the given jpeg::input object.
static std::auto_ptr
< JpegImageInput
createSWFJpeg2HeaderOnly (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 ImageInput interface.


Constructor & Destructor Documentation

gnash::JpegImageInput::JpegImageInput ( boost::shared_ptr< IOChannel in  ) 

Construct a JpegImageInput object to read from an IOChannel.

Parameters:
in The stream to read JPEG data from. Ownership is shared between caller and JpegImageInput, so it is freed automatically when the last owner is destroyed.

Referenced by create(), and createSWFJpeg2HeaderOnly().

gnash::JpegImageInput::~JpegImageInput (  ) 

References finishImage().


Member Function Documentation

static std::auto_ptr<ImageInput> gnash::JpegImageInput::create ( boost::shared_ptr< IOChannel in  )  [inline, static]

Create a JpegImageInput and transfer ownership to the caller.

Parameters:
in The IOChannel to read JPEG data from.

References JpegImageInput().

static std::auto_ptr<JpegImageInput> gnash::JpegImageInput::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:
in The channel to read JPEG header data from.
maxHeaderBytes The maximum number of bytes to read.

References JpegImageInput().

void gnash::JpegImageInput::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::JpegImageInput::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:
msg An error message for logging.
void gnash::JpegImageInput::finishImage (  ) 

Complete processing the image and clean up.

This should close / free all resources from libjpeg.

References _.

Referenced by readSWFJpeg2WithTables(), and ~JpegImageInput().

size_t gnash::JpegImageInput::getComponents (  )  const [virtual]

Get number of components (channels).

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

Implements gnash::ImageInput.

size_t gnash::JpegImageInput::getHeight (  )  const [virtual]

Get the image's height in pixels.

Returns:
The height of the image in pixels.

Implements gnash::ImageInput.

Referenced by readSWFJpeg2WithTables().

size_t gnash::JpegImageInput::getWidth (  )  const [virtual]

Get the image's width in pixels.

Returns:
The width of the image in pixels.

Implements gnash::ImageInput.

Referenced by readScanline(), and readSWFJpeg2WithTables().

void gnash::JpegImageInput::read (  )  [virtual]

Begin processing the image data.

Implements gnash::ImageInput.

References _, gnash::ImageInput::_type, and FALSE.

Referenced by readSWFJpeg2WithTables().

void gnash::JpegImageInput::readHeader ( unsigned int  maxHeaderBytes  ) 

Read the JPEG header information only.

Parameters:
maxHeaderBytes The maximum number of bytes to read before Stopping. If the header is shorter, we stop early.

References _, and FALSE.

void gnash::JpegImageInput::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:
rgbData The buffer for writing raw RGB data to.

Implements gnash::ImageInput.

References getWidth(), and test::w.

Referenced by readSWFJpeg2WithTables().

std::auto_ptr< GnashImage > gnash::JpegImageInput::readSWFJpeg2WithTables ( JpegImageInput loader  )  [static]

For reading SWF JPEG2-style image data, using pre-loaded headers stored in the given jpeg::input object.

Parameters:
loader The JpegImageInput object to use for reading the data. This should have been constructed with createSWFJpeg2HeaderOnly().

References finishImage(), getHeight(), getWidth(), height, read(), readScanline(), gnash::scanline(), and gnash::key::y.


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