Loading...
Searching...
No Matches
juce::PixelRGB Class Reference

Detailed Description

Represents a 24-bit RGB pixel, and can perform compositing operations on it.

This is used internally by the imaging classes.

See also
PixelARGB

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

Public Types

enum  { indexR = 0 , indexG = 1 , indexB = 2 }
 The indexes of the different components in the byte layout of this type of colour. More...

Public Member Functions

 PixelRGB () noexcept=default
 Creates a pixel without defining its colour.
forcedinline constexpr PixelRGB (uint8 red, uint8 green, uint8 blue) noexcept
 Creates a pixel.
forcedinline constexpr uint32 getNativeARGB () const noexcept
 Returns a uint32 which represents the pixel in a platform dependent format which is compatible with the native format of a PixelARGB.
forcedinline constexpr uint32 getInARGBMaskOrder () const noexcept
 Returns a uint32 which will be in argb order as if constructed with the following mask operation ((alpha << 24) | (red << 16) | (green << 8) | blue).
forcedinline constexpr uint32 getInARGBMemoryOrder () const noexcept
 Returns a uint32 which when written to memory, will be in the order a, r, g, b.
forcedinline constexpr uint32 getEvenBytes () const noexcept
 Return channels with an even index and insert zero bytes between them.
forcedinline constexpr uint32 getOddBytes () const noexcept
 Return channels with an odd index and insert zero bytes between them.
forcedinline constexpr uint8 getAlpha () const noexcept
forcedinline constexpr uint8 getRed () const noexcept
forcedinline constexpr uint8 getGreen () const noexcept
forcedinline constexpr uint8 getBlue () const noexcept
template<class Pixel>
forcedinline constexpr void set (Pixel src) noexcept
 Copies another pixel colour over this one.
forcedinline constexpr void setARGB (uint8, uint8 red, uint8 green, uint8 blue) noexcept
 Sets the pixel's colour from individual components.
template<class Pixel>
forcedinline constexpr void blend (Pixel src) noexcept
 Blends another pixel onto this one.
forcedinline constexpr void blend (PixelRGB src) noexcept
template<class Pixel>
forcedinline constexpr void blend (Pixel src, uint32 extraAlpha) noexcept
 Blends another pixel onto this one, applying an extra multiplier to its opacity.
template<class Pixel>
forcedinline void blend (const Pixel &src, BlendMode mode, uint32 extraAlpha=256u) noexcept
 Blends another pixel onto this one with the specified blend mode and applying an extra multiplier to its opacity.
template<class Pixel>
forcedinline constexpr void tween (Pixel src, uint32 amount) noexcept
 Blends another pixel with this one, creating a colour that is somewhere between the two, as specified by the amount.
forcedinline constexpr void setAlpha (uint8) noexcept
 This method is included for compatibility with the PixelARGB class.
forcedinline constexpr void multiplyAlpha (int) noexcept
 Multiplies the colour's alpha value with another one.
forcedinline constexpr void multiplyAlpha (float) noexcept
 Multiplies the colour's alpha value with another one.
forcedinline constexpr void premultiply () noexcept
 Premultiplies the pixel's RGB values by its alpha.
forcedinline constexpr void unpremultiply () noexcept
 Unpremultiplies the pixel's RGB values.
forcedinline constexpr void desaturate () noexcept

Member Enums

◆ anonymous enum

anonymous enum

The indexes of the different components in the byte layout of this type of colour.

Enumerator
indexR 
indexG 
indexB 

Constructors and Destructors

◆ PixelRGB() [1/2]

juce::PixelRGB::PixelRGB ( )
defaultnoexcept

Creates a pixel without defining its colour.

Referenced by blend(), PixelRGB(), set(), and setARGB().

◆ PixelRGB() [2/2]

forcedinline constexpr juce::PixelRGB::PixelRGB ( uint8 red,
uint8 green,
uint8 blue )
inlineconstexprnoexcept

Creates a pixel.

References forcedinline, and PixelRGB().

Member Functions

◆ getNativeARGB()

forcedinline constexpr uint32 juce::PixelRGB::getNativeARGB ( ) const
inlineconstexprnoexcept

Returns a uint32 which represents the pixel in a platform dependent format which is compatible with the native format of a PixelARGB.

See also
PixelARGB::getNativeARGB

References forcedinline, and juce::PixelARGB::getNativeARGB().

◆ getInARGBMaskOrder()

forcedinline constexpr uint32 juce::PixelRGB::getInARGBMaskOrder ( ) const
inlineconstexprnoexcept

Returns a uint32 which will be in argb order as if constructed with the following mask operation ((alpha << 24) | (red << 16) | (green << 8) | blue).

References forcedinline, and juce::PixelARGB::getInARGBMaskOrder().

◆ getInARGBMemoryOrder()

forcedinline constexpr uint32 juce::PixelRGB::getInARGBMemoryOrder ( ) const
inlineconstexprnoexcept

Returns a uint32 which when written to memory, will be in the order a, r, g, b.

In other words, if the return-value is read as a uint8 array then the elements will be in the order of a, r, g, b

References forcedinline, and juce::PixelARGB::getInARGBMemoryOrder().

◆ getEvenBytes()

forcedinline constexpr uint32 juce::PixelRGB::getEvenBytes ( ) const
inlineconstexprnoexcept

Return channels with an even index and insert zero bytes between them.

This is useful for blending operations. The exact channels which are returned is platform dependent but compatible with the return value of getEvenBytes of the PixelARGB class.

See also
PixelARGB::getEvenBytes

References forcedinline.

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

◆ getOddBytes()

forcedinline constexpr uint32 juce::PixelRGB::getOddBytes ( ) const
inlineconstexprnoexcept

Return channels with an odd index and insert zero bytes between them.

This is useful for blending operations. The exact channels which are returned is platform dependent but compatible with the return value of getOddBytes of the PixelARGB class.

See also
PixelARGB::getOddBytes

References forcedinline.

Referenced by blend(), and tween().

◆ getAlpha()

forcedinline constexpr uint8 juce::PixelRGB::getAlpha ( ) const
inlineconstexprnoexcept

References forcedinline.

◆ getRed()

forcedinline constexpr uint8 juce::PixelRGB::getRed ( ) const
inlineconstexprnoexcept

References forcedinline.

◆ getGreen()

forcedinline constexpr uint8 juce::PixelRGB::getGreen ( ) const
inlineconstexprnoexcept

References forcedinline.

◆ getBlue()

forcedinline constexpr uint8 juce::PixelRGB::getBlue ( ) const
inlineconstexprnoexcept

References forcedinline.

◆ set()

template<class Pixel>
forcedinline constexpr void juce::PixelRGB::set ( Pixel src)
inlineconstexprnoexcept

Copies another pixel colour over this one.

This doesn't blend it - this colour is simply replaced by the other one. Because PixelRGB has no alpha channel, any alpha value in the source pixel is thrown away.

References forcedinline, and PixelRGB().

Referenced by blend().

◆ setARGB()

forcedinline constexpr void juce::PixelRGB::setARGB ( uint8 ,
uint8 red,
uint8 green,
uint8 blue )
inlineconstexprnoexcept

Sets the pixel's colour from individual components.

References forcedinline, and PixelRGB().

◆ blend() [1/4]

template<class Pixel>
forcedinline constexpr void juce::PixelRGB::blend ( Pixel src)
inlineconstexprnoexcept

Blends another pixel onto this one.

This takes into account the opacity of the pixel being overlaid, and blends it accordingly.

References juce::clampPixelComponents(), forcedinline, getEvenBytes(), and juce::maskPixelComponents().

◆ blend() [2/4]

forcedinline constexpr void juce::PixelRGB::blend ( PixelRGB src)
inlineconstexprnoexcept

References forcedinline, PixelRGB(), and set().

◆ blend() [3/4]

template<class Pixel>
forcedinline constexpr void juce::PixelRGB::blend ( Pixel src,
uint32 extraAlpha )
inlineconstexprnoexcept

Blends another pixel onto this one, applying an extra multiplier to its opacity.

The opacity of the pixel being overlaid is scaled by the extraAlpha factor before being used, so this can blend semi-transparently from a PixelRGB argument.

References juce::clampPixelComponents(), forcedinline, getEvenBytes(), and juce::maskPixelComponents().

◆ blend() [4/4]

template<class Pixel>
forcedinline void juce::PixelRGB::blend ( const Pixel & src,
BlendMode mode,
uint32 extraAlpha = 256u )
inlinenoexcept

Blends another pixel onto this one with the specified blend mode and applying an extra multiplier to its opacity.

The opacity of the pixel being overlaid is scaled by the extraAlpha factor before being used, so this can blend semi-transparently from a PixelRGB argument.

Scaling with extraAlpha is done using lossy, fixed-point arithmetic, where full opacity is represented by 256.

References juce::clampPixelComponents(), juce::destinationIn, juce::destinationOut, forcedinline, getEvenBytes(), getOddBytes(), juce::maskPixelComponents(), juce::source, and juce::sourceOver.

◆ tween()

template<class Pixel>
forcedinline constexpr void juce::PixelRGB::tween ( Pixel src,
uint32 amount )
inlineconstexprnoexcept

Blends another pixel with this one, creating a colour that is somewhere between the two, as specified by the amount.

References forcedinline, getEvenBytes(), and getOddBytes().

◆ setAlpha()

forcedinline constexpr void juce::PixelRGB::setAlpha ( uint8 )
inlineconstexprnoexcept

This method is included for compatibility with the PixelARGB class.

References forcedinline.

◆ multiplyAlpha() [1/2]

forcedinline constexpr void juce::PixelRGB::multiplyAlpha ( int )
inlineconstexprnoexcept

Multiplies the colour's alpha value with another one.

References forcedinline.

◆ multiplyAlpha() [2/2]

forcedinline constexpr void juce::PixelRGB::multiplyAlpha ( float )
inlineconstexprnoexcept

Multiplies the colour's alpha value with another one.

References forcedinline.

◆ premultiply()

forcedinline constexpr void juce::PixelRGB::premultiply ( )
inlineconstexprnoexcept

Premultiplies the pixel's RGB values by its alpha.

References forcedinline.

◆ unpremultiply()

forcedinline constexpr void juce::PixelRGB::unpremultiply ( )
inlineconstexprnoexcept

Unpremultiplies the pixel's RGB values.

References forcedinline.

◆ desaturate()

forcedinline constexpr void juce::PixelRGB::desaturate ( )
inlineconstexprnoexcept

References forcedinline.

linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram