39 const int width =
static_cast< int >(
Qgis::UI_SCALE_FACTOR * widget->fontMetrics().horizontalAdvance(
'X' ) * 23 );
40 const int height =
static_cast< int >( width / 1.61803398875 );
42 const int margin =
static_cast< int >( height * 0.1 );
43 QImage icon = QImage( width + 2 * margin, height + 2 * margin, QImage::Format_ARGB32 );
44 icon.fill( Qt::transparent );
50 const QBrush checkBrush = QBrush( widget->transparentBackground() );
51 p.setPen( Qt::NoPen );
52 p.setBrush( checkBrush );
53 p.drawRect( margin, margin, width, height );
56 p.setBrush( QBrush( color ) );
59 p.setPen( QColor( 197, 197, 197 ) );
60 p.drawRect( margin, margin, width, height );
64 QBuffer buffer( &data );
65 icon.save( &buffer,
"PNG", 100 );
67 QString info = QStringLiteral(
"<b>HEX</b> %1<br>" ).arg( color.name() );
69 if ( color.spec() == QColor::Spec::Cmyk )
71 const double cyan = color.cyanF() * 100.;
72 const double magenta = color.magentaF() * 100.;
73 const double yellow = color.yellowF() * 100.;
74 const double black = color.blackF() * 100.;
75 const double alpha = color.alphaF() * 100.;
77 info += QStringLiteral(
"<b>CMYKA</b> %1,%2,%3,%4,%5<p>" )
78 .arg( cyan, 0,
'f', 2 ).arg( magenta, 0,
'f', 2 )
79 .arg( yellow, 0,
'f', 2 ).arg( black, 0,
'f', 2 )
80 .arg( alpha, 0,
'f', 2 );
84 const int hue = color.hue();
85 const int value = color.value();
86 const int saturation = color.saturation();
88 info += QStringLiteral(
"<b>RGBA</b> %1<br>"
90 .arg( hue ).arg( saturation ).arg( value );
93 info += QStringLiteral(
"<img src='data:image/png;base64, %1'>" ).arg( QString( data.toBase64() ) );