Main Page   Class Hierarchy   Alphabetical List   Compound List   Compound Members  

prapi::graphics::MemoryGraphics< T > Class Template Reference

#include <Graphics.h>

Inheritance diagram for prapi::graphics::MemoryGraphics< T >:

prapi::graphics::Graphics< T > Object List of all members.

Detailed Description

template<class T>
class prapi::graphics::MemoryGraphics< T >

An implementation of the Graphics interface that draws on a matrix buffer.


Public Methods

 MemoryGraphics (util::Matrix< T > &buffer)
 Create a new MemoryGraphics object that uses the given matrix as an output buffer.


Protected Methods

getPixel (int x, int y) const
 Get a pixel in a graphics context.

T & pixel (int x, int y)
 Get a pixel in a graphics context.

void setPixel (int x, int y, T value)
 Set a pixel in a graphics context.


Constructor & Destructor Documentation

template<class T>
prapi::graphics::MemoryGraphics< T >::MemoryGraphics util::Matrix< T > &    buffer [inline]
 

Create a new MemoryGraphics object that uses the given matrix as an output buffer.

All drawing methods will modify the pixels in this buffer. Note that the buffer is passed by a reference. You must allocate and keep the storage yourself. A bad example:

 Matrix<int> *mat = new Matrix<int>(100,100);
 MemoryGraphics<int> graphics(*mat);
 delete mat; //OOPS!
 graphics.drawPixel(1,1); //segmentation fault
 

A better one:

 Matrix<int> mat(100,100);
 MemoryGraphics<int> graphics(mat);
 graphics.drawPixel(1,1);
 


Member Function Documentation

template<class T>
T prapi::graphics::MemoryGraphics< T >::getPixel int    x,
int    y
const [inline, protected, virtual]
 

Get a pixel in a graphics context.

Subclasses must implement this method to get the contents of the graphics device/buffer. Boundary checking has been done before calling this method. Thus, assuming _dimBounds has been set correctly, subclasses never need to check whether the given coordinates are within the allowed range.

Implements prapi::graphics::Graphics< T >.

template<class T>
T& prapi::graphics::MemoryGraphics< T >::pixel int    x,
int    y
[inline, protected, virtual]
 

Get a pixel in a graphics context.

Subclasses must implement this method to get the contents of the graphics device/buffer. Boundary checking has been done before calling this method. Thus, assuming _dimBounds has been set correctly, subclasses never need to check whether the given coordinates are within the allowed range.

Implements prapi::graphics::Graphics< T >.

template<class T>
void prapi::graphics::MemoryGraphics< T >::setPixel int    x,
int    y,
  value
[inline, protected, virtual]
 

Set a pixel in a graphics context.

Subclasses must implement this method to alter the graphics device/buffer. Boundary checking has been done before calling this method. Thus, assuming _dimBounds has been set correctly, subclasses never need to check whether the given coordinates are within the allowed range.

Implements prapi::graphics::Graphics< T >.


The documentation for this class was generated from the following file:
Documentation generated on 11.09.2003 with Doxygen.
The documentation is copyrighted material.
Copyright © Topi Mäenpää 2003. All rights reserved.