29 #include "DGtal/io/Color.h" 45 :myAlpha( aAlphaValue )
47 myRed = ( rgb & 0xFF0000u ) >> 16;
48 myGreen = ( rgb & 0xFF00u ) >> 8;
56 myRed = ( aRGBA & 0xFF000000u ) >> 24;
57 myGreen = ( aRGBA & 0xFF0000u ) >> 16;
58 myBlue = ( aRGBA & 0xFF00u ) >> 8;
69 if ( aRedValue > 1.0f ) aRedValue = 1.0f;
70 if ( aRedValue < 0.0f ) aRedValue = 0.0f;
71 myRed =
static_cast<unsigned char>( 255 * aRedValue );
72 if ( aGreenValue > 1.0f ) aGreenValue = 1.0f;
73 if ( aGreenValue < 0.0f ) aGreenValue = 0.0f;
74 myGreen =
static_cast<unsigned char>( 255 * aGreenValue );
75 if ( aBlueValue > 1.0f ) aBlueValue = 1.0f;
76 if ( aBlueValue < 0.0f ) aBlueValue = 0.0f;
77 myBlue =
static_cast<unsigned char>( 255 * aBlueValue );
78 if ( aAlphaValue > 1.0f ) aAlphaValue = 1.0f;
79 if ( aAlphaValue < 0.0f ) aAlphaValue = 0.0f;
80 myAlpha =
static_cast<unsigned char>( 255 * aAlphaValue );
126 stream << ((double)
myRed/255.0) <<
" " 127 << ((double)
myGreen/255.0) <<
" " 128 << ((double)
myBlue/255.0) <<
" srgb\n";
135 secured_sprintf( buffer, 255,
"%.4f %.4f %.4f",
myRed/255.0,
myGreen/255.0,
myBlue/255.0 );
153 secured_sprintf( buffer, 255,
" %s-opacity=\"%f\"", prefix,
myAlpha/255.0f );
177 secured_sprintf( buffer, 255,
"{rgb,255:red,%d;green,%d;blue,%d}",
myRed,
myGreen,
myBlue );
boost::uint32_t uint32_t
unsigned 32-bit integer.
static const Color Magenta
Color & setRGBA(DGtal::uint32_t aRGBA)
bool operator!=(const Color &aColor) const
static const Color Yellow
bool operator<(const Color &aColor) const
std::string postscript() const
void selfDisplay(std::ostream &out) const
std::string svgAlpha(const char *aPrefix) const
static const Color Silver
bool operator==(const Color &aColor) const
Structure representing an RGB triple with alpha component.
void flushPostscript(std::ostream &) const
Color & setRGBf(float red, float green, float blue, float alpha=1.0)
static const Color Purple