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

#include "pixel_format_optimizer.h"

Inheritance diagram for pagespeed::image_compression::PixelFormatOptimizer:
pagespeed::image_compression::ScanlineReaderInterface

Public Member Functions

 PixelFormatOptimizer (net_instaweb::MessageHandler *handler)
 
ScanlineStatus Initialize (ScanlineReaderInterface *reader)
 PixelFormatOptimizer acquires ownership of reader, even in case of failure.
 
virtual ScanlineStatus ReadNextScanlineWithStatus (void **out_scanline_bytes)
 
virtual bool Reset ()
 Resets the resizer to its initial state. Always returns true.
 
virtual size_t GetBytesPerScanline ()
 Returns number of bytes required to store a scanline.
 
virtual bool HasMoreScanLines ()
 
virtual size_t GetImageHeight ()
 Returns the height of the image.
 
virtual size_t GetImageWidth ()
 Returns the width of the image.
 
virtual PixelFormat GetPixelFormat ()
 Returns the pixel format of the image.
 
virtual bool IsProgressive ()
 Returns true if the image is encoded in progressive / interlacing format.
 
virtual ScanlineStatus InitializeWithStatus (const void *image_buffer, size_t buffer_length)
 
- Public Member Functions inherited from pagespeed::image_compression::ScanlineReaderInterface
bool Initialize (const void *image_buffer, size_t buffer_length)
 
bool ReadNextScanline (void **out_scanline_bytes)
 

Detailed Description

PixelFormatOptimizer removes an unused channel from the image. This corresponds to changing the pixel format to a more compact one. Currently it only removes opaque alpha channel and changes RGBA_8888 to RGB_888.

To determine if a channel is unused, PixelFormatOptimizer has to examine every pixel in the image. Thus, the entire image may be buffered before the first output scanline can be retrieved. However, as soon as PixelFormatOptimizer finds a pixel with all channels used, it will stop buffering and become ready to serve the first scanline.

Todo:
TODO(huibao): Check how often gray scale images are encoded as color. If it happens often, implement the conversion of RGBA_8888/RGB_888 to GRAY_8.

Member Function Documentation

virtual bool pagespeed::image_compression::PixelFormatOptimizer::HasMoreScanLines ( )
inlinevirtual

Returns true if there are more scanlines to read. Returns false if the object has not been initialized or all of the scanlines have been read.

Implements pagespeed::image_compression::ScanlineReaderInterface.

virtual ScanlineStatus pagespeed::image_compression::PixelFormatOptimizer::InitializeWithStatus ( const void *  image_buffer,
size_t  buffer_length 
)
virtual

This method should not be called. If it does get called, in DEBUG mode it will throw a FATAL error and in RELEASE mode it does nothing.

Implements pagespeed::image_compression::ScanlineReaderInterface.

virtual ScanlineStatus pagespeed::image_compression::PixelFormatOptimizer::ReadNextScanlineWithStatus ( void **  out_scanline_bytes)
virtual

Reads the next available scanline. Returns the ScanlineStatus of the conversion.

Implements pagespeed::image_compression::ScanlineReaderInterface.


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