DUDS
Distributed Update of Data from Something
duds::ui::graphics::BppImage::ConstPixel Class Reference

A forward iterator like class that visits each location of the image or a subset of the image. More...

#include <BppImage.hpp>

Inheritance diagram for duds::ui::graphics::BppImage::ConstPixel:
Collaboration diagram for duds::ui::graphics::BppImage::ConstPixel:

Classes

class  ConstBoolProxy
 Retreives a pixel's state; used to allow ConstPixel to be dereferenced like any other iterator to get a bool for the pixel. More...
 
struct  End
 

Public Types

typedef bool value_type
 

Public Member Functions

constexpr ConstPixel ()
 Construct a ConstPixel to nowhere. More...
 
constexpr ConstPixel (const EndPixel)
 Construct a ConstPixel to nowhere. More...
 
 ConstPixel (const ConstPixel &)=default
 Obvious copy constructor. More...
 
 ConstPixel (const BppImage *img, const End e)
 Construct a ConstPixel to be the end iterator of the given image. More...
 
 ConstPixel (const BppImage *img, const ImageLocation &il=ImageLocation(0, 0), Direction d=HorizInc)
 Construct a ConstPixel to reference the requested location of the image. More...
 
 ConstPixel (const BppImage *img, int x, int y, Direction d=HorizInc)
 Construct a ConstPixel to reference the requested location of the image. More...
 
 ConstPixel (const BppImage *img, const ImageLocation &o, const ImageDimensions &s, const ImageLocation &p=ImageLocation(0, 0), Direction d=HorizInc)
 Construct a ConstPixel to iterate over a subset of the image, and start at a given spot. More...
 
ImageLocation absLocation () const
 Returns the absolute coordinates of the referenced pixel. More...
 
int absX () const
 Returns the absolute horizontal coordinate of the referenced pixel. More...
 
int absY () const
 Returns the absolute vertical coordinate of the referenced pixel. More...
 
const ImageDimensionsdimensions () const
 Returns this object's dimensions used to limit the area of the source image that will be visited. More...
 
void dimensions (const ImageDimensions &d)
 Changes the dimensions of this object. More...
 
Direction direction () const
 Returns the direction used for incrementing. More...
 
void direction (Direction d)
 Changes the direction used for incrementing. More...
 
int height () const
 Returns the height of this object's dimensions used to limit the area of the source image that will be visited. More...
 
const ImageLocationlocation () const
 Returns the coordinates of the referenced pixel relative to this object's origin. More...
 
void location (const ImageLocation &il)
 Changes the location referenced by this ConstPixel relative to its origin. More...
 
void location (int x, int y)
 Changes the location referenced by this ConstPixel relative to its origin. More...
 
bool operator!= (const ConstPixel &cp) const
 Obvious inequality operator. More...
 
bool operator!= (const EndPixel) const
 False if this object is an end iterator or an iterator to nowhere. More...
 
ConstBoolProxy operator* () const
 Dereferences the ConstPixel; provides the state of the pixel. More...
 
ConstPixeloperator++ ()
 Pre-increment operator. More...
 
ConstPixel operator++ (int)
 Post-increment operator. More...
 
ConstPixeloperator= (const ConstPixel &)=default
 Obvious assignment operator. More...
 
ConstPixeloperator= (const Pixel &p)
 Assigns a ConstPixel to reference the same location of the same image as the given Pixel object. More...
 
ConstPixeloperator= (const EndPixel)
 Assigns a ConstPixel to nowhere. More...
 
bool operator== (const ConstPixel &cp) const
 Less than obvious equality operator. More...
 
bool operator== (const EndPixel) const
 True if this object is an end iterator or an iterator to nowhere. More...
 
void origdimloc (const ImageLocation &o, const ImageDimensions &d, const ImageLocation &p)
 Changes the origin, dimensions, and relative position of this object. More...
 
const ImageLocationorigin () const
 Returns this object's origin used to limit the area of the source image that will be visited. More...
 
void origin (const ImageLocation &il)
 Changes the origin of this object. More...
 
int originX () const
 Returns the X coordinate of this object's origin used to limit the area of the source image that will be visited. More...
 
int originY () const
 Returns the Y coordinate of this object's origin used to limit the area of the source image that will be visited. More...
 
bool state () const
 Returns the state of the referenced pixel. More...
 
int width () const
 Returns the width of this object's dimensions used to limit the area of the source image that will be visited. More...
 
int x () const
 Returns the horizontal coordinate of the referenced pixel relative to this object's origin. More...
 
int y () const
 Returns the vertical coordinate of the referenced pixel relative to this object's origin. More...
 

Protected Attributes

PixelBlockblk
 The PixelBlock containing the referenced pixel. More...
 
ImageDimensions dim
 The dimensions of the image to iterate over; can be used to limit the portion visited by the iterator. More...
 
Direction dir
 The direction to move when incremented. More...
 
PixelBlock mask
 The mask used to isolate the referenced pixel. More...
 
ImageLocation orig
 Upper left corner of the image to limit the iteration to a portion of the whole image. More...
 
ImageLocation pos
 The location of the referenced pixel on the source image. More...
 
BppImagesrc
 The image to operate upon. More...
 

Detailed Description

A forward iterator like class that visits each location of the image or a subset of the image.

The iterator becomes invalid whenever one of these actions occur on the source image:

  • The dimensions are changed.
  • It is swapped with another image.
  • It is destructed.

Definition at line 456 of file BppImage.hpp.

Member Typedef Documentation

◆ value_type

Definition at line 815 of file BppImage.hpp.

Constructor & Destructor Documentation

◆ ConstPixel() [1/7]

constexpr duds::ui::graphics::BppImage::ConstPixel::ConstPixel ( )
inline

Construct a ConstPixel to nowhere.

Definition at line 498 of file BppImage.hpp.

Referenced by operator=().

◆ ConstPixel() [2/7]

constexpr duds::ui::graphics::BppImage::ConstPixel::ConstPixel ( const EndPixel  )
inline

Construct a ConstPixel to nowhere.

Definition at line 510 of file BppImage.hpp.

◆ ConstPixel() [3/7]

duds::ui::graphics::BppImage::ConstPixel::ConstPixel ( const ConstPixel )
default

Obvious copy constructor.

◆ ConstPixel() [4/7]

duds::ui::graphics::BppImage::ConstPixel::ConstPixel ( const BppImage img,
const End  e 
)

Construct a ConstPixel to be the end iterator of the given image.

Definition at line 556 of file BppImage.cpp.

◆ ConstPixel() [5/7]

duds::ui::graphics::BppImage::ConstPixel::ConstPixel ( const BppImage img,
const ImageLocation il = ImageLocation(0, 0),
Direction  d = HorizInc 
)

Construct a ConstPixel to reference the requested location of the image.

Exceptions
ImageBoundsError

Definition at line 565 of file BppImage.cpp.

◆ ConstPixel() [6/7]

duds::ui::graphics::BppImage::ConstPixel::ConstPixel ( const BppImage img,
int  x,
int  y,
Direction  d = HorizInc 
)
inline

Construct a ConstPixel to reference the requested location of the image.

Exceptions
ImageBoundsError

Definition at line 534 of file BppImage.hpp.

◆ ConstPixel() [7/7]

duds::ui::graphics::BppImage::ConstPixel::ConstPixel ( const BppImage img,
const ImageLocation o,
const ImageDimensions s,
const ImageLocation p = ImageLocation(0, 0),
Direction  d = HorizInc 
)

Construct a ConstPixel to iterate over a subset of the image, and start at a given spot.

Parameters
imgThe source image to iterate over.
oThe origin (top left); used to limit the iteration to a subset of the image data. The top left location is not modified by the iteration direction d. The area to iterate over must exist within the source image.
sThe size of the image to iterate over. This is used to limit the iteration to a subset of the image data. The axes for width and height are not modified by the iteration direction d. The area to iterate over must exist within the source image.
pThe starting position of the iteration. Its axes are not modified by the iteration direction d. It must specify a position within the dimensions s. It will not change when iteration will end.
dThe direction of the iteration as defined in the enum Direction.
Exceptions
ImageBoundsErrorEither the starting position p is beyond the dimensions s, or the area to iterate over goes beyond the bounds of the source image img.

Definition at line 581 of file BppImage.cpp.

Member Function Documentation

◆ absLocation()

ImageLocation duds::ui::graphics::BppImage::ConstPixel::absLocation ( ) const
inline

Returns the absolute coordinates of the referenced pixel.

Definition at line 700 of file BppImage.hpp.

◆ absX()

int duds::ui::graphics::BppImage::ConstPixel::absX ( ) const
inline

Returns the absolute horizontal coordinate of the referenced pixel.

Definition at line 688 of file BppImage.hpp.

◆ absY()

int duds::ui::graphics::BppImage::ConstPixel::absY ( ) const
inline

Returns the absolute vertical coordinate of the referenced pixel.

Definition at line 694 of file BppImage.hpp.

◆ dimensions() [1/2]

const ImageDimensions& duds::ui::graphics::BppImage::ConstPixel::dimensions ( ) const
inline

Returns this object's dimensions used to limit the area of the source image that will be visited.

Definition at line 749 of file BppImage.hpp.

◆ dimensions() [2/2]

void duds::ui::graphics::BppImage::ConstPixel::dimensions ( const ImageDimensions d)

Changes the dimensions of this object.

The relative position and the origin are not changed. This means the absolute position will also not change. The dimensions must fit within the source image.

Definition at line 715 of file BppImage.cpp.

◆ direction() [1/2]

Direction duds::ui::graphics::BppImage::ConstPixel::direction ( ) const
inline

Returns the direction used for incrementing.

Definition at line 591 of file BppImage.hpp.

◆ direction() [2/2]

void duds::ui::graphics::BppImage::ConstPixel::direction ( Direction  d)
inline

Changes the direction used for incrementing.

Definition at line 597 of file BppImage.hpp.

◆ height()

int duds::ui::graphics::BppImage::ConstPixel::height ( ) const
inline

Returns the height of this object's dimensions used to limit the area of the source image that will be visited.

Definition at line 742 of file BppImage.hpp.

◆ location() [1/3]

const ImageLocation& duds::ui::graphics::BppImage::ConstPixel::location ( ) const
inline

Returns the coordinates of the referenced pixel relative to this object's origin.

Definition at line 668 of file BppImage.hpp.

Referenced by ConstPixel().

◆ location() [2/3]

void duds::ui::graphics::BppImage::ConstPixel::location ( const ImageLocation il)

Changes the location referenced by this ConstPixel relative to its origin.

Exceptions
ImageBoundsError

Definition at line 687 of file BppImage.cpp.

◆ location() [3/3]

void duds::ui::graphics::BppImage::ConstPixel::location ( int  x,
int  y 
)
inline

Changes the location referenced by this ConstPixel relative to its origin.

Exceptions
ImageBoundsError

Definition at line 682 of file BppImage.hpp.

◆ operator!=() [1/2]

bool duds::ui::graphics::BppImage::ConstPixel::operator!= ( const ConstPixel cp) const
inline

Obvious inequality operator.

Definition at line 627 of file BppImage.hpp.

◆ operator!=() [2/2]

bool duds::ui::graphics::BppImage::ConstPixel::operator!= ( const EndPixel  ) const
inline

False if this object is an end iterator or an iterator to nowhere.

Definition at line 633 of file BppImage.hpp.

◆ operator*()

ConstBoolProxy duds::ui::graphics::BppImage::ConstPixel::operator* ( ) const
inline

Dereferences the ConstPixel; provides the state of the pixel.

Definition at line 809 of file BppImage.hpp.

◆ operator++() [1/2]

BppImage::ConstPixel & duds::ui::graphics::BppImage::ConstPixel::operator++ ( )

Pre-increment operator.

Todo:
All direction increments are suboptimal; can be improved.
Todo:
Maybe refactor; split incrmenets into functions to ease implementation of decrement operator. Maybe work this into ImageLocation?

Definition at line 607 of file BppImage.cpp.

◆ operator++() [2/2]

ConstPixel duds::ui::graphics::BppImage::ConstPixel::operator++ ( int  )
inline

Post-increment operator.

This involves the copying the ConstPixel.

Definition at line 643 of file BppImage.hpp.

◆ operator=() [1/3]

ConstPixel& duds::ui::graphics::BppImage::ConstPixel::operator= ( const ConstPixel )
default

Obvious assignment operator.

◆ operator=() [2/3]

BppImage::ConstPixel & duds::ui::graphics::BppImage::ConstPixel::operator= ( const Pixel p)

Assigns a ConstPixel to reference the same location of the same image as the given Pixel object.

Definition at line 601 of file BppImage.cpp.

◆ operator=() [3/3]

ConstPixel& duds::ui::graphics::BppImage::ConstPixel::operator= ( const EndPixel  )
inline

Assigns a ConstPixel to nowhere.

Definition at line 583 of file BppImage.hpp.

◆ operator==() [1/2]

bool duds::ui::graphics::BppImage::ConstPixel::operator== ( const ConstPixel cp) const

Less than obvious equality operator.

If either operand has a source image of nullptr, then they are equal only if both have a position of (-1,-1), Otherwise, all fields must exactly match.

Definition at line 759 of file BppImage.cpp.

◆ operator==() [2/2]

bool duds::ui::graphics::BppImage::ConstPixel::operator== ( const EndPixel  ) const
inline

True if this object is an end iterator or an iterator to nowhere.

Definition at line 621 of file BppImage.hpp.

◆ origdimloc()

void duds::ui::graphics::BppImage::ConstPixel::origdimloc ( const ImageLocation o,
const ImageDimensions d,
const ImageLocation p 
)

Changes the origin, dimensions, and relative position of this object.

This will also change the absolute position. The new image subset must fit within the bounds of the source image.

Parameters
oThe origin (top left); used to limit the iteration to a subset of the image data. The top left location is not modified by the iteration direction. The area to iterate over must exist within the source image.
dThe size of the image to iterate over. This is used to limit the iteration to a subset of the image data. The axes for width and height are not modified by the iteration direction. The area to iterate over must exist within the source image.
pThe current relative position. Its axes are not modified by the iteration direction. It must specify a position within the dimensions d.

Definition at line 730 of file BppImage.cpp.

Referenced by ConstPixel().

◆ origin() [1/2]

const ImageLocation& duds::ui::graphics::BppImage::ConstPixel::origin ( ) const
inline

Returns this object's origin used to limit the area of the source image that will be visited.

Definition at line 721 of file BppImage.hpp.

◆ origin() [2/2]

void duds::ui::graphics::BppImage::ConstPixel::origin ( const ImageLocation il)

Changes the origin of this object.

The relative position and the dimensions are not changed. This means the absolute position will change, and that the dimensions must still fit within the source image.

Definition at line 701 of file BppImage.cpp.

◆ originX()

int duds::ui::graphics::BppImage::ConstPixel::originX ( ) const
inline

Returns the X coordinate of this object's origin used to limit the area of the source image that will be visited.

Definition at line 707 of file BppImage.hpp.

◆ originY()

int duds::ui::graphics::BppImage::ConstPixel::originY ( ) const
inline

Returns the Y coordinate of this object's origin used to limit the area of the source image that will be visited.

Definition at line 714 of file BppImage.hpp.

◆ state()

bool duds::ui::graphics::BppImage::ConstPixel::state ( ) const

Returns the state of the referenced pixel.

Exceptions
ImageIteratorEndError

Definition at line 773 of file BppImage.cpp.

Referenced by duds::ui::graphics::BppImage::ConstPixel::ConstBoolProxy::operator bool().

◆ width()

int duds::ui::graphics::BppImage::ConstPixel::width ( ) const
inline

Returns the width of this object's dimensions used to limit the area of the source image that will be visited.

Definition at line 735 of file BppImage.hpp.

◆ x()

int duds::ui::graphics::BppImage::ConstPixel::x ( ) const
inline

Returns the horizontal coordinate of the referenced pixel relative to this object's origin.

Definition at line 654 of file BppImage.hpp.

Referenced by duds::ui::graphics::BppImage::Pixel::operator=().

◆ y()

int duds::ui::graphics::BppImage::ConstPixel::y ( ) const
inline

Returns the vertical coordinate of the referenced pixel relative to this object's origin.

Definition at line 661 of file BppImage.hpp.

Member Data Documentation

◆ blk

PixelBlock* duds::ui::graphics::BppImage::ConstPixel::blk
protected

The PixelBlock containing the referenced pixel.

Definition at line 471 of file BppImage.hpp.

Referenced by ConstPixel(), location(), operator++(), origdimloc(), origin(), state(), duds::ui::graphics::BppImage::Pixel::state(), and duds::ui::graphics::BppImage::Pixel::toggle().

◆ dim

ImageDimensions duds::ui::graphics::BppImage::ConstPixel::dim
protected

The dimensions of the image to iterate over; can be used to limit the portion visited by the iterator.

Definition at line 489 of file BppImage.hpp.

Referenced by dimensions(), location(), duds::ui::graphics::MaxExtent(), operator++(), operator==(), origdimloc(), and origin().

◆ dir

Direction duds::ui::graphics::BppImage::ConstPixel::dir
protected

The direction to move when incremented.

Definition at line 493 of file BppImage.hpp.

Referenced by operator++().

◆ mask

PixelBlock duds::ui::graphics::BppImage::ConstPixel::mask
protected

The mask used to isolate the referenced pixel.

Definition at line 475 of file BppImage.hpp.

Referenced by ConstPixel(), location(), operator++(), origdimloc(), origin(), state(), duds::ui::graphics::BppImage::Pixel::state(), and duds::ui::graphics::BppImage::Pixel::toggle().

◆ orig

ImageLocation duds::ui::graphics::BppImage::ConstPixel::orig
protected

Upper left corner of the image to limit the iteration to a portion of the whole image.

Definition at line 484 of file BppImage.hpp.

Referenced by location(), operator++(), operator==(), origdimloc(), and origin().

◆ pos

ImageLocation duds::ui::graphics::BppImage::ConstPixel::pos
protected

The location of the referenced pixel on the source image.

Definition at line 479 of file BppImage.hpp.

Referenced by ConstPixel(), dimensions(), location(), operator!=(), operator++(), operator==(), origdimloc(), and origin().

◆ src

BppImage* duds::ui::graphics::BppImage::ConstPixel::src
protected

The image to operate upon.

This is a non-const pointer because this class serves as the base class for Pixel. No functions in this class will ever modify src.

Definition at line 465 of file BppImage.hpp.

Referenced by ConstPixel(), dimensions(), location(), operator!=(), operator++(), operator==(), origdimloc(), and origin().


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