MRaster v20.12.0 lib 2022-10-14
An off-screen raster graphics library
MRaster v20.12.0 lib

Introduction

For a bit more detail about MRaster: http://richmit.github.io/mraster/index.html

A quick start guide: http://richmit.github.io/mraster/QuickStart.html

The code: [[https://github.com/richmit/mraster/]]

Notes on the Code

The code for this library all lives within the namespace of 'mjr' – my initials. This should help to avoid namespace conflicts.

At this time everything is implemented in header files.

As far as I know this code infringes upon no patents or other IP.

Organization of the code and include files

The library is template based and the primary players, canvas and color classes, are all templates. Common data types, 4 channel/24-bit color types and canvases that use them for example, all have typedefs. In addition, the various headers implementing the templates are included by headers defining the typedefs. In this way, common usage of the library requires no use of template syntax (or the extra typing).

The include files:

About Color Type Templates

Color types are intended to store all color information for a single pixel. Most common image structures can be identified by the number of channels (Red, Green, and Blue for example) and the depth of each channel (8-bit for example). The most common configurations are:

      |---------+---------+------+-------+------------------+-------------------------------------------------|
      | Channel |    Bits | Data |  bits |                  |                                                 |
      |   Count |     Per | Data |   per | Common Name      | Notes                                           |
      |         | Channel |      | pixel |                  |                                                 |
      |---------+---------+------+-------+------------------+-------------------------------------------------|
      |       3 |       8 | RGB  |    24 | 24-bit truecolor | Very common format.                             |
      |       4 |       8 | RGBA |    32 | truecolor+alpha  | Very common format.                             |
      |       3 |      16 | RGB  |    48 | 48-bit color     | High quality digital camera sensors.            |
      |       3 |      32 | RGB  |    96 | 96-bit color     | Usually a fusion from multiple CCDs             |
      |       1 |       8 | Grey |     8 | 8-bit greyscale  | Surveillance and Low Quality scientific imaging |
      |       1 |      16 | Grey |    16 | 16-bit greyscale | Typical scientific CCD equipment                |
      |       1 |      32 | Grey |    32 | 32-bit greyscale | High end scientific CCD equipment               |
      |---------+---------+------+-------+------------------+-------------------------------------------------|

Several aspects of the colorTpl template are not included in the Doxygen documentation because Doxygen has trouble with complex meta-programming constructs. In particular:

  • Types
    • maskType - Unsigned integer mask to cover the channel array without wasting too much space.
    • channelArithDType - Arithmetic type for differences of clrChanT values.
    • channelArithSPType - Arithmetic type for sums and products of clrChanT values.
    • channelArithSDPType - Arithmetic type for sums, differences, and products of clrChanT values.
    • channelArithFltType - Floating point type suitable for arithmetic of clrChanT values.
    • channelArithLogType - Arithmetic type suitable for for logical operations of clrChanT values.
    • csIntType - Integer type used to select colors from a color scheme
    • csFltType - Floating point type used to select colors from a color scheme
    • csNatType - A type used to select colors from a color scheme (it will be integral when clrChanT is integral, and floating point otherwise)
  • Predefined color scheme classes are documented here: http://richmit.github.io/mraster/ColorSchemes.html

Drawing

Primitive drawing functions generally come in several forms:

  • foo(<integer_coords>, <color>)
  • foo(<integer_coords>)
  • foo()
  • foo(<float_coords>, <color>)
  • foo(<float_coords>)
  • foo(<integer_points>, <color>)
  • foo(<integer_points>)
  • foo(<float_points>, <color>)
  • foo(<float_points>)
  • foo(<array_of_integer_points>, <color>)
  • foo(<array_of_integer_points>)
  • foo(<array_of_float_points>, <color>)
  • foo(<array_of_float_points>)

This library supports both the "moveTo/lineTo" paradigm (i.e. move to A, draw line to B), and the "absolute" paradigm (i.e. draw a line from A to B). Because of this, some primitive drawing functions also have forms with fewer coordinates specified. For example, we have a point drawing function that takes no arguments. Just with fewer coordinates. Some primitives, like circles, require extra parameters to describe the primitive. Such parameters right before the color arguments or last in the argument list if no color is specified.