ImgTile Class Reference

This reference page is linked to from the following overview topics: Images.



Detailed Description

Represents a rectangle. Used to specify rectangular regions of an image.

Definition at line 867 of file image.h.

#include <image.h>

Inheritance diagram for ImgTile:
Inheritance graph
[legend]

List of all members.

Public Member Functions

  ImgTile ()
  Create a default empty tile.
  ImgTile (int X, int Y, int NX, int NY)
  Create a tile as specified in the parameters.
  ImgTile (const ImgTile &a, const ImgTile &b)
  Construct a tile by computing the intersection fo the two input tiles.
bool  isEqualTile (const ImgTile &t) const
bool  operator== (const ImgTile &t) const
bool  operator!= (const ImgTile &t) const
bool  isEmpty () const
  return true of this tile is empty
void  setEmpty ()
bool  contains (const ImgTile &a) const
  return true if this tile includes the specified tile
bool  contains (int x_, int y_) const
  return true if this tile includes the specified point
void  clipPositive ()
  Clip the tile so it will not extend into the negative quadrants.
void  ExpandToInclude (int x_, int y_)
  Expand this tile to include the specified point.
void  Expand (int numPixels=1)
  Grow the tile by the specified number of pixels on all 4 sides.
int  numPixels () const
  return the number of pixels contained in this tile

Public Attributes

int  x
  x origin of the tile
int  y
  y origin of the tile
int  nx
  x size of the tile (width)
int  ny
  y size of the tile (height)

Constructor & Destructor Documentation

ImgTile ( ) [inline]

Create a default empty tile.

Definition at line 876 of file image.h.

: x(0), y(0), nx(0), ny(0) {}
ImgTile ( int  X,
int  Y,
int  NX,
int  NY 
) [inline]

Create a tile as specified in the parameters.

Parameters:
X X origin
Y y Origin
NX x Size (width)
NY y Size (height)

Definition at line 885 of file image.h.

: x(X), y(Y), nx(NX), ny(NY) {}
ImgTile ( const ImgTile a,
const ImgTile b 
) [inline]

Construct a tile by computing the intersection fo the two input tiles.

Parameters:
t1 First tile to be intersected
t2 Second tile to be intersected

Definition at line 899 of file image.h.

    {
        x  = MAX(a.x, b.x);
        y  = MAX(a.y, b.y);
        nx = MIN(a.x+a.nx, b.x+b.nx) - x;
        ny = MIN(a.y+a.ny, b.y+b.ny) - y;
        if (nx <= 0 || ny <= 0) x = y = nx = ny = 0;
    }

Member Function Documentation

bool isEqualTile ( const ImgTile t ) const [inline]

Definition at line 908 of file image.h.

    { return x == t.x && y == t.y && nx == t.nx && ny == t.ny; }
bool operator== ( const ImgTile t ) const [inline]

Definition at line 911 of file image.h.

    { return x == t.x && y == t.y && nx == t.nx && ny == t.ny; }
bool operator!= ( const ImgTile t ) const [inline]

Definition at line 914 of file image.h.

    { return !(t == *this); }
bool isEmpty ( ) const [inline]

return true of this tile is empty

Definition at line 918 of file image.h.

{ return nx <= 0 || ny <= 0; }
void setEmpty ( ) [inline]

Definition at line 920 of file image.h.

{ x = y = nx = ny = 0; }
bool contains ( const ImgTile a ) const [inline]

return true if this tile includes the specified tile

Definition at line 923 of file image.h.

    { return x <= a.x && a.x+a.nx <= x+nx &&
             y <= a.y && a.y+a.ny <= y+ny;
    }
bool contains ( int  x_,
int  y_ 
) const [inline]

return true if this tile includes the specified point

Definition at line 929 of file image.h.

    { return x <= x_ && x_ < x+nx && y <= y_ && y_ < y+ny;
    }
void clipPositive ( ) [inline]

Clip the tile so it will not extend into the negative quadrants.

Definition at line 934 of file image.h.

    {
        if (x < 0) {
            nx += x; x = 0;
            if (nx < 0) x = y = nx = ny = 0;
        }
        if (y < 0) {
            ny += y; y = 0;
            if (ny < 0) x = y = nx = ny = 0;
        }
    }
void ExpandToInclude ( int  x_,
int  y_ 
) [inline]

Expand this tile to include the specified point.

Definition at line 947 of file image.h.

    {
        if (isEmpty()) {
            x = x_; y = y_; nx = 1; ny = 1;
        } else {
            if (x_ < x) { nx += (x - x_); x = x_; }
            if (y_ < y) { ny += (y - y_); y = y_; }

            if (x + nx < x_) nx = (x_ - x) + 1;
            if (y + ny < y_) ny = (y_ - y) + 1;
        }
    }
void Expand ( int  numPixels = 1 ) [inline]

Grow the tile by the specified number of pixels on all 4 sides.

Definition at line 961 of file image.h.

    {
        x  -= numPixels; y  -= numPixels;
        numPixels <<= 1;
        nx += numPixels; ny += numPixels;
    }
int numPixels ( ) const [inline]

return the number of pixels contained in this tile

Definition at line 969 of file image.h.

{ return isEmpty() ? 0 : nx * ny; }

Member Data Documentation

int x

x origin of the tile

Definition at line 870 of file image.h.

int y

y origin of the tile

Definition at line 871 of file image.h.

int nx

x size of the tile (width)

Definition at line 872 of file image.h.

int ny

y size of the tile (height)

Definition at line 873 of file image.h.


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

ImgTile ImgTile ImgTile ImgTile ImgTile ImgTile ImgTile ImgTile ImgTile ImgTile
ImgTile ImgTile ImgTile ImgTile ImgTile ImgTile ImgTile ImgTile ImgTile ImgTile