OSDN Git Service

avoid color masking/unmasking in init_gray() function
authorIvailo Monev <xakepa10@laimg.moc>
Fri, 10 Jul 2020 01:32:43 +0000 (01:32 +0000)
committerIvailo Monev <xakepa10@laimg.moc>
Fri, 10 Jul 2020 01:32:43 +0000 (01:32 +0000)
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
src/gui/painting/qcolormap_x11.cpp

index 43b1495..d8c8b96 100644 (file)
@@ -235,15 +235,14 @@ static void init_gray(QColormapPrivate *d, int screen)
 
     for (int g = 0; g < d->g_max; ++g) {
         const int gray = (g * 0xff + (d->r_max - 1) / 2) / (d->r_max - 1);
-        const QRgb rgb = qRgb(gray, gray, gray);
 
         d->pixels[g] = -1;
 
         if (d->visual->c_class & 1) {
             XColor xcolor;
-            xcolor.red   =   qRed(rgb) * 0x101;
-            xcolor.green = qGreen(rgb) * 0x101;
-            xcolor.blue  =  qBlue(rgb) * 0x101;
+            xcolor.red   = gray * 0x101;
+            xcolor.green = gray * 0x101;
+            xcolor.blue  = gray * 0x101;
             xcolor.pixel = 0ul;
 
             if (XAllocColor(QX11Info::display(), d->colormap, &xcolor))