Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
agg::rgba16 Struct Reference

#include <src/agg/agg_color_rgba.h>

Public Types

enum  base_scale_e { base_shift = 16 , base_scale = 1 << base_shift , base_mask = base_scale - 1 , base_MSB = 1 << (base_shift - 1) }
 
typedef int16u value_type
 
typedef int32u calc_type
 
typedef int64 long_type
 
typedef rgba16 self_type
 

Public Member Functions

 rgba16 ()
 
 rgba16 (unsigned r_, unsigned g_, unsigned b_, unsigned a_=base_mask)
 
 rgba16 (const self_type &c, unsigned a_)
 
 rgba16 (const rgba &c)
 
 rgba16 (const rgba8 &c)
 
 rgba16 (const srgba8 &c)
 
 operator rgba () const
 
 operator rgba8 () const
 
 operator srgba8 () const
 
AGG_INLINE bool is_transparent () const
 
AGG_INLINE bool is_opaque () const
 
self_typeclear ()
 
self_typetransparent ()
 
AGG_INLINE self_typeopacity (double a_)
 
double opacity () const
 
AGG_INLINE self_typepremultiply ()
 
AGG_INLINE self_typepremultiply (unsigned a_)
 
AGG_INLINE self_typedemultiply ()
 
AGG_INLINE self_type gradient (const self_type &c, double k) const
 
AGG_INLINE void add (const self_type &c, unsigned cover)
 
template<class GammaLUT >
AGG_INLINE void apply_gamma_dir (const GammaLUT &gamma)
 
template<class GammaLUT >
AGG_INLINE void apply_gamma_inv (const GammaLUT &gamma)
 

Static Public Member Functions

static AGG_INLINE double to_double (value_type a)
 
static AGG_INLINE value_type from_double (double a)
 
static AGG_INLINE value_type empty_value ()
 
static AGG_INLINE value_type full_value ()
 
static AGG_INLINE value_type invert (value_type x)
 
static AGG_INLINE value_type multiply (value_type a, value_type b)
 
static AGG_INLINE value_type demultiply (value_type a, value_type b)
 
template<typename T >
static AGG_INLINEdownscale (T a)
 
template<typename T >
static AGG_INLINEdownshift (T a, unsigned n)
 
static AGG_INLINE value_type mult_cover (value_type a, cover_type b)
 
static AGG_INLINE cover_type scale_cover (cover_type a, value_type b)
 
static AGG_INLINE value_type prelerp (value_type p, value_type q, value_type a)
 
static AGG_INLINE value_type lerp (value_type p, value_type q, value_type a)
 
static self_type no_color ()
 
static self_type from_wavelength (double wl, double gamma=1.0)
 

Public Attributes

value_type r
 
value_type g
 
value_type b
 
value_type a
 

Detailed Description

Member Typedef Documentation

◆ calc_type

◆ long_type

◆ self_type

◆ value_type

Member Enumeration Documentation

◆ base_scale_e

Enumerator
base_shift 
base_scale 
base_mask 
base_MSB 
668 {
669 base_shift = 16,
670 base_scale = 1 << base_shift,
671 base_mask = base_scale - 1,
672 base_MSB = 1 << (base_shift - 1)
673 };
@ base_scale
Definition agg_color_rgba.h:670
@ base_MSB
Definition agg_color_rgba.h:672
@ base_shift
Definition agg_color_rgba.h:669
@ base_mask
Definition agg_color_rgba.h:671

Constructor & Destructor Documentation

◆ rgba16() [1/6]

agg::rgba16::rgba16 ( )
inline
682{}

◆ rgba16() [2/6]

agg::rgba16::rgba16 ( unsigned  r_,
unsigned  g_,
unsigned  b_,
unsigned  a_ = base_mask 
)
inline
685 :
686 r(value_type(r_)),
687 g(value_type(g_)),
688 b(value_type(b_)),
689 a(value_type(a_)) {}
value_type r
Definition agg_color_rgba.h:676
value_type g
Definition agg_color_rgba.h:677
value_type a
Definition agg_color_rgba.h:679
int16u value_type
Definition agg_color_rgba.h:664
value_type b
Definition agg_color_rgba.h:678

◆ rgba16() [3/6]

agg::rgba16::rgba16 ( const self_type c,
unsigned  a_ 
)
inline
692 :
693 r(c.r), g(c.g), b(c.b), a(value_type(a_)) {}

◆ rgba16() [4/6]

agg::rgba16::rgba16 ( const rgba c)
inline
696 :
697 r((value_type)uround(c.r * double(base_mask))),
698 g((value_type)uround(c.g * double(base_mask))),
699 b((value_type)uround(c.b * double(base_mask))),
700 a((value_type)uround(c.a * double(base_mask))) {}
AGG_INLINE int uround(double v)
Definition agg_basics.h:192

◆ rgba16() [5/6]

agg::rgba16::rgba16 ( const rgba8 c)
inline
703 :
704 r(value_type((value_type(c.r) << 8) | c.r)),
705 g(value_type((value_type(c.g) << 8) | c.g)),
706 b(value_type((value_type(c.b) << 8) | c.b)),
707 a(value_type((value_type(c.a) << 8) | c.a)) {}

◆ rgba16() [6/6]

agg::rgba16::rgba16 ( const srgba8 c)
inline
710 :
711 r(sRGB_conv<value_type>::rgb_from_sRGB(c.r)),
712 g(sRGB_conv<value_type>::rgb_from_sRGB(c.g)),
713 b(sRGB_conv<value_type>::rgb_from_sRGB(c.b)),
714 a(sRGB_conv<value_type>::alpha_from_sRGB(c.a)) {}

Member Function Documentation

◆ add()

AGG_INLINE void agg::rgba16::add ( const self_type c,
unsigned  cover 
)
inline
957 {
958 calc_type cr, cg, cb, ca;
959 if (cover == cover_mask)
960 {
961 if (c.a == base_mask)
962 {
963 *this = c;
964 return;
965 }
966 else
967 {
968 cr = r + c.r;
969 cg = g + c.g;
970 cb = b + c.b;
971 ca = a + c.a;
972 }
973 }
974 else
975 {
976 cr = r + mult_cover(c.r, cover);
977 cg = g + mult_cover(c.g, cover);
978 cb = b + mult_cover(c.b, cover);
979 ca = a + mult_cover(c.a, cover);
980 }
981 r = (value_type)((cr > calc_type(base_mask)) ? calc_type(base_mask) : cr);
982 g = (value_type)((cg > calc_type(base_mask)) ? calc_type(base_mask) : cg);
983 b = (value_type)((cb > calc_type(base_mask)) ? calc_type(base_mask) : cb);
984 a = (value_type)((ca > calc_type(base_mask)) ? calc_type(base_mask) : ca);
985 }
@ cover_mask
Definition agg_basics.h:242
int32u calc_type
Definition agg_color_rgba.h:665
static AGG_INLINE value_type mult_cover(value_type a, cover_type b)
Definition agg_color_rgba.h:824

References a, b, base_mask, agg::cover_mask, g, mult_cover(), and r.

+ Here is the call graph for this function:

◆ apply_gamma_dir()

template<class GammaLUT >
AGG_INLINE void agg::rgba16::apply_gamma_dir ( const GammaLUT &  gamma)
inline
990 {
991 r = gamma.dir(r);
992 g = gamma.dir(g);
993 b = gamma.dir(b);
994 }

References b, g, and r.

◆ apply_gamma_inv()

template<class GammaLUT >
AGG_INLINE void agg::rgba16::apply_gamma_inv ( const GammaLUT &  gamma)
inline
999 {
1000 r = gamma.inv(r);
1001 g = gamma.inv(g);
1002 b = gamma.inv(b);
1003 }

References b, g, and r.

◆ clear()

self_type & agg::rgba16::clear ( )
inline
852 {
853 r = g = b = a = 0;
854 return *this;
855 }

References a, b, g, and r.

◆ demultiply() [1/2]

AGG_INLINE self_type & agg::rgba16::demultiply ( )
inline
923 {
924 if (a < base_mask)
925 {
926 if (a == 0)
927 {
928 r = g = b = 0;
929 }
930 else
931 {
932 calc_type r_ = (calc_type(r) * base_mask) / a;
933 calc_type g_ = (calc_type(g) * base_mask) / a;
934 calc_type b_ = (calc_type(b) * base_mask) / a;
938 }
939 }
940 return *this;
941 }

References a, b, base_mask, g, and r.

◆ demultiply() [2/2]

static AGG_INLINE value_type agg::rgba16::demultiply ( value_type  a,
value_type  b 
)
inlinestatic
795 {
796 if (a * b == 0)
797 {
798 return 0;
799 }
800 else if (a >= b)
801 {
802 return base_mask;
803 }
804 else return value_type((a * base_mask + (b >> 1)) / b);
805 }

References a, b, and base_mask.

◆ downscale()

template<typename T >
static AGG_INLINE T agg::rgba16::downscale ( a)
inlinestatic
810 {
811 return a >> base_shift;
812 }

References a, and base_shift.

◆ downshift()

template<typename T >
static AGG_INLINE T agg::rgba16::downshift ( a,
unsigned  n 
)
inlinestatic
817 {
818 return a >> n;
819 }

References a.

◆ empty_value()

static AGG_INLINE value_type agg::rgba16::empty_value ( )
inlinestatic
757 {
758 return 0;
759 }

◆ from_double()

static AGG_INLINE value_type agg::rgba16::from_double ( double  a)
inlinestatic
751 {
752 return value_type(uround(a * base_mask));
753 }

References a, base_mask, and agg::uround().

+ Here is the call graph for this function:

◆ from_wavelength()

static self_type agg::rgba16::from_wavelength ( double  wl,
double  gamma = 1.0 
)
inlinestatic
1010 {
1011 return self_type(rgba::from_wavelength(wl, gamma));
1012 }
rgba16 self_type
Definition agg_color_rgba.h:674
static rgba from_wavelength(double wl, double gamma=1.0)
Definition agg_color_rgba.h:194

References agg::rgba::from_wavelength().

+ Here is the call graph for this function:

◆ full_value()

static AGG_INLINE value_type agg::rgba16::full_value ( )
inlinestatic
763 {
764 return base_mask;
765 }

References base_mask.

◆ gradient()

AGG_INLINE self_type agg::rgba16::gradient ( const self_type c,
double  k 
) const
inline
945 {
946 self_type ret;
947 calc_type ik = uround(k * base_mask);
948 ret.r = lerp(r, c.r, ik);
949 ret.g = lerp(g, c.g, ik);
950 ret.b = lerp(b, c.b, ik);
951 ret.a = lerp(a, c.a, ik);
952 return ret;
953 }
static AGG_INLINE value_type lerp(value_type p, value_type q, value_type a)
Definition agg_color_rgba.h:844

References a, b, base_mask, g, lerp(), r, and agg::uround().

+ Here is the call graph for this function:

◆ invert()

static AGG_INLINE value_type agg::rgba16::invert ( value_type  x)
inlinestatic
781 {
782 return base_mask - x;
783 }
TCoord< P > x(const P &p)
Definition geometry_traits.hpp:297

References base_mask.

◆ is_opaque()

AGG_INLINE bool agg::rgba16::is_opaque ( ) const
inline
775 {
776 return a == base_mask;
777 }

References a, and base_mask.

◆ is_transparent()

AGG_INLINE bool agg::rgba16::is_transparent ( ) const
inline
769 {
770 return a == 0;
771 }

References a.

◆ lerp()

static AGG_INLINE value_type agg::rgba16::lerp ( value_type  p,
value_type  q,
value_type  a 
)
inlinestatic
845 {
846 int t = (q - p) * a + base_MSB - (p > q);
847 return value_type(p + (((t >> base_shift) + t) >> base_shift));
848 }

References a, base_MSB, and base_shift.

Referenced by gradient().

+ Here is the caller graph for this function:

◆ mult_cover()

static AGG_INLINE value_type agg::rgba16::mult_cover ( value_type  a,
cover_type  b 
)
inlinestatic
825 {
826 return multiply(a, (b << 8) | b);
827 }
static AGG_INLINE value_type multiply(value_type a, value_type b)
Definition agg_color_rgba.h:787

References a, b, and multiply().

Referenced by add().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ multiply()

static AGG_INLINE value_type agg::rgba16::multiply ( value_type  a,
value_type  b 
)
inlinestatic
788 {
789 calc_type t = a * b + base_MSB;
790 return value_type(((t >> base_shift) + t) >> base_shift);
791 }

References a, b, base_MSB, and base_shift.

Referenced by mult_cover(), prelerp(), premultiply(), and scale_cover().

+ Here is the caller graph for this function:

◆ no_color()

static self_type agg::rgba16::no_color ( )
inlinestatic
1006{ return self_type(0,0,0,0); }

◆ opacity() [1/2]

double agg::rgba16::opacity ( ) const
inline
875 {
876 return double(a) / double(base_mask);
877 }

References a, and base_mask.

◆ opacity() [2/2]

AGG_INLINE self_type & agg::rgba16::opacity ( double  a_)
inline
866 {
867 if (a_ < 0) a = 0;
868 if (a_ > 1) a = 1;
869 a = value_type(uround(a_ * double(base_mask)));
870 return *this;
871 }

References a, base_mask, and agg::uround().

+ Here is the call graph for this function:

◆ operator rgba()

agg::rgba16::operator rgba ( ) const
inline
718 {
719 return rgba(
720 r / 65535.0,
721 g / 65535.0,
722 b / 65535.0,
723 a / 65535.0);
724 }

References a, b, g, and r.

◆ operator rgba8()

agg::rgba16::operator rgba8 ( ) const
inline
728 {
729 return rgba8(r >> 8, g >> 8, b >> 8, a >> 8);
730 }
rgba8T< linear > rgba8
Definition agg_color_rgba.h:623

References a, b, g, and r.

◆ operator srgba8()

agg::rgba16::operator srgba8 ( ) const
inline
734 {
735 // Return (non-premultiplied) sRGB values.
736 return srgba8(
737 sRGB_conv<value_type>::rgb_to_sRGB(r),
738 sRGB_conv<value_type>::rgb_to_sRGB(g),
739 sRGB_conv<value_type>::rgb_to_sRGB(b),
740 sRGB_conv<value_type>::alpha_to_sRGB(a));
741 }
rgba8T< sRGB > srgba8
Definition agg_color_rgba.h:624

References a, b, g, and r.

◆ prelerp()

static AGG_INLINE value_type agg::rgba16::prelerp ( value_type  p,
value_type  q,
value_type  a 
)
inlinestatic
838 {
839 return p + q - multiply(p, a);
840 }

References a, and multiply().

+ Here is the call graph for this function:

◆ premultiply() [1/2]

AGG_INLINE self_type & agg::rgba16::premultiply ( )
inline
881 {
882 if (a != base_mask)
883 {
884 if (a == 0)
885 {
886 r = g = b = 0;
887 }
888 else
889 {
890 r = multiply(r, a);
891 g = multiply(g, a);
892 b = multiply(b, a);
893 }
894 }
895 return *this;
896 }

References a, b, base_mask, g, multiply(), and r.

+ Here is the call graph for this function:

◆ premultiply() [2/2]

AGG_INLINE self_type & agg::rgba16::premultiply ( unsigned  a_)
inline
900 {
901 if (a < base_mask || a_ < base_mask)
902 {
903 if (a == 0 || a_ == 0)
904 {
905 r = g = b = a = 0;
906 }
907 else
908 {
909 calc_type r_ = (calc_type(r) * a_) / a;
910 calc_type g_ = (calc_type(g) * a_) / a;
911 calc_type b_ = (calc_type(b) * a_) / a;
912 r = value_type((r_ > a_) ? a_ : r_);
913 g = value_type((g_ > a_) ? a_ : g_);
914 b = value_type((b_ > a_) ? a_ : b_);
915 a = value_type(a_);
916 }
917 }
918 return *this;
919 }

References a, b, base_mask, g, and r.

◆ scale_cover()

static AGG_INLINE cover_type agg::rgba16::scale_cover ( cover_type  a,
value_type  b 
)
inlinestatic
831 {
832 return multiply((a << 8) | a, b) >> 8;
833 }

References a, b, and multiply().

+ Here is the call graph for this function:

◆ to_double()

static AGG_INLINE double agg::rgba16::to_double ( value_type  a)
inlinestatic
745 {
746 return double(a) / base_mask;
747 }

References a, and base_mask.

◆ transparent()

self_type & agg::rgba16::transparent ( )
inline
859 {
860 a = 0;
861 return *this;
862 }

References a.

Member Data Documentation

◆ a

◆ b

◆ g

◆ r


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