24 , mMode( PreviewGrayscale )
49 pixmap =
sourcePixmap( Qt::LogicalCoordinates, &offset );
66 for (
int y = 0; y < image.
height(); y++ )
68 line = ( QRgb * )image.
scanLine( y );
69 for (
int x = 0; x < image.
width(); x++ )
71 int gray = 0.21 * qRed( line[x] ) + 0.72 * qGreen( line[x] ) + 0.07 * qBlue( line[x] );
72 line[x] = qRgb( gray, gray, gray );
90 for (
int y = 0; y < image.
height(); y++ )
92 line = ( QRgb * )image.
scanLine( y );
93 for (
int x = 0; x < image.
width(); x++ )
95 line[x] = simulateColorBlindness( line[x], mMode );
108 int red = qRed( originalColor );
109 int green = qGreen( originalColor );
110 int blue = qBlue( originalColor );
114 double L = ( 17.8824 * red ) + ( 43.5161 * green ) + ( 4.11935 * blue );
115 double M = ( 3.45565 * red ) + ( 27.1554 * green ) + ( 3.86714 * blue );
116 double S = ( 0.0299566 * red ) + ( 0.184309 * green ) + ( 1.46709 * blue );
122 simulateProtanopeLMS( L, M, S );
125 simulateDeuteranopeLMS( L, M, S );
133 red = ( 0.080944 * L ) + ( -0.130504 * M ) + ( 0.116721 * S );
134 green = ( -0.0102485 * L ) + ( 0.0540194 * M ) + ( -0.113615 * S );
135 blue = ( -0.000365294 * L ) + ( -0.00412163 * M ) + ( 0.693513 * S );
138 red = qMax( qMin( 255, red ), 0 );
139 green = qMax( qMin( 255, green ), 0 );
140 blue = qMax( qMin( 255, blue ), 0 );
142 return qRgb( red, green, blue );
145 void QgsPreviewEffect::simulateProtanopeLMS(
double& L,
double &M,
double &S )
149 L = ( 2.02344 * M ) + ( -2.52581 * S );
152 void QgsPreviewEffect::simulateDeuteranopeLMS(
double& L,
double &M,
double &S )
156 M = ( 0.494207 * L ) + ( 1.24827 * S );
void setEnabled(bool enable)
QPixmap sourcePixmap(Qt::CoordinateSystem system, QPoint *offset, PixmapPadMode mode) const
void setMode(PreviewMode mode)
Sets the mode for the preview effect, which controls how the effect modifies a widgets appearance...
bool sourceIsPixmap() const
PreviewMode mode() const
Returns the mode used for the preview effect.
void drawImage(const QRectF &target, const QImage &image, const QRectF &source, QFlags< Qt::ImageConversionFlag > flags)
virtual void draw(QPainter *painter) override
QgsPreviewEffect(QObject *parent)