Gnash  0.8.11dev
Public Member Functions | Static Public Member Functions | List of all members
gnash::image::JpegInput Class Reference

Class for reading JPEG image data. More...

#include <GnashImageJpeg.h>

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

Public Member Functions

DSOEXPORT JpegInput (std::shared_ptr< IOChannel > in)
 Construct a JpegInput object to read from an IOChannel. More...
 
void DSOEXPORT readHeader (unsigned int maxHeaderBytes)
 Read the JPEG header information only. More...
 
 ~JpegInput ()
 
void read ()
 Begin processing the image data. More...
 
DSOEXPORT void discardPartialBuffer ()
 Discard any data sitting in our input buffer. More...
 
void finishImage ()
 Complete processing the image and clean up. More...
 
size_t getHeight () const
 Get the image's height in pixels. More...
 
size_t getWidth () const
 Get the image's width in pixels. More...
 
size_t getComponents () const
 Get number of components (channels) More...
 
void readScanline (unsigned char *rgbData)
 Read a scanline's worth of image data into the given buffer. More...
 
void errorOccurred (const char *msg)
 This function is called when libjpeg encounters an error. More...
 
- Public Member Functions inherited from gnash::image::Input
 Input (std::shared_ptr< IOChannel > in)
 Construct an Input object to read from an IOChannel. More...
 
virtual ~Input ()
 
ImageType imageType ()
 Get the ImageType of the image. More...
 

Static Public Member Functions

static std::unique_ptr< Inputcreate (std::shared_ptr< IOChannel > in)
 Create a JpegInput and transfer ownership to the caller. More...
 
static DSOEXPORT std::unique_ptr< GnashImagereadSWFJpeg2WithTables (JpegInput &loader)
 For reading SWF JPEG2-style image data, using pre-loaded headers stored in the given JpegInput object. More...
 
static std::unique_ptr< JpegInputcreateSWFJpeg2HeaderOnly (std::shared_ptr< IOChannel > in, unsigned int maxHeaderBytes)
 Create a JPEG 'loader' object by reading a JPEG header. More...
 
- Static Public Member Functions inherited from gnash::image::Input
static DSOEXPORT std::unique_ptr< ImageRGBAreadSWFJpeg3 (std::shared_ptr< gnash::IOChannel > in)
 For reading SWF JPEG3-style image data, like ordinary JPEG, but stores the data in ImageRGBA format. More...
 
static DSOEXPORT std::unique_ptr< GnashImagereadImageData (std::shared_ptr< gnash::IOChannel > in, FileType type)
 Read image data from an IOChannel into an GnashImage. More...
 

Additional Inherited Members

- Protected Attributes inherited from gnash::image::Input
std::shared_ptr< IOChannel_inStream
 
ImageType _type
 

Detailed Description

Class for reading JPEG image data.

This uses the IJG jpeglib to implement the Input interface.

Constructor & Destructor Documentation

§ JpegInput()

gnash::image::JpegInput::JpegInput ( std::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.

§ ~JpegInput()

gnash::image::JpegInput::~JpegInput ( )

Member Function Documentation

§ create()

static std::unique_ptr<Input> gnash::image::JpegInput::create ( std::shared_ptr< IOChannel in)
inlinestatic

Create a JpegInput and transfer ownership to the caller.

Parameters
inThe IOChannel to read JPEG data from.

References DSOEXPORT.

Referenced by gnash::image::Input::readImageData().

§ createSWFJpeg2HeaderOnly()

static std::unique_ptr<JpegInput> gnash::image::JpegInput::createSWFJpeg2HeaderOnly ( std::shared_ptr< IOChannel in,
unsigned int  maxHeaderBytes 
)
inlinestatic

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.

Referenced by gnash::image::Input::readSWFJpeg3().

§ discardPartialBuffer()

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.

Referenced by gnash::SWF::DefineBitsTag::loader().

§ errorOccurred()

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.

References gnash::log_error().

§ finishImage()

void gnash::image::JpegInput::finishImage ( )

Complete processing the image and clean up.

This should close / free all resources from libjpeg.

References _.

Referenced by readSWFJpeg2WithTables().

§ getComponents()

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.

Referenced by read().

§ getHeight()

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

§ getWidth()

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

§ read()

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

§ readHeader()

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 _, and gnash::log_error().

§ readScanline()

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 getWidth(), and test::w.

Referenced by readSWFJpeg2WithTables().

§ readSWFJpeg2WithTables()

std::unique_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 finishImage(), getHeight(), getWidth(), height, read(), readScanline(), gnash::image::scanline(), and y.

Referenced by gnash::SWF::DefineBitsTag::loader().


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