Namespace List Class Hierarchy Compound List File List Namespace Members Compound Members

# ptc::Surface Class Reference

A linear array of pixels. More...

Class diagram for ptc::Surface:

List of all members.

## Public Members

- Surface (int width,int height,const Format &format)
- ~Surface ()
- virtual void copy (BaseSurface &surface)
- virtual void copy (BaseSurface &surface,const Area &source,const Area &destination)
- virtual void* lock ()
- virtual void unlock ()
- virtual void load (const void *pixels,int width,int height,int pitch,const Format &format,const Palette &palette)
- virtual void load (const void *pixels,int width,int height,int pitch,const Format &format,const Palette &palette,const Area &source,const Area &destination)
- virtual void save (void *pixels,int width,int height,int pitch,const Format &format,const Palette &palette)
- virtual void save (void *pixels,int width,int height,int pitch,const Format &format,const Palette &palette,const Area &source,const Area &destination)
- virtual void clear ()
- virtual void clear (const Color &color)
- virtual void clear (const Color &color,const Area &area)
- virtual void palette (const Palette &palette)
- virtual const Palette& palette () const
- virtual void clip (const Area &area)
- virtual int width () const
- virtual int height () const
- virtual int pitch () const
- virtual const Area& area () const
- virtual const Area& clip () const
- virtual const Format& format () const
- virtual bool option (const char option[])

## Detailed Description

A linear array of pixels.

The surface class represents a linear array of pixels in system memory.

The surface class manages information about the array of pixels, such as its width, height, pitch, pixel format and palette.

It provides routines for loading pixels to the surface, saving surface pixels to another buffer, copying surface pixels to other surfaces and clearing surface pixels to a specified color.

The surface class also manages a clipping rectangle through which all area parameters are first passed to ensure that no load, save, copy or clear operation can write outside of surface memory.

Surface pitch is always equal to width * format.bytes().

This means that surface memory is always linear - the first pixel of line y+1 is immediately after the last pixel of line y in memory for all lines y in the surface.

Be warned, although ptc::Surface guarantees linear memory - ptc::BaseSurface does not!

The documentation of this class only provides an overview for most members, for details see ptc::BaseSurface.

## Member Function Documentation

### ptc::Surface::Surface (int width, int height, const Format & format)

Creates a surface with dimensions of width by height pixels and a pixel format of format.

Parameters:
  width - the width of the surface.
  height - the height of the surface.
  format - the pixel format of the surface.

Exceptions:
  Error - An Error exception is thrown on failure.

### ptc::Surface::~Surface ()

Frees all pixel memory and checks if the surface is still locked.

Exceptions:
  Error - An Error exception is thrown if the surface is still locked.

### virtual void ptc::Surface::copy (BaseSurface & surface)`[virtual]`

Copies the entire contents of this surface to the other surface specified in the surface parameter.

Reimplemented from ptc::BaseSurface.

### virtual void ptc::Surface::copy (BaseSurface & surface, const Area & source, const Area & destination)`[virtual]`

Copies an area of this surface to an area of the other surface specified in the surface parameter.

Reimplemented from ptc::BaseSurface.

### virtual void * ptc::Surface::lock ()`[virtual]`

Locks the surface and returns a pointer to the locked surface pixel memory.

Reimplemented from ptc::BaseSurface.

### virtual void ptc::Surface::unlock ()`[virtual]`

Unlocks the surface pixel memory.

Reimplemented from ptc::BaseSurface.

### virtual void ptc::Surface::load (const void * pixels, int width, int height, int pitch, const Format & format, const Palette & palette)`[virtual]`

Loads pixels from the pixel array pixels to the surface.

Reimplemented from ptc::BaseSurface.

### virtual void ptc::Surface::load (const void * pixels, int width, int height, int pitch, const Format & format, const Palette & palette, const Area & source, const Area & destination)`[virtual]`

Loads an area of pixels from the pixel array pixels to an area of the surface.

Reimplemented from ptc::BaseSurface.

### virtual void ptc::Surface::save (void * pixels, int width, int height, int pitch, const Format & format, const Palette & palette)`[virtual]`

Saves the surface pixels to the pixel array pixels.

Reimplemented from ptc::BaseSurface.

### virtual void ptc::Surface::save (void * pixels, int width, int height, int pitch, const Format & format, const Palette & palette, const Area & source, const Area & destination)`[virtual]`

Saves an area of the surface pixels to an area of the pixel data array pixels.

Reimplemented from ptc::BaseSurface.

### virtual void ptc::Surface::clear ()`[virtual]`

Clears the entire contents of the surface to black in direct color and index zero in indexed color.

Reimplemented from ptc::BaseSurface.

### virtual void ptc::Surface::clear (const Color & color)`[virtual]`

Clears the entire contents of the surface to the color specified in the color parameter.

Reimplemented from ptc::BaseSurface.

### virtual void ptc::Surface::clear (const Color & color, const Area & area)`[virtual]`

Clears the area of pixels of the surface specified by the area parameter to the color specified in the color parameter.

Reimplemented from ptc::BaseSurface.

### virtual void ptc::Surface::palette (const Palette & palette)`[virtual]`

Sets the surface palette to the palette specified in the palette parameter.

Reimplemented from ptc::BaseSurface.

### virtual const Palette & ptc::Surface::palette () const`[virtual]`

Gets the surface palette object.

Reimplemented from ptc::BaseSurface.

### virtual void ptc::Surface::clip (const Area & area)`[virtual]`

Sets the surface clip area to the area specified by the area parameter.

Reimplemented from ptc::BaseSurface.

### virtual int ptc::Surface::width () const`[virtual]`

Gets the width of the surface in pixels.

Reimplemented from ptc::BaseSurface.

### virtual int ptc::Surface::height () const`[virtual]`

Gets the height of the surface in pixels.

Reimplemented from ptc::BaseSurface.

### virtual int ptc::Surface::pitch () const`[virtual]`

Gets the pitch of the surface in bytes.

Reimplemented from ptc::BaseSurface.

### virtual const Area & ptc::Surface::area () const`[virtual]`

Gets the area of the surface.

Reimplemented from ptc::BaseSurface.

### virtual const Area & ptc::Surface::clip () const`[virtual]`

Gets the clip area of the surface.

Reimplemented from ptc::BaseSurface.

### virtual const Format & ptc::Surface::format () const`[virtual]`

Gets the pixel format of the surface.

Reimplemented from ptc::BaseSurface.

### virtual bool ptc::Surface::option (const char option[])`[virtual]`

Passes an implementation specific option string to the surface.

Reimplemented from ptc::BaseSurface.

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

- ptc.h