Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site













SourceForge.net Logo

RasterEncoder

 

class RasterEncoder

RasterEncoder serves as consumer of RGBA scanline data. Typical use is as encoder into one of common image file formats, like PNG. RasterEncoder provides an output buffer for client code (producer) to store the output RGBA scanline, when scanline is finished, producer calls WriteLine and RasterEncoder converts the RGBA scanline into specific format, according to format protected member variable, then calls WriteLineRaw virtual method which performs the final processing (e.g. PNGEncoder stores it into PNG output stream).

RGBA optimization: There is a specific need to avoid redundant conversions and copies when the target is normal Image (with ImageEncoder). SetLine method can replace the default scanline buffer provided by RasterEncoder; that way it can use a pointer to ImageBuffer data and data are then can be stored directly into ImageBuffer (ImageEncoder calls SetLine in Start and WriteLineRaw methods). WriteLineRaw can then check whether data points to suggested buffer (it is not guaranteed, because producer can provide yet another scanline buffer in WriteLine) and in that case, copying into target scanline can be completely skipped.

 

 

Protected Members List

 

RasterFormat format

Derived encoder should store the required conversion format here in Start method.

 


 

void SetLine(RGBA *_line)

Replaces the default scanline buffer to optimize storing RGBA data to direct targets..

 

 

Public Method List

 

virtual int GetPaletteCount()

Returns the number of colors in the palette (or zero).

 


 

virtual void Start(Size sz) = 0

Called at the start of processing sz.

 


 

virtual void WriteLineRaw(const byte *data) = 0

Called to write a single scanline data to output.

 


 

void WriteLine()

Encodes the internal RasterEncoder scanline buffer - converts it to required format and calls WriteLineRaw.

 


 

void WriteLine(const RGBA *s)

Encodes the scanline s - converts it to required format and calls WriteLineRaw.

 


 

const RasterFormat& GetFormat() const

Returns current format.

 


 

const RGBA *GetPalette()

Returns current palette.

 


 

const PaletteCv *GetPaletteCv()

Returns palette convertor.

 


 

operator RGBA *()

RGBA *operator~()

Returns the pointer to scanline buffer that is used in parameterless WriteLine.

 


 

Size GetSize() const

Returns the size.

 


 

int GetWidth() const

Same as GetSize().cx.

 


 

int GetHeight() const

Same as GetSize().cy.

 


 

void SetHotSpot(Point p)

Sets hotspot. This is useful for defining screen cursors (.ico or .cur files in Win32). The derived encoder might need the hotspot information (it reads it by calling GetHotSpot in to store it into the output file in Start).

 


 

Point GetHotSpot() const

Reads hotspot set be SetHotSpot.

 


 

void SetDots(Size _dots)

Sets the physical size of output image, in 1/600 of inch. The derived encoder might read this information in Start and store it into output file, if given format supports any related information.

 


 

Size GetDots() const

Returns the size set by SetDots.

 


 

void SetPalette(const RGBA *palette)

Sets the palette to be used with raster.

 


 

void SetPalette(Raster& pal_raster)

Generates the optimal palette based on colors in pal_raster and sets it for further processing.

 


 

void Create(Size sz)

void Create(int cx, int cy)

void Create(Size sz, const RGBA *palette)

void Create(int cx, int cy, const RGBA *palette)

void Create(Size sz, Raster& pal_raster)

void Create(int cx, int cy, Raster& pal_raster)

Initializes encoder for output of image of specified size, optionally setting the palette.

 

 

Last edit by cbpporter on 02/06/2010. Do you want to contribute?. T++