openMSX
Public Member Functions | Static Public Member Functions | List of all members
openmsx::PixelOperations Class Reference

#include <PixelOperations.hh>

Public Member Functions

Pixel getRmask () const
 
Pixel getGmask () const
 
Pixel getBmask () const
 
Pixel getAmask () const
 
unsigned red (Pixel p) const
 Extract RGBA components, each in range [0..255].
 
unsigned green (Pixel p) const
 
unsigned blue (Pixel p) const
 
unsigned alpha (Pixel p) const
 
Pixel combine (unsigned r, unsigned g, unsigned b) const
 Combine RGB components to a pixel.
 
template<unsigned w1, unsigned w2>
Pixel blend (Pixel p1, Pixel p2) const
 Blend the given colors into a single color.
 
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.
 
Pixel alphaBlend (Pixel p1, Pixel p2) const
 Perform alpha blending of two pixels.
 

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].
 

Detailed Description

Definition at line 12 of file PixelOperations.hh.

Member Function Documentation

◆ alpha()

unsigned openmsx::PixelOperations::alpha ( Pixel  p) const
inline

Definition at line 100 of file PixelOperations.hh.

Referenced by alphaBlend(), and openmsx::alphaBlendLines().

◆ alphaBlend()

Pixel openmsx::PixelOperations::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 309 of file PixelOperations.hh.

References alpha(), and lerp().

Referenced by openmsx::alphaBlendLines().

◆ blend() [1/8]

template<unsigned w1, unsigned w2>
Pixel openmsx::PixelOperations::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 126 of file PixelOperations.hh.

◆ blend() [2/8]

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

Definition at line 175 of file PixelOperations.hh.

References blue(), combine(), g, green(), p3, red(), and w3.

◆ blend() [3/8]

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

Definition at line 196 of file PixelOperations.hh.

References blue(), combine(), g, green(), p3, p4, red(), w3, and w4.

◆ blend() [4/8]

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

Definition at line 224 of file PixelOperations.hh.

References blue(), combine(), g, green(), p3, p4, red(), w3, and w4.

◆ blend() [5/8]

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

Definition at line 259 of file PixelOperations.hh.

◆ blend() [6/8]

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

Definition at line 265 of file PixelOperations.hh.

◆ blend() [7/8]

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

Definition at line 271 of file PixelOperations.hh.

◆ blend() [8/8]

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

Definition at line 278 of file PixelOperations.hh.

◆ blue()

unsigned openmsx::PixelOperations::blue ( Pixel  p) const
inline

Definition at line 96 of file PixelOperations.hh.

Referenced by blend(), blend(), and blend().

◆ combine()

Pixel openmsx::PixelOperations::combine ( unsigned  r,
unsigned  g,
unsigned  b 
) const
inline

Combine RGB components to a pixel.

Definition at line 105 of file PixelOperations.hh.

References g.

Referenced by blend(), blend(), blend(), openmsx::LDSDLRasterizer::drawBlank(), and openmsx::OutputSurface::mapRGB255().

◆ getAmask()

Pixel openmsx::PixelOperations::getAmask ( ) const
inline

Definition at line 18 of file PixelOperations.hh.

Referenced by openmsx::PNG::load(), and openmsx::PNG::saveRGBA().

◆ getBmask()

Pixel openmsx::PixelOperations::getBmask ( ) const
inline

Definition at line 17 of file PixelOperations.hh.

Referenced by openmsx::PNG::load(), and openmsx::PNG::saveRGBA().

◆ getGmask()

Pixel openmsx::PixelOperations::getGmask ( ) const
inline

Definition at line 16 of file PixelOperations.hh.

Referenced by openmsx::PNG::load(), and openmsx::PNG::saveRGBA().

◆ getRmask()

Pixel openmsx::PixelOperations::getRmask ( ) const
inline

Definition at line 15 of file PixelOperations.hh.

Referenced by openmsx::PNG::load(), and openmsx::PNG::saveRGBA().

◆ green()

unsigned openmsx::PixelOperations::green ( Pixel  p) const
inline

Definition at line 92 of file PixelOperations.hh.

Referenced by blend(), blend(), and blend().

◆ lerp()

Pixel openmsx::PixelOperations::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 289 of file PixelOperations.hh.

Referenced by alphaBlend().

◆ multiply()

Pixel openmsx::PixelOperations::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 283 of file PixelOperations.hh.

Referenced by openmsx::alphaBlendLines().

◆ red()

unsigned openmsx::PixelOperations::red ( Pixel  p) const
inline

Extract RGBA components, each in range [0..255].

Definition at line 88 of file PixelOperations.hh.

Referenced by blend(), blend(), and blend().


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