Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
agg::rgba8T< Colorspace > Struct Template Reference

#include <src/agg/agg_color_rgba.h>

Public Types

enum  base_scale_e { base_shift = 8 , base_scale = 1 << base_shift , base_mask = base_scale - 1 , base_MSB = 1 << (base_shift - 1) }
 
typedef int8u value_type
 
typedef int32u calc_type
 
typedef int32 long_type
 
typedef rgba8T self_type
 

Public Member Functions

 rgba8T ()
 
 rgba8T (unsigned r_, unsigned g_, unsigned b_, unsigned a_=base_mask)
 
 rgba8T (const rgba &c)
 
 rgba8T (const self_type &c, unsigned a_)
 
template<class T >
 rgba8T (const rgba8T< T > &c)
 
 operator rgba () const
 
AGG_INLINE bool is_transparent () const
 
AGG_INLINE bool is_opaque () const
 
self_typeclear ()
 
self_typetransparent ()
 
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 void convert (rgba8T< linear > &dst, const rgba8T< sRGB > &src)
 
static void convert (rgba8T< sRGB > &dst, const rgba8T< linear > &src)
 
static void convert (rgba8T< linear > &dst, const rgba &src)
 
static void convert (rgba8T< sRGB > &dst, const rgba &src)
 
static void convert (rgba &dst, const rgba8T< linear > &src)
 
static void convert (rgba &dst, const rgba8T< sRGB > &src)
 
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

template<class Colorspace>
struct agg::rgba8T< Colorspace >

Member Typedef Documentation

◆ calc_type

template<class Colorspace >
typedef int32u agg::rgba8T< Colorspace >::calc_type

◆ long_type

template<class Colorspace >
typedef int32 agg::rgba8T< Colorspace >::long_type

◆ self_type

template<class Colorspace >
typedef rgba8T agg::rgba8T< Colorspace >::self_type

◆ value_type

template<class Colorspace >
typedef int8u agg::rgba8T< Colorspace >::value_type

Member Enumeration Documentation

◆ base_scale_e

template<class Colorspace >
enum agg::rgba8T::base_scale_e
Enumerator
base_shift 
base_scale 
base_mask 
base_MSB 
252 {
253 base_shift = 8,
254 base_scale = 1 << base_shift,
255 base_mask = base_scale - 1,
256 base_MSB = 1 << (base_shift - 1)
257 };
@ base_mask
Definition agg_color_rgba.h:255
@ base_shift
Definition agg_color_rgba.h:253
@ base_scale
Definition agg_color_rgba.h:254
@ base_MSB
Definition agg_color_rgba.h:256

Constructor & Destructor Documentation

◆ rgba8T() [1/5]

template<class Colorspace >
agg::rgba8T< Colorspace >::rgba8T ( )
inline
317{}

◆ rgba8T() [2/5]

template<class Colorspace >
agg::rgba8T< Colorspace >::rgba8T ( unsigned  r_,
unsigned  g_,
unsigned  b_,
unsigned  a_ = base_mask 
)
inline
320 :
321 r(value_type(r_)),
322 g(value_type(g_)),
323 b(value_type(b_)),
324 a(value_type(a_)) {}
value_type b
Definition agg_color_rgba.h:263
int8u value_type
Definition agg_color_rgba.h:248
value_type a
Definition agg_color_rgba.h:264
value_type r
Definition agg_color_rgba.h:261
value_type g
Definition agg_color_rgba.h:262

◆ rgba8T() [3/5]

template<class Colorspace >
agg::rgba8T< Colorspace >::rgba8T ( const rgba c)
inline
328 {
329 convert(*this, c);
330 }
static void convert(rgba8T< linear > &dst, const rgba8T< sRGB > &src)
Definition agg_color_rgba.h:266

References agg::rgba8T< Colorspace >::convert().

+ Here is the call graph for this function:

◆ rgba8T() [4/5]

template<class Colorspace >
agg::rgba8T< Colorspace >::rgba8T ( const self_type c,
unsigned  a_ 
)
inline
333 :
334 r(c.r), g(c.g), b(c.b), a(value_type(a_)) {}

◆ rgba8T() [5/5]

template<class Colorspace >
template<class T >
agg::rgba8T< Colorspace >::rgba8T ( const rgba8T< T > &  c)
inline
339 {
340 convert(*this, c);
341 }

References agg::rgba8T< Colorspace >::convert().

+ Here is the call graph for this function:

Member Function Documentation

◆ add()

template<class Colorspace >
AGG_INLINE void agg::rgba8T< Colorspace >::add ( const self_type c,
unsigned  cover 
)
inline
565 {
566 calc_type cr, cg, cb, ca;
567 if (cover == cover_mask)
568 {
569 if (c.a == base_mask)
570 {
571 *this = c;
572 return;
573 }
574 else
575 {
576 cr = r + c.r;
577 cg = g + c.g;
578 cb = b + c.b;
579 ca = a + c.a;
580 }
581 }
582 else
583 {
584 cr = r + mult_cover(c.r, cover);
585 cg = g + mult_cover(c.g, cover);
586 cb = b + mult_cover(c.b, cover);
587 ca = a + mult_cover(c.a, cover);
588 }
589 r = (value_type)((cr > calc_type(base_mask)) ? calc_type(base_mask) : cr);
590 g = (value_type)((cg > calc_type(base_mask)) ? calc_type(base_mask) : cg);
591 b = (value_type)((cb > calc_type(base_mask)) ? calc_type(base_mask) : cb);
592 a = (value_type)((ca > calc_type(base_mask)) ? calc_type(base_mask) : ca);
593 }
@ cover_mask
Definition agg_basics.h:242
static AGG_INLINE value_type mult_cover(value_type a, cover_type b)
Definition agg_color_rgba.h:432
int32u calc_type
Definition agg_color_rgba.h:249

References agg::rgba8T< Colorspace >::a, agg::rgba8T< Colorspace >::b, agg::rgba8T< Colorspace >::base_mask, agg::cover_mask, agg::rgba8T< Colorspace >::g, agg::rgba8T< Colorspace >::mult_cover(), and agg::rgba8T< Colorspace >::r.

+ Here is the call graph for this function:

◆ apply_gamma_dir()

template<class Colorspace >
template<class GammaLUT >
AGG_INLINE void agg::rgba8T< Colorspace >::apply_gamma_dir ( const GammaLUT &  gamma)
inline
598 {
599 r = gamma.dir(r);
600 g = gamma.dir(g);
601 b = gamma.dir(b);
602 }

References agg::rgba8T< Colorspace >::b, agg::rgba8T< Colorspace >::g, and agg::rgba8T< Colorspace >::r.

◆ apply_gamma_inv()

template<class Colorspace >
template<class GammaLUT >
AGG_INLINE void agg::rgba8T< Colorspace >::apply_gamma_inv ( const GammaLUT &  gamma)
inline
607 {
608 r = gamma.inv(r);
609 g = gamma.inv(g);
610 b = gamma.inv(b);
611 }

References agg::rgba8T< Colorspace >::b, agg::rgba8T< Colorspace >::g, and agg::rgba8T< Colorspace >::r.

◆ clear()

template<class Colorspace >
self_type & agg::rgba8T< Colorspace >::clear ( )
inline

◆ convert() [1/6]

template<class Colorspace >
static void agg::rgba8T< Colorspace >::convert ( rgba dst,
const rgba8T< linear > &  src 
)
inlinestatic
300 {
301 dst.r = src.r / 255.0;
302 dst.g = src.g / 255.0;
303 dst.b = src.b / 255.0;
304 dst.a = src.a / 255.0;
305 }

References agg::rgba::a, agg::rgba8T< Colorspace >::a, agg::rgba::b, agg::rgba8T< Colorspace >::b, agg::rgba::g, agg::rgba8T< Colorspace >::g, agg::rgba::r, and agg::rgba8T< Colorspace >::r.

◆ convert() [2/6]

template<class Colorspace >
static void agg::rgba8T< Colorspace >::convert ( rgba dst,
const rgba8T< sRGB > &  src 
)
inlinestatic
308 {
309 // Use the "float" table.
310 dst.r = sRGB_conv<float>::rgb_from_sRGB(src.r);
311 dst.g = sRGB_conv<float>::rgb_from_sRGB(src.g);
312 dst.b = sRGB_conv<float>::rgb_from_sRGB(src.b);
313 dst.a = sRGB_conv<float>::alpha_from_sRGB(src.a);
314 }

References agg::rgba::a, agg::rgba8T< Colorspace >::a, agg::rgba::b, agg::rgba8T< Colorspace >::b, agg::rgba::g, agg::rgba8T< Colorspace >::g, agg::rgba::r, and agg::rgba8T< Colorspace >::r.

◆ convert() [3/6]

template<class Colorspace >
static void agg::rgba8T< Colorspace >::convert ( rgba8T< linear > &  dst,
const rgba src 
)
inlinestatic
283 {
284 dst.r = value_type(uround(src.r * base_mask));
285 dst.g = value_type(uround(src.g * base_mask));
286 dst.b = value_type(uround(src.b * base_mask));
287 dst.a = value_type(uround(src.a * base_mask));
288 }
AGG_INLINE int uround(double v)
Definition agg_basics.h:192

References agg::rgba::a, agg::rgba8T< Colorspace >::a, agg::rgba::b, agg::rgba8T< Colorspace >::b, agg::rgba8T< Colorspace >::base_mask, agg::rgba::g, agg::rgba8T< Colorspace >::g, agg::rgba::r, agg::rgba8T< Colorspace >::r, and agg::uround().

+ Here is the call graph for this function:

◆ convert() [4/6]

template<class Colorspace >
static void agg::rgba8T< Colorspace >::convert ( rgba8T< linear > &  dst,
const rgba8T< sRGB > &  src 
)
inlinestatic
267 {
268 dst.r = sRGB_conv<value_type>::rgb_from_sRGB(src.r);
269 dst.g = sRGB_conv<value_type>::rgb_from_sRGB(src.g);
270 dst.b = sRGB_conv<value_type>::rgb_from_sRGB(src.b);
271 dst.a = src.a;
272 }

References agg::rgba8T< Colorspace >::a, agg::rgba8T< Colorspace >::b, agg::rgba8T< Colorspace >::g, and agg::rgba8T< Colorspace >::r.

Referenced by agg::rgba8T< Colorspace >::rgba8T(), agg::rgba8T< Colorspace >::rgba8T(), and agg::rgba8T< Colorspace >::operator rgba().

+ Here is the caller graph for this function:

◆ convert() [5/6]

template<class Colorspace >
static void agg::rgba8T< Colorspace >::convert ( rgba8T< sRGB > &  dst,
const rgba src 
)
inlinestatic
291 {
292 // Use the "float" table.
293 dst.r = sRGB_conv<float>::rgb_to_sRGB(float(src.r));
294 dst.g = sRGB_conv<float>::rgb_to_sRGB(float(src.g));
295 dst.b = sRGB_conv<float>::rgb_to_sRGB(float(src.b));
296 dst.a = sRGB_conv<float>::alpha_to_sRGB(float(src.a));
297 }

References agg::rgba::a, agg::rgba8T< Colorspace >::a, agg::rgba::b, agg::rgba8T< Colorspace >::b, agg::rgba::g, agg::rgba8T< Colorspace >::g, agg::rgba::r, and agg::rgba8T< Colorspace >::r.

◆ convert() [6/6]

template<class Colorspace >
static void agg::rgba8T< Colorspace >::convert ( rgba8T< sRGB > &  dst,
const rgba8T< linear > &  src 
)
inlinestatic
275 {
276 dst.r = sRGB_conv<value_type>::rgb_to_sRGB(src.r);
277 dst.g = sRGB_conv<value_type>::rgb_to_sRGB(src.g);
278 dst.b = sRGB_conv<value_type>::rgb_to_sRGB(src.b);
279 dst.a = src.a;
280 }

References agg::rgba8T< Colorspace >::a, agg::rgba8T< Colorspace >::b, agg::rgba8T< Colorspace >::g, and agg::rgba8T< Colorspace >::r.

◆ demultiply() [1/2]

template<class Colorspace >
AGG_INLINE self_type & agg::rgba8T< Colorspace >::demultiply ( )
inline
531 {
532 if (a < base_mask)
533 {
534 if (a == 0)
535 {
536 r = g = b = 0;
537 }
538 else
539 {
540 calc_type r_ = (calc_type(r) * base_mask) / a;
541 calc_type g_ = (calc_type(g) * base_mask) / a;
542 calc_type b_ = (calc_type(b) * base_mask) / a;
546 }
547 }
548 return *this;
549 }

References agg::rgba8T< Colorspace >::a, agg::rgba8T< Colorspace >::b, agg::rgba8T< Colorspace >::base_mask, agg::rgba8T< Colorspace >::g, and agg::rgba8T< Colorspace >::r.

◆ demultiply() [2/2]

template<class Colorspace >
static AGG_INLINE value_type agg::rgba8T< Colorspace >::demultiply ( value_type  a,
value_type  b 
)
inlinestatic
403 {
404 if (a * b == 0)
405 {
406 return 0;
407 }
408 else if (a >= b)
409 {
410 return base_mask;
411 }
412 else return value_type((a * base_mask + (b >> 1)) / b);
413 }

References agg::rgba8T< Colorspace >::a, agg::rgba8T< Colorspace >::b, and agg::rgba8T< Colorspace >::base_mask.

◆ downscale()

template<class Colorspace >
template<typename T >
static AGG_INLINE T agg::rgba8T< Colorspace >::downscale ( a)
inlinestatic

◆ downshift()

template<class Colorspace >
template<typename T >
static AGG_INLINE T agg::rgba8T< Colorspace >::downshift ( a,
unsigned  n 
)
inlinestatic
425 {
426 return a >> n;
427 }

References agg::rgba8T< Colorspace >::a.

◆ empty_value()

template<class Colorspace >
static AGG_INLINE value_type agg::rgba8T< Colorspace >::empty_value ( )
inlinestatic
365 {
366 return 0;
367 }

◆ from_double()

template<class Colorspace >
static AGG_INLINE value_type agg::rgba8T< Colorspace >::from_double ( double  a)
inlinestatic
359 {
360 return value_type(uround(a * base_mask));
361 }

References agg::rgba8T< Colorspace >::a, agg::rgba8T< Colorspace >::base_mask, and agg::uround().

+ Here is the call graph for this function:

◆ from_wavelength()

template<class Colorspace >
static self_type agg::rgba8T< Colorspace >::from_wavelength ( double  wl,
double  gamma = 1.0 
)
inlinestatic
618 {
619 return self_type(rgba::from_wavelength(wl, gamma));
620 }
rgba8T self_type
Definition agg_color_rgba.h:258
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()

template<class Colorspace >
static AGG_INLINE value_type agg::rgba8T< Colorspace >::full_value ( )
inlinestatic
371 {
372 return base_mask;
373 }

References agg::rgba8T< Colorspace >::base_mask.

◆ gradient()

template<class Colorspace >
AGG_INLINE self_type agg::rgba8T< Colorspace >::gradient ( const self_type c,
double  k 
) const
inline
553 {
554 self_type ret;
555 calc_type ik = uround(k * base_mask);
556 ret.r = lerp(r, c.r, ik);
557 ret.g = lerp(g, c.g, ik);
558 ret.b = lerp(b, c.b, ik);
559 ret.a = lerp(a, c.a, ik);
560 return ret;
561 }
static AGG_INLINE value_type lerp(value_type p, value_type q, value_type a)
Definition agg_color_rgba.h:452

References agg::rgba8T< Colorspace >::a, agg::rgba8T< Colorspace >::b, agg::rgba8T< Colorspace >::base_mask, agg::rgba8T< Colorspace >::g, agg::rgba8T< Colorspace >::lerp(), agg::rgba8T< Colorspace >::r, and agg::uround().

+ Here is the call graph for this function:

◆ invert()

template<class Colorspace >
static AGG_INLINE value_type agg::rgba8T< Colorspace >::invert ( value_type  x)
inlinestatic
389 {
390 return base_mask - x;
391 }
TCoord< P > x(const P &p)
Definition geometry_traits.hpp:297

References agg::rgba8T< Colorspace >::base_mask.

◆ is_opaque()

template<class Colorspace >
AGG_INLINE bool agg::rgba8T< Colorspace >::is_opaque ( ) const
inline

◆ is_transparent()

template<class Colorspace >
AGG_INLINE bool agg::rgba8T< Colorspace >::is_transparent ( ) const
inline
377 {
378 return a == 0;
379 }

References agg::rgba8T< Colorspace >::a.

◆ lerp()

template<class Colorspace >
static AGG_INLINE value_type agg::rgba8T< Colorspace >::lerp ( value_type  p,
value_type  q,
value_type  a 
)
inlinestatic
453 {
454 int t = (q - p) * a + base_MSB - (p > q);
455 return value_type(p + (((t >> base_shift) + t) >> base_shift));
456 }

References agg::rgba8T< Colorspace >::a, agg::rgba8T< Colorspace >::base_MSB, and agg::rgba8T< Colorspace >::base_shift.

Referenced by agg::rgba8T< Colorspace >::gradient().

+ Here is the caller graph for this function:

◆ mult_cover()

template<class Colorspace >
static AGG_INLINE value_type agg::rgba8T< Colorspace >::mult_cover ( value_type  a,
cover_type  b 
)
inlinestatic
433 {
434 return multiply(a, b);
435 }
static AGG_INLINE value_type multiply(value_type a, value_type b)
Definition agg_color_rgba.h:395

References agg::rgba8T< Colorspace >::a, agg::rgba8T< Colorspace >::b, and agg::rgba8T< Colorspace >::multiply().

Referenced by agg::rgba8T< Colorspace >::add().

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

◆ multiply()

template<class Colorspace >
static AGG_INLINE value_type agg::rgba8T< Colorspace >::multiply ( value_type  a,
value_type  b 
)
inlinestatic
396 {
397 calc_type t = a * b + base_MSB;
398 return value_type(((t >> base_shift) + t) >> base_shift);
399 }

References agg::rgba8T< Colorspace >::a, agg::rgba8T< Colorspace >::b, agg::rgba8T< Colorspace >::base_MSB, and agg::rgba8T< Colorspace >::base_shift.

Referenced by agg::rgba8T< Colorspace >::mult_cover(), agg::rgba8T< Colorspace >::prelerp(), agg::rgba8T< Colorspace >::premultiply(), and agg::rgba8T< Colorspace >::scale_cover().

+ Here is the caller graph for this function:

◆ no_color()

template<class Colorspace >
static self_type agg::rgba8T< Colorspace >::no_color ( )
inlinestatic
614{ return self_type(0,0,0,0); }

◆ opacity() [1/2]

template<class Colorspace >
double agg::rgba8T< Colorspace >::opacity ( ) const
inline
483 {
484 return double(a) / double(base_mask);
485 }

References agg::rgba8T< Colorspace >::a, and agg::rgba8T< Colorspace >::base_mask.

◆ opacity() [2/2]

template<class Colorspace >
self_type & agg::rgba8T< Colorspace >::opacity ( double  a_)
inline
474 {
475 if (a_ < 0) a = 0;
476 else if (a_ > 1) a = 1;
477 else a = (value_type)uround(a_ * double(base_mask));
478 return *this;
479 }

References agg::rgba8T< Colorspace >::a, agg::rgba8T< Colorspace >::base_mask, and agg::uround().

+ Here is the call graph for this function:

◆ operator rgba()

template<class Colorspace >
agg::rgba8T< Colorspace >::operator rgba ( ) const
inline
345 {
346 rgba c;
347 convert(c, *this);
348 return c;
349 }

References agg::rgba8T< Colorspace >::convert().

+ Here is the call graph for this function:

◆ prelerp()

template<class Colorspace >
static AGG_INLINE value_type agg::rgba8T< Colorspace >::prelerp ( value_type  p,
value_type  q,
value_type  a 
)
inlinestatic
446 {
447 return p + q - multiply(p, a);
448 }

References agg::rgba8T< Colorspace >::a, and agg::rgba8T< Colorspace >::multiply().

+ Here is the call graph for this function:

◆ premultiply() [1/2]

template<class Colorspace >
AGG_INLINE self_type & agg::rgba8T< Colorspace >::premultiply ( )
inline
489 {
490 if (a != base_mask)
491 {
492 if (a == 0)
493 {
494 r = g = b = 0;
495 }
496 else
497 {
498 r = multiply(r, a);
499 g = multiply(g, a);
500 b = multiply(b, a);
501 }
502 }
503 return *this;
504 }

References agg::rgba8T< Colorspace >::a, agg::rgba8T< Colorspace >::b, agg::rgba8T< Colorspace >::base_mask, agg::rgba8T< Colorspace >::g, agg::rgba8T< Colorspace >::multiply(), and agg::rgba8T< Colorspace >::r.

+ Here is the call graph for this function:

◆ premultiply() [2/2]

template<class Colorspace >
AGG_INLINE self_type & agg::rgba8T< Colorspace >::premultiply ( unsigned  a_)
inline
508 {
509 if (a != base_mask || a_ < base_mask)
510 {
511 if (a == 0 || a_ == 0)
512 {
513 r = g = b = a = 0;
514 }
515 else
516 {
517 calc_type r_ = (calc_type(r) * a_) / a;
518 calc_type g_ = (calc_type(g) * a_) / a;
519 calc_type b_ = (calc_type(b) * a_) / a;
520 r = value_type((r_ > a_) ? a_ : r_);
521 g = value_type((g_ > a_) ? a_ : g_);
522 b = value_type((b_ > a_) ? a_ : b_);
523 a = value_type(a_);
524 }
525 }
526 return *this;
527 }

References agg::rgba8T< Colorspace >::a, agg::rgba8T< Colorspace >::b, agg::rgba8T< Colorspace >::base_mask, agg::rgba8T< Colorspace >::g, and agg::rgba8T< Colorspace >::r.

◆ scale_cover()

template<class Colorspace >
static AGG_INLINE cover_type agg::rgba8T< Colorspace >::scale_cover ( cover_type  a,
value_type  b 
)
inlinestatic
439 {
440 return multiply(b, a);
441 }

References agg::rgba8T< Colorspace >::a, agg::rgba8T< Colorspace >::b, and agg::rgba8T< Colorspace >::multiply().

+ Here is the call graph for this function:

◆ to_double()

template<class Colorspace >
static AGG_INLINE double agg::rgba8T< Colorspace >::to_double ( value_type  a)
inlinestatic
353 {
354 return double(a) / base_mask;
355 }

References agg::rgba8T< Colorspace >::a, and agg::rgba8T< Colorspace >::base_mask.

◆ transparent()

template<class Colorspace >
self_type & agg::rgba8T< Colorspace >::transparent ( )
inline
467 {
468 a = 0;
469 return *this;
470 }

References agg::rgba8T< Colorspace >::a.

Member Data Documentation

◆ a

◆ b

◆ g

◆ r


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