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:
Inheritance graph
[legend]
Collaboration diagram for gnash::image::JpegInput:
Collaboration graph
[legend]

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

References finishImage().


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:
in The IOChannel to read JPEG data from.

References JpegInput().

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

References JpegInput().

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:
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(), and ~JpegInput().

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.

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.

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.

Referenced by readScanline(), and readSWFJpeg2WithTables().

void gnash::image::JpegInput::read (  )  [virtual]

Begin processing the image data.

Implements gnash::image::Input.

References _, gnash::image::Input::_type, and FALSE.

Referenced by readSWFJpeg2WithTables().

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

Implements gnash::image::Input.

References getWidth(), and test::w.

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:
loader The JpegInput object to use for reading the data. This should have been constructed with createSWFJpeg2HeaderOnly().

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


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