replace if with switch statment in QColormap::pixel()

Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
Ivailo Monev 2020-03-25 21:08:42 +00:00
parent 6cf4cf8185
commit c8db9c39c0

View file

@ -616,12 +616,16 @@ uint QColormap::pixel(const QColor &color) const
const uint r = (c.ct.argb.red * d->r_max) >> 16;
const uint g = (c.ct.argb.green * d->g_max) >> 16;
const uint b = (c.ct.argb.blue * d->b_max) >> 16;
if (d->mode != Direct) {
if (d->mode == Gray)
switch (d->mode) {
case Gray:
return d->pixels.at((r * 30 + g * 59 + b * 11) / 100);
case Indexed:
return d->pixels.at(r * d->g_max * d->b_max + g * d->b_max + b);
}
case Direct:
return (r << d->r_shift) + (g << d->g_shift) + (b << d->b_shift);
}
Q_UNREACHABLE();
}
const QColor QColormap::colorAt(uint pixel) const