openMSX
Public Member Functions | Static Public Member Functions | List of all members
openmsx::PixelOperations< Pixel > Class Template Reference

#include <PixelOperations.hh>

Inheritance diagram for openmsx::PixelOperations< Pixel >:
Inheritance graph
[legend]
Collaboration diagram for openmsx::PixelOperations< Pixel >:
Collaboration graph
[legend]

Public Member Functions

 PixelOperations (const PixelFormat &format)
 
unsigned red (Pixel p) const
 Extract RGB components. More...
 
unsigned green (Pixel p) const
 
unsigned blue (Pixel p) const
 
unsigned alpha (Pixel p) const
 
bool isFullyOpaque (Pixel p) const
 
bool isFullyTransparent (Pixel p) const
 
unsigned red256 (Pixel p) const
 Same as above, but result is scaled to [0..255]. More...
 
unsigned green256 (Pixel p) const
 
unsigned blue256 (Pixel p) const
 
Pixel combine (unsigned r, unsigned g, unsigned b) const
 Combine RGB components to a pixel. More...
 
Pixel combine256 (unsigned r, unsigned g, unsigned b) const
 
unsigned getMaxRed () const
 Get maximum component value. More...
 
unsigned getMaxGreen () const
 
unsigned getMaxBlue () const
 
template<unsigned w1, unsigned w2>
Pixel blend (Pixel p1, Pixel p2) const
 Blend the given colors into a single color. More...
 
template<unsigned w1, unsigned w2, unsigned w3>
Pixel blend (Pixel p1, Pixel p2, Pixel p3) const
 
template<unsigned w1, unsigned w2, unsigned w3, unsigned w4>
Pixel blend (Pixel p1, Pixel p2, Pixel p3, Pixel p4) const
 
template<unsigned w1, unsigned w2, unsigned w3, unsigned w4, unsigned w5, unsigned w6>
Pixel blend (Pixel p1, Pixel p2, Pixel p3, Pixel p4, Pixel p5, Pixel p6) const
 
template<unsigned w1, unsigned w2>
Pixel blend (std::span< const Pixel, 2 > p) const
 
template<unsigned w1, unsigned w2, unsigned w3>
Pixel blend (std::span< const Pixel, 3 > p) const
 
template<unsigned w1, unsigned w2, unsigned w3, unsigned w4>
Pixel blend (std::span< const Pixel, 4 > p) const
 
template<unsigned w1, unsigned w2, unsigned w3, unsigned w4, unsigned w5, unsigned w6>
Pixel blend (std::span< const Pixel, 6 > p) const
 
Pixel lerp (Pixel p1, Pixel p2, unsigned x) const
 Perform linear interpolation between two pixels. More...
 
Pixel alphaBlend (Pixel p1, Pixel p2) const
 Perform alpha blending of two pixels. More...
 
- Public Member Functions inherited from openmsx::PixelOpBase< Pixel >
 PixelOpBase (const PixelFormat &format_)
 
const PixelFormatgetPixelFormat () const
 
unsigned getRmask () const
 
unsigned getGmask () const
 
unsigned getBmask () const
 
unsigned getAmask () const
 
unsigned getRshift () const
 
unsigned getGshift () const
 
unsigned getBshift () const
 
unsigned getAshift () const
 
unsigned getRloss () const
 
unsigned getGloss () const
 
unsigned getBloss () const
 
unsigned getAloss () const
 
Pixel getBlendMask () const
 Returns a constant that is useful to calculate the average of two pixel values. More...
 

Static Public Member Functions

static Pixel multiply (Pixel p, unsigned x)
 Perform a component wise multiplication of a pixel with an 8-bit fractional value: result = (pixel * x) / 256 [component wise] 'x' must be in range [0..256]. More...
 

Additional Inherited Members

- Static Public Attributes inherited from openmsx::PixelOpBase< Pixel >
static constexpr bool IS_RGB565 = false
 Return true if it's statically known that the pixelformat has a 5-6-5 format (not specified which component goes where, but usually it will be BGR). More...
 

Detailed Description

template<std::unsigned_integral Pixel>
class openmsx::PixelOperations< Pixel >

Definition at line 146 of file PixelOperations.hh.

Constructor & Destructor Documentation

◆ PixelOperations()

template<std::unsigned_integral Pixel>
openmsx::PixelOperations< Pixel >::PixelOperations ( const PixelFormat format)
explicit

Definition at line 254 of file PixelOperations.hh.

Member Function Documentation

◆ alpha()

template<std::unsigned_integral Pixel>
unsigned openmsx::PixelOperations< Pixel >::alpha ( Pixel  p) const
inline

Definition at line 287 of file PixelOperations.hh.

References UNREACHABLE.

◆ alphaBlend()

template<std::unsigned_integral Pixel>
Pixel openmsx::PixelOperations< Pixel >::alphaBlend ( Pixel  p1,
Pixel  p2 
) const
inline

Perform alpha blending of two pixels.

Pixel p1 contains the alpha value. For maximal alpha p1 is returned, for minimal alpha p2.

Definition at line 665 of file PixelOperations.hh.

◆ blend() [1/8]

template<std::unsigned_integral Pixel>
template<unsigned w1, unsigned w2>
Pixel openmsx::PixelOperations< Pixel >::blend ( Pixel  p1,
Pixel  p2 
) const
inline

Blend the given colors into a single color.

The special case for blending between two colors with an equal blend weight has an optimized implementation.

Definition at line 414 of file PixelOperations.hh.

References openmsx::Keys::combine(), and g.

◆ blend() [2/8]

template<std::unsigned_integral Pixel>
template<unsigned w1, unsigned w2, unsigned w3>
Pixel openmsx::PixelOperations< Pixel >::blend ( Pixel  p1,
Pixel  p2,
Pixel  p3 
) const
inline

Definition at line 490 of file PixelOperations.hh.

References openmsx::Keys::combine(), g, p3, and w3.

◆ blend() [3/8]

template<std::unsigned_integral Pixel>
template<unsigned w1, unsigned w2, unsigned w3, unsigned w4>
Pixel openmsx::PixelOperations< Pixel >::blend ( Pixel  p1,
Pixel  p2,
Pixel  p3,
Pixel  p4 
) const
inline

Definition at line 512 of file PixelOperations.hh.

References openmsx::Keys::combine(), g, p3, p4, w3, and w4.

◆ blend() [4/8]

template<std::unsigned_integral Pixel>
template<unsigned w1, unsigned w2, unsigned w3, unsigned w4, unsigned w5, unsigned w6>
Pixel openmsx::PixelOperations< Pixel >::blend ( Pixel  p1,
Pixel  p2,
Pixel  p3,
Pixel  p4,
Pixel  p5,
Pixel  p6 
) const
inline

Definition at line 541 of file PixelOperations.hh.

References openmsx::Keys::combine(), g, p3, p4, w3, and w4.

◆ blend() [5/8]

template<std::unsigned_integral Pixel>
template<unsigned w1, unsigned w2>
Pixel openmsx::PixelOperations< Pixel >::blend ( std::span< const Pixel, 2 >  p) const
inline

Definition at line 577 of file PixelOperations.hh.

◆ blend() [6/8]

template<std::unsigned_integral Pixel>
template<unsigned w1, unsigned w2, unsigned w3>
Pixel openmsx::PixelOperations< Pixel >::blend ( std::span< const Pixel, 3 >  p) const
inline

Definition at line 584 of file PixelOperations.hh.

◆ blend() [7/8]

template<std::unsigned_integral Pixel>
template<unsigned w1, unsigned w2, unsigned w3, unsigned w4>
Pixel openmsx::PixelOperations< Pixel >::blend ( std::span< const Pixel, 4 >  p) const
inline

Definition at line 591 of file PixelOperations.hh.

◆ blend() [8/8]

template<std::unsigned_integral Pixel>
template<unsigned w1, unsigned w2, unsigned w3, unsigned w4, unsigned w5, unsigned w6>
Pixel openmsx::PixelOperations< Pixel >::blend ( std::span< const Pixel, 6 >  p) const
inline

Definition at line 599 of file PixelOperations.hh.

◆ blue()

template<std::unsigned_integral Pixel>
unsigned openmsx::PixelOperations< Pixel >::blue ( Pixel  p) const
inline

Definition at line 278 of file PixelOperations.hh.

◆ blue256()

template<std::unsigned_integral Pixel>
unsigned openmsx::PixelOperations< Pixel >::blue256 ( Pixel  p) const
inline

Definition at line 335 of file PixelOperations.hh.

◆ combine()

template<std::unsigned_integral Pixel>
Pixel openmsx::PixelOperations< Pixel >::combine ( unsigned  r,
unsigned  g,
unsigned  b 
) const
inline

Combine RGB components to a pixel.

Definition at line 345 of file PixelOperations.hh.

References g.

◆ combine256()

template<std::unsigned_integral Pixel>
Pixel openmsx::PixelOperations< Pixel >::combine256 ( unsigned  r,
unsigned  g,
unsigned  b 
) const
inline

Definition at line 354 of file PixelOperations.hh.

References g.

◆ getMaxBlue()

template<std::unsigned_integral Pixel>
unsigned openmsx::PixelOperations< Pixel >::getMaxBlue
inline

Definition at line 387 of file PixelOperations.hh.

◆ getMaxGreen()

template<std::unsigned_integral Pixel>
unsigned openmsx::PixelOperations< Pixel >::getMaxGreen
inline

Definition at line 378 of file PixelOperations.hh.

◆ getMaxRed()

template<std::unsigned_integral Pixel>
unsigned openmsx::PixelOperations< Pixel >::getMaxRed
inline

Get maximum component value.

Definition at line 369 of file PixelOperations.hh.

◆ green()

template<std::unsigned_integral Pixel>
unsigned openmsx::PixelOperations< Pixel >::green ( Pixel  p) const
inline

Definition at line 269 of file PixelOperations.hh.

◆ green256()

template<std::unsigned_integral Pixel>
unsigned openmsx::PixelOperations< Pixel >::green256 ( Pixel  p) const
inline

Definition at line 326 of file PixelOperations.hh.

◆ isFullyOpaque()

template<std::unsigned_integral Pixel>
bool openmsx::PixelOperations< Pixel >::isFullyOpaque ( Pixel  p) const
inline

Definition at line 298 of file PixelOperations.hh.

◆ isFullyTransparent()

template<std::unsigned_integral Pixel>
bool openmsx::PixelOperations< Pixel >::isFullyTransparent ( Pixel  p) const
inline

Definition at line 307 of file PixelOperations.hh.

◆ lerp()

template<std::unsigned_integral Pixel>
Pixel openmsx::PixelOperations< Pixel >::lerp ( Pixel  p1,
Pixel  p2,
unsigned  x 
) const
inline

Perform linear interpolation between two pixels.

This calculates component-wise: (c1 * (256 - x) + c2 * x) / 256 with c1, c2 the R,B,G,A components of the pixel. 'x' must be in range [0..256]. For x=0 the result is p1. For x=256 the result is p2.

Definition at line 616 of file PixelOperations.hh.

References openmsx::Keys::combine(), and g.

◆ multiply()

template<std::unsigned_integral Pixel>
Pixel openmsx::PixelOperations< Pixel >::multiply ( Pixel  p,
unsigned  x 
)
inlinestatic

Perform a component wise multiplication of a pixel with an 8-bit fractional value: result = (pixel * x) / 256 [component wise] 'x' must be in range [0..256].

For x=0 the result is 0. For x=255 the result in the original value. Note: ATM only implemented for 32bpp.

Definition at line 605 of file PixelOperations.hh.

References UNREACHABLE.

Referenced by openmsx::Multiply< uint32_t >::multiply().

◆ red()

template<std::unsigned_integral Pixel>
unsigned openmsx::PixelOperations< Pixel >::red ( Pixel  p) const
inline

Extract RGB components.

Definition at line 260 of file PixelOperations.hh.

◆ red256()

template<std::unsigned_integral Pixel>
unsigned openmsx::PixelOperations< Pixel >::red256 ( Pixel  p) const
inline

Same as above, but result is scaled to [0..255].

Definition at line 317 of file PixelOperations.hh.


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