Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Friends | List of all members
pagespeed::image_compression::GifFrameReader Class Reference

#include "gif_reader.h"

Inheritance diagram for pagespeed::image_compression::GifFrameReader:
pagespeed::image_compression::MultipleFrameReader

Public Member Functions

virtual ScanlineStatus Reset ()
 Resets the MultipleFrameReader to its initial state.
 
virtual ScanlineStatus Initialize ()
 
virtual bool HasMoreFrames () const
 
virtual bool HasMoreScanlines () const
 
virtual ScanlineStatus PrepareNextFrame ()
 
virtual ScanlineStatus ReadNextScanline (const void **out_scanline_bytes)
 
virtual ScanlineStatus GetFrameSpec (FrameSpec *frame_spec) const
 
virtual ScanlineStatus GetImageSpec (ImageSpec *image_spec) const
 
virtual ScanlineStatus set_quirks_mode (QuirksMode quirks_mode)
 
- Public Member Functions inherited from pagespeed::image_compression::MultipleFrameReader
 MultipleFrameReader (MessageHandler *handler)
 
ScanlineStatus Initialize (const void *image_buffer, size_t buffer_length)
 
MessageHandlermessage_handler () const
 
virtual QuirksMode quirks_mode () const
 
bool Reset (ScanlineStatus *status)
 
bool Initialize (const void *image_buffer, size_t buffer_length, ScanlineStatus *status)
 
bool Initialize (ScanlineStatus *status)
 
bool PrepareNextFrame (ScanlineStatus *status)
 
bool ReadNextScanline (const void **out_scanline_bytes, ScanlineStatus *status)
 
bool GetFrameSpec (FrameSpec *frame_spec, ScanlineStatus *status)
 
bool GetImageSpec (ImageSpec *image_spec, ScanlineStatus *status)
 
bool set_quirks_mode (QuirksMode quirks_mode, ScanlineStatus *status)
 

Static Public Member Functions

static void ApplyQuirksModeToImage (QuirksMode quirks_mode, bool has_loop_count, const FrameSpec &frame_spec, ImageSpec *image_spec)
 
static void ApplyQuirksModeToFirstFrame (QuirksMode quirks_mode, const ImageSpec &image_spec, FrameSpec *frame_spec)
 

Friends

class TestGifFrameReader
 Used in gif_reader_test.cc and frame_interface_integration_test.cc.
 
MultipleFrameReaderInstantiateImageFrameReader (ImageFormat image_type, MessageHandler *handler, ScanlineStatus *status)
 

Additional Inherited Members

- Protected Attributes inherited from pagespeed::image_compression::MultipleFrameReader
const void * image_buffer_
 
size_t buffer_length_
 

Detailed Description

GifFrameReader decodes GIF images and outputs the raw pixel data, image size, pixel type, etc. The class accepts both single frame and animated GIFs. The output is RGB_888 if transparent color is not specified, or RGBA_8888 otherwise.

Note: The input image stream must be valid throughout the life of the object. In other words, the image_buffer input you set to Initialize() cannot be changed until your last call to the ReadNextScanline(). That said, if you are sure that your image is a single-frame progressive GIF, you can modify image_buffer after the first call to ReadNextScanline().

Note: In the wild, there are many static GIFs that don't conform to the GIF standard by having, for example, image dimensions larger than frame dimensions. The workaround for such images is to properly pad those frames. Because this is such a common occurrence, we disallow instantiating GifFrameReader directly and instead require that clients call CreateImageFrameReader() to instantiate this class.

Member Function Documentation

static void pagespeed::image_compression::GifFrameReader::ApplyQuirksModeToFirstFrame ( QuirksMode  quirks_mode,
const ImageSpec image_spec,
FrameSpec frame_spec 
)
static

Apply the specified browser-specific tweaking of the first frame's frame_spec based on image_spec.

static void pagespeed::image_compression::GifFrameReader::ApplyQuirksModeToImage ( QuirksMode  quirks_mode,
bool  has_loop_count,
const FrameSpec frame_spec,
ImageSpec image_spec 
)
static

Apply the specified browser-specific tweaking of image_spec based on the first frame's frame_spec and whether an explicit loop_count was read from the GIF file.

virtual ScanlineStatus pagespeed::image_compression::GifFrameReader::GetFrameSpec ( FrameSpec frame_spec) const
inlinevirtual

Assigns to '*frame_spec' the FrameSpec describing the current frame.

Todo:
TODO(vchudnov): Consider simplifying this method to return frame_spec rather than the ScanlineStatus.

Implements pagespeed::image_compression::MultipleFrameReader.

virtual ScanlineStatus pagespeed::image_compression::GifFrameReader::GetImageSpec ( ImageSpec image_spec) const
inlinevirtual

Copies into '*image_spec' the ImageSpec describing the image.

Implements pagespeed::image_compression::MultipleFrameReader.

virtual bool pagespeed::image_compression::GifFrameReader::HasMoreFrames ( ) const
inlinevirtual

Returns true iff the image being read has additional frames beyond the current frame being read. For any well-formed image with at least one frame (or for a well-formed static image), this will return true before the first call to PrepareNextFrame().

Implements pagespeed::image_compression::MultipleFrameReader.

virtual bool pagespeed::image_compression::GifFrameReader::HasMoreScanlines ( ) const
inlinevirtual

Returns true iff the current frame has more scanlines that have not yet been read.

Implements pagespeed::image_compression::MultipleFrameReader.

virtual ScanlineStatus pagespeed::image_compression::GifFrameReader::Initialize ( )
virtual

Initialize the reader with the given image stream. Note that image_buffer must remain unchanged until the last call to ReadNextScanlineWithStatus().

Implements pagespeed::image_compression::MultipleFrameReader.

virtual ScanlineStatus pagespeed::image_compression::GifFrameReader::PrepareNextFrame ( )
virtual

Prepares to read scanlines from the frame after the current one. Must be called before reading from the first frame.

Implements pagespeed::image_compression::MultipleFrameReader.

virtual ScanlineStatus pagespeed::image_compression::GifFrameReader::ReadNextScanline ( const void **  out_scanline_bytes)
virtual

Return the next row of pixels. For non-progressive GIF, ReadNextScanline will decode one row of pixels each time when it is called, but for progressive GIF, ReadNextScanline will decode the entire image at the first time when it is called.

Implements pagespeed::image_compression::MultipleFrameReader.

Friends And Related Function Documentation

MultipleFrameReader* InstantiateImageFrameReader ( ImageFormat  image_type,
MessageHandler handler,
ScanlineStatus status 
)
friend

Clients should call this function to instantiate GifFrameReader. This function is defined in read_image.cc.


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