The ZX Ecosystem v5.1.0;_GUI_v3.1.0
Loading...
Searching...
No Matches
Modules | Namespaces | Classes | Functions
Support for graphics in the ZX

Description

These classes provide support for managing graphics.

NOTE:

-These classes are not thread-safe.

http://jafma.net

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Collaboration diagram for Support for graphics in the ZX:

Modules

 Coordinate systems for the screen
 

Namespaces

namespace  zxeco
 The main namespace of the library, that spans across all the zx modules.
 

Classes

struct  zxeco::CoordT
 Base class for all coordinate trait classes. More...
 
struct  zxeco::DistT
 Base class for all distance trait classes. More...
 
struct  zxeco::CharCoordT
 A class that makes CharCoord a different, distinguishable type from others. More...
 
struct  zxeco::PixelCoordT
 A class that makes PixelCoord a different, distinguishable type from others. More...
 
struct  zxeco::CharDistT
 A class that makes CharDist a different, distinguishable type from others. More...
 
struct  zxeco::PixelDistT
 A class that makes PixelDist a different, distinguishable type from others. More...
 
struct  zxeco::IntDistT
 A class that makes IntDist a different, distinguishable type from others. More...
 
struct  zxeco::BorderCoordT
 A class that makes BorderCoord a different, distinguishable type from others. More...
 
struct  zxeco::BorderDistT
 A class that makes BorderDist a different, distinguishable type from others. More...
 
class  zxeco::Cursor< WRES, HRES >
 A cursor on screen that uses the given coordinates resolution. More...
 
class  zxeco::Area< WRES, HRES >
 An area on the screen that uses the given distance resolutions. More...
 
struct  zxeco::Rect< WRES, HRES >
 A rectangle placed on the screen that uses the given resolutions. More...
 
class  zxeco::DoubleArea
 An area with both char and pixel resolutions, possibly synchronized. More...
 
class  zxeco::DoubleRect
 A rectangle with both char and pixel resolutions, possibly synchronized. More...
 
class  zxeco::LinearGraphic
 A rectangular graphic block. More...
 
class  zxeco::DimsGraphic< HEIGHTRESOL >
 A graphic that has certain 2D dimensions and coordinates. More...
 
class  zxeco::Bitmap
 A graphic that contains a bitmap, i.e., it has pixel resolution in height. More...
 
class  zxeco::Attrmap
 A graphic that contains an attrmap, i.e., it has char resolution in height. More...
 
class  zxeco::DoubleGraphic
 A bitmap plus an attrmap, possibly synchronized. More...
 
struct  zxeco::DoubleGraphic::PNGConversionParms
 Parameters for the conversion of PNG images into DoubleGraphic. More...
 
class  zxeco::DoubleGraphic::DitheringSystem::Color
 

Functions

template<>
constexpr uint8_t zxeco::LinearGraphic::doGraphOp< LinearGraphic::GraphOp::COPY > (uint8_t b0, uint8_t b1) noexcept
 

Class Documentation

◆ zxeco::CoordT

struct zxeco::CoordT

Base class for all coordinate trait classes.

This serves to refer to any coordinate class. If the compiler implements empty base class optimization, its size will not be embedded in the size of derived classes.

Definition at line 254 of file ZXGraphics.h.

Inheritance diagram for zxeco::CoordT:

◆ zxeco::DistT

struct zxeco::DistT

Base class for all distance trait classes.

This serves to refer to any distance class. If the compiler implements empty base class optimization, its size will not be embedded in the size of derived classes.

Definition at line 262 of file ZXGraphics.h.

Inheritance diagram for zxeco::DistT:

◆ zxeco::CharCoordT

struct zxeco::CharCoordT

A class that makes CharCoord a different, distinguishable type from others.

Definition at line 267 of file ZXGraphics.h.

Inheritance diagram for zxeco::CharCoordT:
Collaboration diagram for zxeco::CharCoordT:

Public Types

using type = CharCoord
 Numerical type corresponding to this class. More...
 

Static Public Attributes

static constexpr const char * name = "CharC"
 Name of numeric type. More...
 

Public Attributes

type value
 To hold values of that type. More...
 

◆ zxeco::PixelCoordT

struct zxeco::PixelCoordT

A class that makes PixelCoord a different, distinguishable type from others.

Definition at line 277 of file ZXGraphics.h.

Inheritance diagram for zxeco::PixelCoordT:
Collaboration diagram for zxeco::PixelCoordT:

Public Types

using type = PixelCoord
 Numerical type corresponding to this class. More...
 

Static Public Attributes

static constexpr const char * name = "PixC"
 Name of numeric type. More...
 

Public Attributes

type value
 To hold values of that type. More...
 

◆ zxeco::CharDistT

struct zxeco::CharDistT

A class that makes CharDist a different, distinguishable type from others.

Definition at line 287 of file ZXGraphics.h.

Inheritance diagram for zxeco::CharDistT:
Collaboration diagram for zxeco::CharDistT:

Public Types

using type = CharDist
 Numerical type corresponding to this class. More...
 
using coord_typeT = CharCoordT
 Corresponding coord type trait. More...
 

Static Public Attributes

static constexpr const char * name = "CharD"
 Name of numeric type. More...
 

Public Attributes

type value
 To hold values of that type. More...
 

◆ zxeco::PixelDistT

struct zxeco::PixelDistT

A class that makes PixelDist a different, distinguishable type from others.

Definition at line 299 of file ZXGraphics.h.

Inheritance diagram for zxeco::PixelDistT:
Collaboration diagram for zxeco::PixelDistT:

Public Types

using type = PixelDist
 Numerical type corresponding to this class. More...
 
using coord_typeT = PixelCoordT
 Corresponding coord type trait. More...
 

Static Public Attributes

static constexpr const char * name = "PixD"
 Name of numeric type. More...
 

Public Attributes

type value
 To hold values of that type. More...
 

◆ zxeco::IntDistT

struct zxeco::IntDistT

A class that makes IntDist a different, distinguishable type from others.

This class does not follow the same hierarchy as the previous ones.

Definition at line 312 of file ZXGraphics.h.

Public Types

using type = IntDist
 Numerical type corresponding to this class. More...
 

Static Public Attributes

static constexpr const char * name = "IntD"
 Name of numeric type. More...
 

Public Attributes

type value
 To hold values of that type. More...
 

◆ zxeco::BorderCoordT

struct zxeco::BorderCoordT

A class that makes BorderCoord a different, distinguishable type from others.

Definition at line 322 of file ZXGraphics.h.

Inheritance diagram for zxeco::BorderCoordT:
Collaboration diagram for zxeco::BorderCoordT:

Public Types

using type = BorderCoord
 Numerical type corresponding to this class. More...
 

Static Public Attributes

static constexpr const char * name = "BorderC"
 Name of numeric type. More...
 

Public Attributes

type value
 To hold values of that type. More...
 

◆ zxeco::BorderDistT

struct zxeco::BorderDistT

A class that makes BorderDist a different, distinguishable type from others.

Definition at line 332 of file ZXGraphics.h.

Inheritance diagram for zxeco::BorderDistT:
Collaboration diagram for zxeco::BorderDistT:

Public Types

using type = BorderDist
 Numerical type corresponding to this class. More...
 
using coord_typeT = BorderCoordT
 Corresponding coord type trait. More...
 

Static Public Attributes

static constexpr const char * name = "BorderD"
 Name of numeric type. More...
 

Public Attributes

type value
 To hold values of that type. More...
 

◆ zxeco::Cursor

class zxeco::Cursor
template<typename WRES, typename HRES>
class zxeco::Cursor< WRES, HRES >

A cursor on screen that uses the given coordinates resolution.

Coordinates are 0,0 at the top-left of the possible area for the cursor, and they increase rightwards and downwards.

Definition at line 358 of file ZXGraphics.h.

Public Types

using WidthType = WRES
 Type used for the width dimension. More...
 
using HeightType = HRES
 Type used for the height dimension. More...
 

Static Public Member Functions

static const CursortheZero (void) noexcept
 < Return a reference to an inmutable zero cursorof this type. More...
 
static Cursor max (const Cursor &c0, const Cursor &c1) noexcept
 < Return a copy of the one of C0, C1 that is more to the right and below. More...
 

Public Attributes

WidthType::type x
 Coordinate in width (horizontally). More...
 
HeightType::type y
 Coordinates in height (vertically). More...
 

Public Member Functions

 Cursor (typename WidthType::type xc, typename HeightType::type yc)
 Constructor, from the numerical coord types. More...
 
 Cursor (WidthType xc, HeightType yc)
 Constructor from the trait coord types. More...
 
void newRow (void) noexcept
 Go down one row resetting x (y <- y + 1 & x <- 0). More...
 
void newCol (void) noexcept
 Go right one column (x <- x + 1). More...
 
void incRow (void) noexcept
 Go down one row without resetting x. More...
 
bool zero (void) const noexcept
 Return TRUE if the cursor is placed at (0,0). *‍/. More...
 
bool before (const Cursor &oth) const noexcept
 < Return TRUE if THIS is placed before OTH in the plane (linearly). More...
 
bool rightBelow (const Cursor &oth) const noexcept
 < Return TRUE if THIS is placed to the right and below of OTH. More...
 
IntDist xDiff (const Cursor &oth) const noexcept
 < Return the signed distance in X from OTH to THIS. More...
 
IntDist yDiff (const Cursor &oth) const noexcept
 < Return the signed distance in Y from OTH to THIS. More...
 
void addDiff (IntDist xdiff, IntDist ydiff) noexcept
 < Add the given signed distances to both coordinates. More...
 
bool operator== (const Cursor &oth) const noexcept
 < Return TRUE if both cursors are placed at the same place. More...
 
bool operator!= (const Cursor &oth) const noexcept
 < Unequality. More...
 
Cursor operator+ (const Cursor &oth) const
 < Return the sum of both cursors. More...
 
Cursoroperator+= (const Cursor &oth)
 Make the sum and return the result. More...
 
Cursor operator- (const Cursor &oth) const
 < Return the cursor THIS relative to OTH, or throw if result is negative. More...
 
Cursoroperator-= (const Cursor &oth)
 Make the substraction and return the result. More...
 
std::string to_string (bool withtype=true) const
 < Return a string with the textual information of the area. More...
 

◆ zxeco::Area

class zxeco::Area
template<typename WRES, typename HRES>
class zxeco::Area< WRES, HRES >

An area on the screen that uses the given distance resolutions.

Definition at line 503 of file ZXGraphics.h.

Public Types

using WidthType = WRES
 Type used for the width dimension. More...
 
using HeightType = HRES
 Type used for the height dimension. More...
 
using CursorType = Cursor< typename WRES::coord_typeT, typename HRES::coord_typeT >
 Cursor. More...
 

Static Public Member Functions

static const AreatheEmpty (void) noexcept
 Return a reference to an inmutable empty area of this type. More...
 

Public Attributes

WidthType::type width
 width of the area. More...
 
HeightType::type height
 height of the area. More...
 

Public Member Functions

 Area (typename WidthType::type w, typename HeightType::type h)
 Default constructor, from the numerical dist types. More...
 
 Area (WidthType w, HeightType h)
 Constructor from the trait dist types. More...
 
 Area (const CursorType &c0, const CursorType &c1)
 Constructor of the area within C0 (top-left) and C1 (bottom-right). More...
 
bool empty (void) const noexcept
 Return TRUE if the area is empty. More...
 
size_t area (void) const noexcept
 < Return the number of cells in the area. More...
 
bool containedInto (const Area &oth) const noexcept
 < Return TRUE if this area can be contained into OTH or if they are equal More...
 
Area operator+ (const Area &oth) const noexcept
 < Add width and height of OTH to THIS. More...
 
Areaoperator+= (const Area &oth) noexcept
 < Add to THIS the width and height of OTH. More...
 
Area operator- (const Area &oth) const
 < Substract OTH dimensions from THIS dims and return the result, or throw More...
 
Areaoperator-= (const Area &oth)
 Substract OTH from THIS and return THIS. Throw if error. More...
 
Area operator* (const Area &oth) const
 < Intersect OTH dimensions to THIS dims and return the result. More...
 
Areaoperator*= (const Area &oth)
 Intersect OTH to THIS and return THIS. More...
 
bool operator== (const Area &oth) const noexcept
 < Equality. More...
 
bool operator!= (const Area &oth) const noexcept
 < Unequality. More...
 
std::string to_string (bool withtype=true) const
 < Return a string with the textual information of the area. More...
 

◆ zxeco::Rect

struct zxeco::Rect
template<typename WRES, typename HRES>
struct zxeco::Rect< WRES, HRES >

A rectangle placed on the screen that uses the given resolutions.

The corresponding coord resolutions are deduced from the given dist resolutions.

Definition at line 643 of file ZXGraphics.h.

Collaboration diagram for zxeco::Rect< WRES, HRES >:

Public Types

using cursor_type = Cursor< typename WRES::coord_typeT, typename HRES::coord_typeT >
 
using area_type = Area< WRES, HRES >
 

Static Public Member Functions

static const RecttheEmpty (void) noexcept
 Return a reference to an inmutable empty rectangle of this type. More...
 

Public Attributes

cursor_type corner
 Top-left corner. More...
 
area_type area
 Width and height. More...
 

Public Member Functions

 Rect (const cursor_type &c=cursor_type{0, 0}, const area_type &a=area_type{0, 0})
 Default constructor: empty rectangle. More...
 
bool empty (void) const noexcept
 Return TRUE if the rectangle area is empty. More...
 
bool contains (const cursor_type &cur) const noexcept
 Return TRUE if CUR is inside the rectangle. More...
 
cursor_type bottomRight (void) const noexcept
 < Return the coordinates of the bottom-right extreme within the rectangle More...
 
bool applyConstrainedDiffs (IntDist &xdiff, IntDist &ydiff, const Rect &oth) noexcept
 Apply the given increments to the corner of THIS, keeping it within OTH. More...
 
Rect compose (const Rect &reloth) const
 < Return the RELOTH region of THIS as a rectangle. More...
 
Rect subRect (const cursor_type &reltopleft) const
 < Return the absolute sub-rectangle that starts at RELTOPLEFT within this More...
 
Rect intersect (const Rect &oth) const noexcept
 Return the rectangle resulting from the intersection of this and OTH. More...
 
Rect align_area (const area_type &areaneeded, char horalign, char vertalign) const
 Return the portion of this rectangle that contains AREANEEDED aligned. More...
 
bool operator== (const Rect &oth) const noexcept
 < Equality. More...
 
bool operator!= (const Rect &oth) const noexcept
 < Unequality. More...
 
std::string to_string (bool withtype=true) const
 < Return a string with the textual information of the rectangle. More...
 

◆ zxeco::DoubleArea

class zxeco::DoubleArea

An area with both char and pixel resolutions, possibly synchronized.

Definition at line 768 of file ZXGraphics.h.

Collaboration diagram for zxeco::DoubleArea:

Public Attributes

CharArea chararea
 Char resolution. More...
 
PixArea pixarea
 Pixel resolution. More...
 

Public Member Functions

std::string to_string (void) const
 
 DoubleArea (const CharArea &area=CharArea::theEmpty())
 
 DoubleArea (const CharArea &carea, const PixArea &parea)
 

◆ zxeco::DoubleRect

class zxeco::DoubleRect

A rectangle with both char and pixel resolutions, possibly synchronized.

Definition at line 798 of file ZXGraphics.h.

Collaboration diagram for zxeco::DoubleRect:

Public Attributes

CharRect charrect
 Char resolution. More...
 
PixRect pixrect
 Pixel resolution. More...
 

Public Member Functions

std::string to_string (void) const
 
 DoubleRect (const CharRect &rect=CharRect::theEmpty())
 
 DoubleRect (const CharRect &crect, const PixRect &prect)
 

◆ zxeco::LinearGraphic

class zxeco::LinearGraphic

A rectangular graphic block.

Definition at line 833 of file ZXGraphics.h.

Inheritance diagram for zxeco::LinearGraphic:
Collaboration diagram for zxeco::LinearGraphic:

Public Types

enum class  GraphOp : unsigned char {
  GraphOp::COPY , GraphOp::INV , GraphOp::OR , GraphOp::INVOR ,
  GraphOp::AND , GraphOp::INVAND , GraphOp::XOR , GraphOp::INVXOR
}
 Possible operations on Graphics. More...
 

Static Public Member Functions

template<LinearGraphic::GraphOp op>
static constexpr uint8_t doGraphOp (uint8_t b0, uint8_t b1) noexcept
 Return the result of doing operation OP on byte B0 with byte B1.
 

Public Member Functions

 LinearGraphic (void)
 Default constructor: empty graphic.
 
 LinearGraphic (size_t s)
 Construct an empty graphic of the given size, yet to be filled. More...
 
 LinearGraphic (size_t s, uint8_t b)
 Construct a graphic of the given size filled with 1 byte (B).
 
 LinearGraphic (uint8_t *bs, size_t s)
 Construct a graphic that is held externally (NO OWNERSHIP to this). More...
 
 LinearGraphic (LinearGraphic &oth, size_t firstoff, size_t chunksize, size_t gap, size_t numchunks)
 Construct a graphic referring to part of another one (no ownership). More...
 
 LinearGraphic (const LinearGraphic &)=delete
 
LinearGraphicoperator= (const LinearGraphic &)=delete
 
 LinearGraphic (LinearGraphic &&og)
 
LinearGraphicoperator= (LinearGraphic &&og)
 
bool external (void) const noexcept
 Whether the object refers to part of another linear graphic. More...
 
bool owner (void) const noexcept
 Whether the object owns the graphical data. More...
 
size_t size (void) const noexcept
 Size in memory, in bytes. More...
 
bool oneByte (void) const noexcept
 Return TRUE if the graphic content is compressed into one byte. More...
 
uint8_t getByte (size_t offset) const
 Get the byte at the given offset, throwing if it is out of range.
 
uint8_t getByteUnsafe (size_t offset) const noexcept
 Get the byte at the given offset without checking out of range.
 
uint8_t * getAllBytes (void)
 Return a pointer to the data or throw if it is onebyte or external.
 
void setByte (size_t offset, uint8_t b)
 Change the byte at the given offset inside the data. More...
 
void setByteUnsafe (size_t offset, uint8_t b) noexcept
 Change the byte at the given offset without checking anything. More...
 
void setAllBytes (uint8_t b) noexcept
 Set all bytes of the graphic to the given value. More...
 
void merge (size_t destoffset, const LinearGraphic &oth, size_t origoffset, size_t howmany, GraphOp op=GraphOp::COPY)
 Merge HOWMANY bytes from OTH (at ORIGOFFSET) into this (at DESTOFFSET). More...
 
void mergeUnsafe (size_t destoffset, const LinearGraphic &oth, size_t origoffset, size_t howmany, GraphOp op=GraphOp::COPY)
 Merge HOWMANY bytes from OTH (at ORIGOFFSET) into this (at DESTOFFSET). More...
 
int compare (const LinearGraphic &oth, bool withinv=false) const noexcept
 Compare this graphic to OTH and return 1 if both are equal. More...
 
size_t similarity (const LinearGraphic &oth) const noexcept
 Return a measure of the bitmap similarity (bit by bit) between both. More...
 
std::string to_string (void) const
 Return a text with the info of the graphic.
 

Protected Member Functions

void clear (void)
 
void reset (void)
 
void moveFrom (LinearGraphic &&og)
 

Protected Attributes

bool owner_
 
size_t s_
 

◆ zxeco::DimsGraphic

class zxeco::DimsGraphic
template<typename HEIGHTRESOL>
class zxeco::DimsGraphic< HEIGHTRESOL >

A graphic that has certain 2D dimensions and coordinates.

The width coordinate is restricted to CharCoordT.

Definition at line 1008 of file ZXGraphics.h.

Inheritance diagram for zxeco::DimsGraphic< HEIGHTRESOL >:
Collaboration diagram for zxeco::DimsGraphic< HEIGHTRESOL >:

Public Types

using CursorType = Cursor< CharCoordT, typename HEIGHTRESOL::coord_typeT >
 
using AreaType = Area< CharDistT, HEIGHTRESOL >
 
using RectType = Rect< CharDistT, HEIGHTRESOL >
 
- Public Types inherited from zxeco::LinearGraphic
enum class  GraphOp : unsigned char {
  GraphOp::COPY , GraphOp::INV , GraphOp::OR , GraphOp::INVOR ,
  GraphOp::AND , GraphOp::INVAND , GraphOp::XOR , GraphOp::INVXOR
}
 Possible operations on Graphics. More...
 

Public Attributes

AreaType dims
 Dimensions of the graphic. More...
 

Public Member Functions

 DimsGraphic (void)
 Default constructor: empty graphic. More...
 
 DimsGraphic (const AreaType &a)
 Construct an undefined graphic of the given dimensions, to be filled. More...
 
 DimsGraphic (const AreaType &a, uint8_t b)
 Construct a graphic of the given dimensions filled with one byte (B). More...
 
 DimsGraphic (uint8_t *bs, const AreaType &a)
 Construct a graphic that is held externally (NO OWNERSHIP to this). More...
 
 DimsGraphic (DimsGraphic &g, const RectType &region, bool copy=true)
 Construct a graphic that refers to a region within another one. More...
 
 DimsGraphic (DimsGraphic &&oth)
 Move constructor. More...
 
DimsGraphicoperator= (DimsGraphic &&oth)
 Move assignment. More...
 
size_t offset (const CursorType &pos) const
 Get the offset corresponding to the given coordinates in the graphic. More...
 
CursorType coords (size_t offset) const
 Get the coordinates of the given offset, if it is valid, or throws. More...
 
uint8_t getByte (const CursorType &pos) const
 < Unhide the linear getByte() method hidden by the new getByte(). More...
 
void setByte (const CursorType &pos, uint8_t b)
 < Unhide the linear setByte() method hidden by the new setByte(). More...
 
void merge (const DimsGraphic &oth, const CursorType &pos, GraphOp mode=GraphOp::COPY)
 Merge OTH at the given coordinates of this object with the given mode. More...
 
HEIGHTRESOL::type scrollUp (typename HEIGHTRESOL::type howmany, typename HEIGHTRESOL::type upperrow, uint8_t fillb)
 Scroll HOWMANY rows of the graphic up, beginning at y-coord UPPERROW. More...
 
std::string to_string (void) const
 Return a text with the info of the graphic. More...
 
uint8_t getByte (size_t offset) const
 Get the byte at the given offset, throwing if it is out of range.
 
void setByte (size_t offset, uint8_t b)
 Change the byte at the given offset inside the data. More...
 
- Public Member Functions inherited from zxeco::LinearGraphic
 LinearGraphic (void)
 Default constructor: empty graphic.
 
 LinearGraphic (size_t s)
 Construct an empty graphic of the given size, yet to be filled. More...
 
 LinearGraphic (size_t s, uint8_t b)
 Construct a graphic of the given size filled with 1 byte (B).
 
 LinearGraphic (uint8_t *bs, size_t s)
 Construct a graphic that is held externally (NO OWNERSHIP to this). More...
 
 LinearGraphic (LinearGraphic &oth, size_t firstoff, size_t chunksize, size_t gap, size_t numchunks)
 Construct a graphic referring to part of another one (no ownership). More...
 
 LinearGraphic (const LinearGraphic &)=delete
 
LinearGraphicoperator= (const LinearGraphic &)=delete
 
 LinearGraphic (LinearGraphic &&og)
 
LinearGraphicoperator= (LinearGraphic &&og)
 
bool external (void) const noexcept
 Whether the object refers to part of another linear graphic. More...
 
bool owner (void) const noexcept
 Whether the object owns the graphical data. More...
 
size_t size (void) const noexcept
 Size in memory, in bytes. More...
 
bool oneByte (void) const noexcept
 Return TRUE if the graphic content is compressed into one byte. More...
 
uint8_t getByte (size_t offset) const
 Get the byte at the given offset, throwing if it is out of range.
 
uint8_t getByteUnsafe (size_t offset) const noexcept
 Get the byte at the given offset without checking out of range.
 
uint8_t * getAllBytes (void)
 Return a pointer to the data or throw if it is onebyte or external.
 
void setByte (size_t offset, uint8_t b)
 Change the byte at the given offset inside the data. More...
 
void setByteUnsafe (size_t offset, uint8_t b) noexcept
 Change the byte at the given offset without checking anything. More...
 
void setAllBytes (uint8_t b) noexcept
 Set all bytes of the graphic to the given value. More...
 
void merge (size_t destoffset, const LinearGraphic &oth, size_t origoffset, size_t howmany, GraphOp op=GraphOp::COPY)
 Merge HOWMANY bytes from OTH (at ORIGOFFSET) into this (at DESTOFFSET). More...
 
void mergeUnsafe (size_t destoffset, const LinearGraphic &oth, size_t origoffset, size_t howmany, GraphOp op=GraphOp::COPY)
 Merge HOWMANY bytes from OTH (at ORIGOFFSET) into this (at DESTOFFSET). More...
 
int compare (const LinearGraphic &oth, bool withinv=false) const noexcept
 Compare this graphic to OTH and return 1 if both are equal. More...
 
size_t similarity (const LinearGraphic &oth) const noexcept
 Return a measure of the bitmap similarity (bit by bit) between both. More...
 
std::string to_string (void) const
 Return a text with the info of the graphic.
 

Additional Inherited Members

- Static Public Member Functions inherited from zxeco::LinearGraphic
template<LinearGraphic::GraphOp op>
static constexpr uint8_t doGraphOp (uint8_t b0, uint8_t b1) noexcept
 Return the result of doing operation OP on byte B0 with byte B1.
 
- Protected Member Functions inherited from zxeco::LinearGraphic
void clear (void)
 
void reset (void)
 
void moveFrom (LinearGraphic &&og)
 
- Protected Attributes inherited from zxeco::LinearGraphic
bool owner_
 
size_t s_
 

Member Function Documentation

◆ setByte()

template<typename HEIGHTRESOL >
void zxeco::LinearGraphic::setByte ( size_t  offset,
uint8_t  b 
)

Change the byte at the given offset inside the data.

If the graphic is onebyte or the offset is invalid, throw an exception.

◆ zxeco::Bitmap

class zxeco::Bitmap

A graphic that contains a bitmap, i.e., it has pixel resolution in height.

Definition at line 1150 of file ZXGraphics.h.

Inheritance diagram for zxeco::Bitmap:
Collaboration diagram for zxeco::Bitmap:

Public Types

using BaseGr = DimsGraphic< PixelDistT >
 
- Public Types inherited from zxeco::DimsGraphic< PixelDistT >
using CursorType = Cursor< CharCoordT, typename HEIGHTRESOL::coord_typeT >
 
using AreaType = Area< CharDistT, PixelDistT >
 
using RectType = Rect< CharDistT, PixelDistT >
 
- Public Types inherited from zxeco::LinearGraphic
enum class  GraphOp : unsigned char {
  GraphOp::COPY , GraphOp::INV , GraphOp::OR , GraphOp::INVOR ,
  GraphOp::AND , GraphOp::INVAND , GraphOp::XOR , GraphOp::INVXOR
}
 Possible operations on Graphics. More...
 

Public Member Functions

 Bitmap (DesktopInterface &desktop, const std::string &pngfile)
 < Reuse all constructor from Gr<PixelDistT>. More...
 
 Bitmap (uint8_t ascii, uint8_t *chartable=nullptr)
 Construct a bitmap for a ZX ascii char (including block-graphic ones).
 
void merge (const Bitmap &oth, const PixCursor &pos, GraphOp mode=GraphOp::COPY)
 < Unhide the base merge() method hidden by the new merge(). More...
 
std::string to_string (void) const
 Return a text with the info of the graphic. More...
 
- Public Member Functions inherited from zxeco::DimsGraphic< PixelDistT >
 DimsGraphic (void)
 Default constructor: empty graphic. More...
 
 DimsGraphic (const AreaType &a)
 Construct an undefined graphic of the given dimensions, to be filled. More...
 
 DimsGraphic (const AreaType &a, uint8_t b)
 Construct a graphic of the given dimensions filled with one byte (B). More...
 
 DimsGraphic (uint8_t *bs, const AreaType &a)
 Construct a graphic that is held externally (NO OWNERSHIP to this). More...
 
 DimsGraphic (DimsGraphic &g, const RectType &region, bool copy=true)
 Construct a graphic that refers to a region within another one. More...
 
 DimsGraphic (DimsGraphic &&oth)
 Move constructor. More...
 
DimsGraphicoperator= (DimsGraphic &&oth)
 Move assignment. More...
 
size_t offset (const CursorType &pos) const
 Get the offset corresponding to the given coordinates in the graphic. More...
 
CursorType coords (size_t offset) const
 Get the coordinates of the given offset, if it is valid, or throws. More...
 
uint8_t getByte (const CursorType &pos) const
 < Unhide the linear getByte() method hidden by the new getByte(). More...
 
uint8_t getByte (size_t offset) const
 Get the byte at the given offset, throwing if it is out of range.
 
void setByte (const CursorType &pos, uint8_t b)
 < Unhide the linear setByte() method hidden by the new setByte(). More...
 
void setByte (size_t offset, uint8_t b)
 Change the byte at the given offset inside the data. More...
 
void merge (const DimsGraphic &oth, const CursorType &pos, GraphOp mode=GraphOp::COPY)
 Merge OTH at the given coordinates of this object with the given mode. More...
 
HEIGHTRESOL::type scrollUp (typename HEIGHTRESOL::type howmany, typename HEIGHTRESOL::type upperrow, uint8_t fillb)
 Scroll HOWMANY rows of the graphic up, beginning at y-coord UPPERROW. More...
 
std::string to_string (void) const
 Return a text with the info of the graphic. More...
 
- Public Member Functions inherited from zxeco::LinearGraphic
 LinearGraphic (void)
 Default constructor: empty graphic.
 
 LinearGraphic (size_t s)
 Construct an empty graphic of the given size, yet to be filled. More...
 
 LinearGraphic (size_t s, uint8_t b)
 Construct a graphic of the given size filled with 1 byte (B).
 
 LinearGraphic (uint8_t *bs, size_t s)
 Construct a graphic that is held externally (NO OWNERSHIP to this). More...
 
 LinearGraphic (LinearGraphic &oth, size_t firstoff, size_t chunksize, size_t gap, size_t numchunks)
 Construct a graphic referring to part of another one (no ownership). More...
 
 LinearGraphic (const LinearGraphic &)=delete
 
LinearGraphicoperator= (const LinearGraphic &)=delete
 
 LinearGraphic (LinearGraphic &&og)
 
LinearGraphicoperator= (LinearGraphic &&og)
 
bool external (void) const noexcept
 Whether the object refers to part of another linear graphic. More...
 
bool owner (void) const noexcept
 Whether the object owns the graphical data. More...
 
size_t size (void) const noexcept
 Size in memory, in bytes. More...
 
bool oneByte (void) const noexcept
 Return TRUE if the graphic content is compressed into one byte. More...
 
uint8_t getByte (size_t offset) const
 Get the byte at the given offset, throwing if it is out of range.
 
uint8_t getByteUnsafe (size_t offset) const noexcept
 Get the byte at the given offset without checking out of range.
 
uint8_t * getAllBytes (void)
 Return a pointer to the data or throw if it is onebyte or external.
 
void setByte (size_t offset, uint8_t b)
 Change the byte at the given offset inside the data. More...
 
void setByteUnsafe (size_t offset, uint8_t b) noexcept
 Change the byte at the given offset without checking anything. More...
 
void setAllBytes (uint8_t b) noexcept
 Set all bytes of the graphic to the given value. More...
 
void merge (size_t destoffset, const LinearGraphic &oth, size_t origoffset, size_t howmany, GraphOp op=GraphOp::COPY)
 Merge HOWMANY bytes from OTH (at ORIGOFFSET) into this (at DESTOFFSET). More...
 
void mergeUnsafe (size_t destoffset, const LinearGraphic &oth, size_t origoffset, size_t howmany, GraphOp op=GraphOp::COPY)
 Merge HOWMANY bytes from OTH (at ORIGOFFSET) into this (at DESTOFFSET). More...
 
int compare (const LinearGraphic &oth, bool withinv=false) const noexcept
 Compare this graphic to OTH and return 1 if both are equal. More...
 
size_t similarity (const LinearGraphic &oth) const noexcept
 Return a measure of the bitmap similarity (bit by bit) between both. More...
 
std::string to_string (void) const
 Return a text with the info of the graphic.
 

Additional Inherited Members

- Static Public Member Functions inherited from zxeco::LinearGraphic
template<LinearGraphic::GraphOp op>
static constexpr uint8_t doGraphOp (uint8_t b0, uint8_t b1) noexcept
 Return the result of doing operation OP on byte B0 with byte B1.
 
- Public Attributes inherited from zxeco::DimsGraphic< PixelDistT >
AreaType dims
 Dimensions of the graphic. More...
 
- Protected Member Functions inherited from zxeco::LinearGraphic
void clear (void)
 
void reset (void)
 
void moveFrom (LinearGraphic &&og)
 
- Protected Attributes inherited from zxeco::LinearGraphic
bool owner_
 
size_t s_
 

◆ zxeco::Attrmap

class zxeco::Attrmap

A graphic that contains an attrmap, i.e., it has char resolution in height.

Definition at line 1220 of file ZXGraphics.h.

Inheritance diagram for zxeco::Attrmap:
Collaboration diagram for zxeco::Attrmap:

Public Types

using BaseGr = DimsGraphic< CharDistT >
 
- Public Types inherited from zxeco::DimsGraphic< CharDistT >
using CursorType = Cursor< CharCoordT, typename HEIGHTRESOL::coord_typeT >
 
using AreaType = Area< CharDistT, CharDistT >
 
using RectType = Rect< CharDistT, CharDistT >
 
- Public Types inherited from zxeco::LinearGraphic
enum class  GraphOp : unsigned char {
  GraphOp::COPY , GraphOp::INV , GraphOp::OR , GraphOp::INVOR ,
  GraphOp::AND , GraphOp::INVAND , GraphOp::XOR , GraphOp::INVXOR
}
 Possible operations on Graphics. More...
 

Public Member Functions

void swapPaperInk (void)
 < Reuse all constructor from Gr<CharDistT>. More...
 
std::string to_string (void) const
 Return a text with the info of the graphic. More...
 
- Public Member Functions inherited from zxeco::DimsGraphic< CharDistT >
 DimsGraphic (void)
 Default constructor: empty graphic. More...
 
 DimsGraphic (const AreaType &a)
 Construct an undefined graphic of the given dimensions, to be filled. More...
 
 DimsGraphic (const AreaType &a, uint8_t b)
 Construct a graphic of the given dimensions filled with one byte (B). More...
 
 DimsGraphic (uint8_t *bs, const AreaType &a)
 Construct a graphic that is held externally (NO OWNERSHIP to this). More...
 
 DimsGraphic (DimsGraphic &g, const RectType &region, bool copy=true)
 Construct a graphic that refers to a region within another one. More...
 
 DimsGraphic (DimsGraphic &&oth)
 Move constructor. More...
 
DimsGraphicoperator= (DimsGraphic &&oth)
 Move assignment. More...
 
size_t offset (const CursorType &pos) const
 Get the offset corresponding to the given coordinates in the graphic. More...
 
CursorType coords (size_t offset) const
 Get the coordinates of the given offset, if it is valid, or throws. More...
 
uint8_t getByte (const CursorType &pos) const
 < Unhide the linear getByte() method hidden by the new getByte(). More...
 
uint8_t getByte (size_t offset) const
 Get the byte at the given offset, throwing if it is out of range.
 
void setByte (const CursorType &pos, uint8_t b)
 < Unhide the linear setByte() method hidden by the new setByte(). More...
 
void setByte (size_t offset, uint8_t b)
 Change the byte at the given offset inside the data. More...
 
void merge (const DimsGraphic &oth, const CursorType &pos, GraphOp mode=GraphOp::COPY)
 Merge OTH at the given coordinates of this object with the given mode. More...
 
HEIGHTRESOL::type scrollUp (typename HEIGHTRESOL::type howmany, typename HEIGHTRESOL::type upperrow, uint8_t fillb)
 Scroll HOWMANY rows of the graphic up, beginning at y-coord UPPERROW. More...
 
std::string to_string (void) const
 Return a text with the info of the graphic. More...
 
- Public Member Functions inherited from zxeco::LinearGraphic
 LinearGraphic (void)
 Default constructor: empty graphic.
 
 LinearGraphic (size_t s)
 Construct an empty graphic of the given size, yet to be filled. More...
 
 LinearGraphic (size_t s, uint8_t b)
 Construct a graphic of the given size filled with 1 byte (B).
 
 LinearGraphic (uint8_t *bs, size_t s)
 Construct a graphic that is held externally (NO OWNERSHIP to this). More...
 
 LinearGraphic (LinearGraphic &oth, size_t firstoff, size_t chunksize, size_t gap, size_t numchunks)
 Construct a graphic referring to part of another one (no ownership). More...
 
 LinearGraphic (const LinearGraphic &)=delete
 
LinearGraphicoperator= (const LinearGraphic &)=delete
 
 LinearGraphic (LinearGraphic &&og)
 
LinearGraphicoperator= (LinearGraphic &&og)
 
bool external (void) const noexcept
 Whether the object refers to part of another linear graphic. More...
 
bool owner (void) const noexcept
 Whether the object owns the graphical data. More...
 
size_t size (void) const noexcept
 Size in memory, in bytes. More...
 
bool oneByte (void) const noexcept
 Return TRUE if the graphic content is compressed into one byte. More...
 
uint8_t getByte (size_t offset) const
 Get the byte at the given offset, throwing if it is out of range.
 
uint8_t getByteUnsafe (size_t offset) const noexcept
 Get the byte at the given offset without checking out of range.
 
uint8_t * getAllBytes (void)
 Return a pointer to the data or throw if it is onebyte or external.
 
void setByte (size_t offset, uint8_t b)
 Change the byte at the given offset inside the data. More...
 
void setByteUnsafe (size_t offset, uint8_t b) noexcept
 Change the byte at the given offset without checking anything. More...
 
void setAllBytes (uint8_t b) noexcept
 Set all bytes of the graphic to the given value. More...
 
void merge (size_t destoffset, const LinearGraphic &oth, size_t origoffset, size_t howmany, GraphOp op=GraphOp::COPY)
 Merge HOWMANY bytes from OTH (at ORIGOFFSET) into this (at DESTOFFSET). More...
 
void mergeUnsafe (size_t destoffset, const LinearGraphic &oth, size_t origoffset, size_t howmany, GraphOp op=GraphOp::COPY)
 Merge HOWMANY bytes from OTH (at ORIGOFFSET) into this (at DESTOFFSET). More...
 
int compare (const LinearGraphic &oth, bool withinv=false) const noexcept
 Compare this graphic to OTH and return 1 if both are equal. More...
 
size_t similarity (const LinearGraphic &oth) const noexcept
 Return a measure of the bitmap similarity (bit by bit) between both. More...
 
std::string to_string (void) const
 Return a text with the info of the graphic.
 

Additional Inherited Members

- Static Public Member Functions inherited from zxeco::LinearGraphic
template<LinearGraphic::GraphOp op>
static constexpr uint8_t doGraphOp (uint8_t b0, uint8_t b1) noexcept
 Return the result of doing operation OP on byte B0 with byte B1.
 
- Public Attributes inherited from zxeco::DimsGraphic< CharDistT >
AreaType dims
 Dimensions of the graphic. More...
 
- Protected Member Functions inherited from zxeco::LinearGraphic
void clear (void)
 
void reset (void)
 
void moveFrom (LinearGraphic &&og)
 
- Protected Attributes inherited from zxeco::LinearGraphic
bool owner_
 
size_t s_
 

◆ zxeco::DoubleGraphic

class zxeco::DoubleGraphic

A bitmap plus an attrmap, possibly synchronized.

Definition at line 1249 of file ZXGraphics.h.

Collaboration diagram for zxeco::DoubleGraphic:

Public Types

enum class  PNGConversionMode { PNGConversionMode::ToNearestPlain , PNGConversionMode::Dither }
 Modes of conversion of PNG images into DoubleGraphic. More...
 
enum class  PNGConversionSubmode { PNGConversionSubmode::None , PNGConversionSubmode::FixedPattern , PNGConversionSubmode::Noise }
 Submode of conversion of PNG images into DoubleGraphic. More...
 
using NumDithLevels = uint8_t
 Type for storing number of dithering levels. More...
 

Public Attributes

Bitmap bitmap
 
Attrmap attrmap
 

Public Member Functions

 DoubleGraphic (const CharArea &dims)
 Constructor for a given size in characters. More...
 
 DoubleGraphic (uint8_t *bs, uint8_t *as, const CharArea &a)
 Construct a graphic that is held externally (NO OWNERSHIP to this). More...
 
 DoubleGraphic (DoubleGraphic &g, const CharRect &region, bool copy=true)
 Construct a graphic that refers to the same region within a bit/attrmap. More...
 
 DoubleGraphic (DesktopInterface &desktop, const std::string &pngfile, const PNGConversionParms &parms={PNGConversionMode::ToNearestPlain, PNGConversionSubmode::None})
 Constructor from a .png file. More...
 
 DoubleGraphic (const DoubleGraphic &)=delete
 
DoubleGraphicoperator= (const DoubleGraphic &)=delete
 
 DoubleGraphic (DoubleGraphic &&oth)
 
DoubleGraphicoperator= (DoubleGraphic &&oth)
 
void merge (const DoubleGraphic &oth, const CharCursor &pos, LinearGraphic::GraphOp mode=LinearGraphic::GraphOp::COPY)
 Merge both bitmap and attrmap of OTH at the given coordinates in MODE. More...
 
void savePNG (DesktopInterface &desktop, const std::string &pngfile)
 Save the double graphic into a PNG file. More...
 
std::string to_string (void) const
 Return a text with the info of the graphic. More...
 

◆ zxeco::DoubleGraphic::PNGConversionParms

struct zxeco::DoubleGraphic::PNGConversionParms

Parameters for the conversion of PNG images into DoubleGraphic.

Definition at line 1274 of file ZXGraphics.h.

Public Attributes

PNGConversionMode mode
 Mode for conversion. More...
 
PNGConversionSubmode submode
 Submode. More...
 
struct {
tonearestplain
 Parms for ToNearestPlain mode.
 
struct {
   NumDithLevels   zxeco::DoubleGraphic::PNGConversionParms::numlevels
 Number of dithering levels. More...
 
dither
 Parms for Dither and its submodes.
 

◆ zxeco::DoubleGraphic::DitheringSystem::Color

class zxeco::DoubleGraphic::DitheringSystem::Color

Definition at line 1400 of file ZXGraphics.h.

Public Attributes

friend DitheringSystem
 

Public Member Functions

RGBPalette::Index indexInPal (void) const noexcept
 
RGBColor rgbColor (void) const
 
RGBPalette::Index firstExtreme (void) const noexcept
 
RGBPalette::Index secondExtreme (void) const noexcept
 
DitherLevel ditherLevel (void) const noexcept
 
bool notDithered (void) const noexcept
 
bool equalExtremesOrder (const Color &oc) const noexcept
 
bool equalExtremesNotOrder (const Color &oc) const noexcept
 
bool equalExtremes (const Color &oc) const noexcept
 
Color makeCompatibleWith (const Color &oc) const noexcept
 
std::string to_string (void) const
 

Function Documentation

◆ LinearGraphic::doGraphOp< LinearGraphic::GraphOp::COPY >()

template<>
constexpr uint8_t zxeco::LinearGraphic::doGraphOp< LinearGraphic::GraphOp::COPY > ( uint8_t  b0,
uint8_t  b1 
)
constexprnoexcept

#include <ZXGraphics.h>

Definition at line 1678 of file ZXGraphics.h.