mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-25 11:22:58 +00:00
replace if with switch statment in QColormap::pixel()
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
parent
6cf4cf8185
commit
c8db9c39c0
1 changed files with 8 additions and 4 deletions
|
@ -616,13 +616,17 @@ uint QColormap::pixel(const QColor &color) const
|
||||||
const uint r = (c.ct.argb.red * d->r_max) >> 16;
|
const uint r = (c.ct.argb.red * d->r_max) >> 16;
|
||||||
const uint g = (c.ct.argb.green * d->g_max) >> 16;
|
const uint g = (c.ct.argb.green * d->g_max) >> 16;
|
||||||
const uint b = (c.ct.argb.blue * d->b_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);
|
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);
|
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);
|
return (r << d->r_shift) + (g << d->g_shift) + (b << d->b_shift);
|
||||||
}
|
}
|
||||||
|
Q_UNREACHABLE();
|
||||||
|
}
|
||||||
|
|
||||||
const QColor QColormap::colorAt(uint pixel) const
|
const QColor QColormap::colorAt(uint pixel) const
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue