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 | List of all members
pagespeed::image_compression::PngReaderInterface Class Referenceabstract

#include "png_optimizer.h"

Inheritance diagram for pagespeed::image_compression::PngReaderInterface:
pagespeed::image_compression::GifReader pagespeed::image_compression::PngReader

Public Member Functions

virtual bool ReadPng (const GoogleString &body, png_structp png_ptr, png_infop info_ptr, int transforms, bool require_opaque) const =0
 
bool ReadPng (const GoogleString &body, png_structp png_ptr, png_infop info_ptr, int transforms) const
 
virtual bool GetAttributes (const GoogleString &body, int *out_width, int *out_height, int *out_bit_depth, int *out_color_type) const =0
 

Static Public Member Functions

static bool GetBackgroundColor (png_structp png_ptr, png_infop info_ptr, unsigned char *red, unsigned char *green, unsigned char *blue, MessageHandler *handler)
 
static bool IsAlphaChannelOpaque (png_structp png_ptr, png_infop info_ptr, MessageHandler *handler)
 

Detailed Description

Helper class that provides an API to read a PNG image from some source.

Member Function Documentation

virtual bool pagespeed::image_compression::PngReaderInterface::GetAttributes ( const GoogleString body,
int *  out_width,
int *  out_height,
int *  out_bit_depth,
int *  out_color_type 
) const
pure virtual

Get just the attributes of the given image. out_bit_depth is the number of bits per channel. out_color_type is one of the PNG_COLOR_TYPE_* declared in png.h.

Todo:
TODO(bmcquade): consider merging this with ImageAttributes.

Implemented in pagespeed::image_compression::PngReader, and pagespeed::image_compression::GifReader.

static bool pagespeed::image_compression::PngReaderInterface::GetBackgroundColor ( png_structp  png_ptr,
png_infop  info_ptr,
unsigned char *  red,
unsigned char *  green,
unsigned char *  blue,
MessageHandler handler 
)
static

Get the background color, in the form of 8-bit RGB triplets. Note that if the underlying image uses a bit_depth other than 8, the background color will be scaled to 8-bits per channel.

static bool pagespeed::image_compression::PngReaderInterface::IsAlphaChannelOpaque ( png_structp  png_ptr,
png_infop  info_ptr,
MessageHandler handler 
)
static

Returns true if the alpha channel is actually a opaque. Returns false otherwise. It is an error to call this method for an image that does not have an alpha channel.

virtual bool pagespeed::image_compression::PngReaderInterface::ReadPng ( const GoogleString body,
png_structp  png_ptr,
png_infop  info_ptr,
int  transforms,
bool  require_opaque 
) const
pure virtual

Parse the contents of body, convert to a PNG, and populate the PNG structures with the PNG representation. If 'require_opaque' is true, returns an image without an alpha channel if the original image has no transparent pixels, and fails otherwise. Returns true on success, false on failure.

Implemented in pagespeed::image_compression::PngReader, and pagespeed::image_compression::GifReader.

bool pagespeed::image_compression::PngReaderInterface::ReadPng ( const GoogleString body,
png_structp  png_ptr,
png_infop  info_ptr,
int  transforms 
) const
inline

Parse the contents of body, convert to a PNG, and populate the PNG structures with the PNG representation. Returns true on success, false on failure.


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