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

#include "jpeg_optimizer.h"

Inheritance diagram for pagespeed::image_compression::JpegScanlineWriter:

Public Member Functions

 JpegScanlineWriter (MessageHandler *handler)
void SetJmpBufEnv (jmp_buf *env)
 Set the environment for longjmp calls.
void AbortWrite ()
virtual ScanlineStatus InitWithStatus (const size_t width, const size_t height, PixelFormat pixel_format)
 Initialize the basic parameter for writing the image.
virtual ScanlineStatus InitializeWriteWithStatus (const void *params, GoogleString *compressed)
virtual ScanlineStatus WriteNextScanlineWithStatus (const void *scanline_bytes)
virtual ScanlineStatus FinalizeWriteWithStatus ()
 Finalizes write structure once all scanlines are written.
- Public Member Functions inherited from pagespeed::image_compression::ScanlineWriterInterface
bool Init (const size_t width, const size_t height, PixelFormat pixel_format)
bool InitializeWrite (const void *config, GoogleString *const out)
bool WriteNextScanline (const void *scanline_bytes)
bool FinalizeWrite ()

Detailed Description

User of this class must call this functions in the following sequence func () { JpegScanlineWriter jpeg_writer; jmp_buf env; if (setjmp(env)) { jpeg_writer.AbortWrite(); return; } jpeg_writer.SetJmpBufEnv(&env); if (jpeg_writer.Init(width, height, format)) { jpeg_writer.SetJpegCompressParams(quality); jpeg_writer.InitializeWrite(out); while(has_lines_to_write) { writer.WriteNextScanline(next_scan_line); } writer.FinalizeWrite() } }

Member Function Documentation

void pagespeed::image_compression::JpegScanlineWriter::AbortWrite ( )

This function is only called when jpeg library call longjmp for cleaning up the jpeg structs.

virtual ScanlineStatus pagespeed::image_compression::JpegScanlineWriter::InitializeWriteWithStatus ( const void *  params,
GoogleString compressed 

Set the compression options via 'params', which should be a JpegCompressionOptions*. Since writer only supports lossy encoding, it is an error to pass in a 'params' that has the lossy field set to false.

Implements pagespeed::image_compression::ScanlineWriterInterface.

virtual ScanlineStatus pagespeed::image_compression::JpegScanlineWriter::WriteNextScanlineWithStatus ( const void *  scanline_bytes)

Writes the current scan line with data provided. Returns false if the write fails.

Implements pagespeed::image_compression::ScanlineWriterInterface.

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