2
2
// Anti-Grain Geometry - Version 2.4
3
3
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
5
// Permission to copy, use, modify, sell and distribute this software
6
// is granted provided this copyright notice appears in all copies.
5
// Permission to copy, use, modify, sell and distribute this software
6
// is granted provided this copyright notice appears in all copies.
7
7
// This software is provided "as is" without express or implied
8
8
// warranty, and with no claim as to its suitability for any purpose.
10
10
//----------------------------------------------------------------------------
12
// Adaptation for high precision colors has been sponsored by
12
// Adaptation for high precision colors has been sponsored by
13
13
// Liberty Technology Systems, Inc., visit http://lib-sys.com
15
15
// Liberty Technology Systems, Inc. is the provider of
16
16
// PostScript and PDF technology for software developers.
18
18
//----------------------------------------------------------------------------
19
19
// Contact: mcseem@antigrain.com
20
20
// mcseemagg@yahoo.com
245
245
//--------------------------------------------------------------------
246
246
rgba8(unsigned r_, unsigned g_, unsigned b_, unsigned a_=base_mask) :
250
250
a(value_type(a_)) {}
252
252
//--------------------------------------------------------------------
253
253
rgba8(const rgba& c, double a_) :
254
r((value_type)uround(c.r * double(base_mask))),
255
g((value_type)uround(c.g * double(base_mask))),
256
b((value_type)uround(c.b * double(base_mask))),
254
r((value_type)uround(c.r * double(base_mask))),
255
g((value_type)uround(c.g * double(base_mask))),
256
b((value_type)uround(c.b * double(base_mask))),
257
257
a((value_type)uround(a_ * double(base_mask))) {}
259
259
//--------------------------------------------------------------------
263
263
//--------------------------------------------------------------------
264
264
rgba8(const rgba& c) :
265
r((value_type)uround(c.r * double(base_mask))),
266
g((value_type)uround(c.g * double(base_mask))),
267
b((value_type)uround(c.b * double(base_mask))),
265
r((value_type)uround(c.r * double(base_mask))),
266
g((value_type)uround(c.g * double(base_mask))),
267
b((value_type)uround(c.b * double(base_mask))),
268
268
a((value_type)uround(c.a * double(base_mask))) {}
270
270
//--------------------------------------------------------------------
422
422
//-------------------------------------------------------------rgba8_pre
423
inline rgba8 rgba8_pre(unsigned r, unsigned g, unsigned b,
423
inline rgba8 rgba8_pre(unsigned r, unsigned g, unsigned b,
424
424
unsigned a = rgba8::base_mask)
426
426
return rgba8(r,g,b,a).premultiply();
515
515
//--------------------------------------------------------------------
516
516
rgba16(const rgba& c) :
517
r((value_type)uround(c.r * double(base_mask))),
518
g((value_type)uround(c.g * double(base_mask))),
519
b((value_type)uround(c.b * double(base_mask))),
517
r((value_type)uround(c.r * double(base_mask))),
518
g((value_type)uround(c.g * double(base_mask))),
519
b((value_type)uround(c.b * double(base_mask))),
520
520
a((value_type)uround(c.a * double(base_mask))) {}
522
522
//--------------------------------------------------------------------
523
523
rgba16(const rgba& c, double a_) :
524
r((value_type)uround(c.r * double(base_mask))),
525
g((value_type)uround(c.g * double(base_mask))),
526
b((value_type)uround(c.b * double(base_mask))),
524
r((value_type)uround(c.r * double(base_mask))),
525
g((value_type)uround(c.g * double(base_mask))),
526
b((value_type)uround(c.b * double(base_mask))),
527
527
a((value_type)uround(a_ * double(base_mask))) {}
529
529
//--------------------------------------------------------------------
530
530
rgba16(const rgba8& c) :
531
r(value_type((value_type(c.r) << 8) | c.r)),
532
g(value_type((value_type(c.g) << 8) | c.g)),
533
b(value_type((value_type(c.b) << 8) | c.b)),
531
r(value_type((value_type(c.r) << 8) | c.r)),
532
g(value_type((value_type(c.g) << 8) | c.g)),
533
b(value_type((value_type(c.b) << 8) | c.b)),
534
534
a(value_type((value_type(c.a) << 8) | c.a)) {}
536
536
//--------------------------------------------------------------------
537
537
rgba16(const rgba8& c, unsigned a_) :
538
r(value_type((value_type(c.r) << 8) | c.r)),
539
g(value_type((value_type(c.g) << 8) | c.g)),
540
b(value_type((value_type(c.b) << 8) | c.b)),
538
r(value_type((value_type(c.r) << 8) | c.r)),
539
g(value_type((value_type(c.g) << 8) | c.g)),
540
b(value_type((value_type(c.b) << 8) | c.b)),
541
541
a(value_type(( a_ << 8) | c.a)) {}
543
543
//--------------------------------------------------------------------
696
696
//--------------------------------------------------------------rgba16_pre
697
inline rgba16 rgba16_pre(unsigned r, unsigned g, unsigned b,
697
inline rgba16 rgba16_pre(unsigned r, unsigned g, unsigned b,
698
698
unsigned a = rgba16::base_mask)
700
700
return rgba16(r,g,b,a).premultiply();