Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

Plot::AARImage Template Class Reference

2D axis-aligned rectangular pixel-based image. More...

#include <image.h>

Inheritance diagram for Plot::AARImage

Inheritance graph

[legend]
List of all members.

Public Types

typedef PixelMatrix::size_type PixelSubscript
 Underlying pixel matrix subscript type; could be unsigned. More...

typedef PixelSubscript size_type
typedef PixelType value_type
typedef double CartesianCoordinate
 Arbitrary floating-point x or y position in the plane occupied by the image. More...


Public Methods

 AARImage (PixelSubscript height=0, PixelSubscript width=0)
 Blank or empty image constructor. More...

void draw_pixel (const PixelSubscript r, const PixelSubscript c, PixelType p)
 Sets the specified pixel to the given color, if in bounds. More...

const PixelType& get_pixel (const PixelSubscript r, const PixelSubscript c) const
 Returns the current value of the specified pixel. More...

PixelSubscript nrows () const
 Returns the number of pixel rows in the image. More...

PixelSubscript ncols () const
 Returns the number of pixel columns in the image. More...

void draw_rectangle (int r1, int c1, int r2, int c2, PixelType p)
 Draws a single-color rectangle bounded by the two specified points. More...

void draw_line (int r1, int c1, int r2, int c2, PixelType p, int thickness=1)
 Draws a single-color line between the two specified points. More...

void draw_bar (CartesianCoordinate cx, CartesianCoordinate cy, double angle, double length, double width=1, PixelType p=default_fg, bool always_draw=true)
 Same as draw_line but specified by the midpoint of the line in Cartesian space rather than endpoints in matrix coordinates. More...

void draw_border (size_type borderwidth=1, PixelType p=default_border)
 Draws a single-color rectangular border around the image. More...

ostream& ppm_write ( ostream& os, const string& comments="", int max_val=255 )
 Writes this image to a ppm file. More...


Static Public Attributes

PixelType default_fg
 Global defaults. More...

PixelType default_bg
PixelType default_border

Protected Methods

PixelSubscript col_from_x (const CartesianCoordinate x)
 Returns the pixel column corresponding to the specified Cartesian coordinate. More...

PixelSubscript row_from_y (const CartesianCoordinate y)
 Returns the pixel row corresponding to the specified Cartesian coordinate. More...

bool inbounds (const PixelSubscript r, const PixelSubscript c) const
 Returns true if the given coordinates are within the image matrix. More...


Friends

template<classPType, classPMatrix> ostream& operator<<<PType, PMatrix> (ostream& s, const AARImage<PType,PMatrix>& o)
 Writes a readable representation to a stream.


Detailed Description

template<class PixelType = RGBPixel<>, class PixelMatrix = MatrixType<PixelType>::rectangular> template class Plot::AARImage

2D axis-aligned rectangular pixel-based image.

In this class and its derived classes, the emphasis is on generality and simplicity of implementation rather than speed. To be suitable for real-time display, some of the routines may need to be rewritten for common special cases such as axis-aligned straight lines, square box outlines, etc.

All integer coordinate pairs in the base class are in the form (row,column), laid out in standard mathematical matrix order with the origin in the upper left, columns increasing to the right, and rows increasing downwards. All floating-point coordinate pairs are in standard mathematical Cartesian space, with the origin at the lower left, x increasing to the right, and y increasing upwards. In Cartesian space, units are centered in between integer locations, so e.g. the lower left unit is centered on location (0.5,0.5).

Definition at line 43 of file image.h.


Member Typedef Documentation

template<classPixelType = RGBPixel<>, classPixelMatrix = MatrixType<PixelType>::rectangular>
typedef double Plot::AARImage<PixelType, PixelMatrix>::CartesianCoordinate
 

Arbitrary floating-point x or y position in the plane occupied by the image.

Definition at line 58 of file image.h.

template<classPixelType = RGBPixel<>, classPixelMatrix = MatrixType<PixelType>::rectangular>
typedef PixelMatrix::size_type Plot::AARImage<PixelType, PixelMatrix>::PixelSubscript
 

Underlying pixel matrix subscript type; could be unsigned.

Definition at line 53 of file image.h.

template<classPixelType = RGBPixel<>, classPixelMatrix = MatrixType<PixelType>::rectangular>
typedef PixelSubscript Plot::AARImage<PixelType, PixelMatrix>::size_type
 

Definition at line 54 of file image.h.

template<classPixelType = RGBPixel<>, classPixelMatrix = MatrixType<PixelType>::rectangular>
typedef PixelType Plot::AARImage<PixelType, PixelMatrix>::value_type
 

Definition at line 55 of file image.h.


Constructor & Destructor Documentation

template<classPixelType = RGBPixel<>, classPixelMatrix = MatrixType<PixelType>::rectangular>
Plot::AARImage<PixelType, PixelMatrix>::AARImage<PixelType, PixelMatrix> ( PixelSubscript height = 0,
PixelSubscript width = 0 )
 

Blank or empty image constructor.

Definition at line 61 of file image.h.


Member Function Documentation

template<classPixelType = RGBPixel<>, classPixelMatrix = MatrixType<PixelType>::rectangular>
PixelSubscript Plot::AARImage<PixelType, PixelMatrix>::col_from_x ( const CartesianCoordinate x ) [inline, protected]
 

Returns the pixel column corresponding to the specified Cartesian coordinate.

Definition at line 106 of file image.h.

template<classPixelType, classPixelMatrix>
void Plot::AARImage< PixelType,PixelMatrix >::draw_bar ( CartesianCoordinate cx,
CartesianCoordinate cy,
double angle,
double length,
double width = 1,
PixelType p = default_fg,
bool always_draw = true )
 

Same as draw_line but specified by the midpoint of the line in Cartesian space rather than endpoints in matrix coordinates.

Takes a center point in Cartesian space, an angle (in radians), and a length. Unlike draw_line, thick lines should approximate a rotated rectangle properly, at least for large enough thicknesses, but they are not implemented very efficiently. The origin is at the at the lower left, with x and y axes increasing to the right and upwards, respectively.

The length is specified between the centers of the two endpoint pixels. As a result, a horizontal or vertical bar of length 0 will consist of one pixel, length 1, 2 pixels, length 5, 6 pixels, etc.

Definition at line 295 of file image.h.

template<classPixelType = RGBPixel<>, classPixelMatrix = MatrixType<PixelType>::rectangular>
void Plot::AARImage<PixelType, PixelMatrix>::draw_border ( size_type borderwidth = 1,
PixelType p = default_border ) [inline]
 

Draws a single-color rectangular border around the image.

Definition at line 87 of file image.h.

template<classPixelType, classPixelMatrix>
void Plot::AARImage< PixelType,PixelMatrix >::draw_line ( int r1,
int c1,
int r2,
int c2,
PixelType p,
int thickness = 1 )
 

Draws a single-color line between the two specified points.

The "thickness" argument is just a hack. For oblique angles, it draws sheared rectangles instead of rotated ones, but that's better than nothing and much simpler than doing scan line conversion.

Definition at line 183 of file image.h.

template<classPixelType = RGBPixel<>, classPixelMatrix = MatrixType<PixelType>::rectangular>
void Plot::AARImage<PixelType, PixelMatrix>::draw_pixel ( const PixelSubscript r,
const PixelSubscript c,
PixelType p ) [inline]
 

Sets the specified pixel to the given color, if in bounds.

Definition at line 65 of file image.h.

template<classPixelType, classPixelMatrix>
void Plot::AARImage< PixelType,PixelMatrix >::draw_rectangle ( int r1,
int c1,
int r2,
int c2,
PixelType p )
 

Draws a single-color rectangle bounded by the two specified points.

The first point is included, and the second is not.

Definition at line 167 of file image.h.

template<classPixelType = RGBPixel<>, classPixelMatrix = MatrixType<PixelType>::rectangular>
const PixelType & Plot::AARImage<PixelType, PixelMatrix>::get_pixel ( const PixelSubscript r,
const PixelSubscript c ) const [inline]
 

Returns the current value of the specified pixel.

Definition at line 71 of file image.h.

template<classPixelType = RGBPixel<>, classPixelMatrix = MatrixType<PixelType>::rectangular>
bool Plot::AARImage<PixelType, PixelMatrix>::inbounds ( const PixelSubscript r,
const PixelSubscript c ) const [inline, protected]
 

Returns true if the given coordinates are within the image matrix.

Definition at line 112 of file image.h.

template<classPixelType = RGBPixel<>, classPixelMatrix = MatrixType<PixelType>::rectangular>
PixelSubscript Plot::AARImage<PixelType, PixelMatrix>::ncols ( ) const [inline]
 

Returns the number of pixel columns in the image.

Definition at line 78 of file image.h.

template<classPixelType = RGBPixel<>, classPixelMatrix = MatrixType<PixelType>::rectangular>
PixelSubscript Plot::AARImage<PixelType, PixelMatrix>::nrows ( ) const [inline]
 

Returns the number of pixel rows in the image.

Definition at line 75 of file image.h.

template<classPixelType, classPixelMatrix>
ostream & Plot::AARImage< PixelType,PixelMatrix >::ppm_write ( ostream & os,
const string & comments = "",
int max_val = 255 )
 

Writes this image to a ppm file.

The given ostream should presumably be fresh, i.e. with nothing yet written, and should be closed afterwards. If 'comments' contains newlines, each should be followed immediately by a '#'.

Definition at line 140 of file image.h.

template<classPixelType = RGBPixel<>, classPixelMatrix = MatrixType<PixelType>::rectangular>
PixelSubscript Plot::AARImage<PixelType, PixelMatrix>::row_from_y ( const CartesianCoordinate y ) [inline, protected]
 

Returns the pixel row corresponding to the specified Cartesian coordinate.

Definition at line 109 of file image.h.


Member Data Documentation

template<classPixelType = RGBPixel<>, classPixelMatrix = MatrixType<PixelType>::rectangular>
PixelType Plot::AARImage<PixelType, PixelMatrix>::default_bg [static]
 

Definition at line 120 of file image.h.

template<classPixelType = RGBPixel<>, classPixelMatrix = MatrixType<PixelType>::rectangular>
PixelType Plot::AARImage<PixelType, PixelMatrix>::default_border [static]
 

Definition at line 121 of file image.h.

template<classPixelType = RGBPixel<>, classPixelMatrix = MatrixType<PixelType>::rectangular>
PixelType Plot::AARImage<PixelType, PixelMatrix>::default_fg [static]
 

Global defaults.

Definition at line 119 of file image.h.


The documentation for this class was generated from the following file:
Generated at Mon Aug 21 00:31:14 2000 for RF-LISSOM by doxygen1.2.1 written by Dimitri van Heesch, © 1997-2000