icon-o-matic: converts the result of round() to uint8 to fit in struct rgb_color.

* GCC 4.7 warning: narrowing conversion of '(int)(((ColorPickerView*)this)->ColorPickerView::r * 2.55e+2f)'
from 'int' to 'uint8 {aka unsigned char}' inside { } is ill-formed in C++11 [-Werror=narrowing]
This commit is contained in:
Jérôme Duval 2013-04-26 20:11:53 +02:00
parent 5f08555a59
commit cc3fb1f518
2 changed files with 10 additions and 5 deletions

View File

@ -315,7 +315,8 @@ ColorField::SetModeAndValue(selected_color_mode mode, float fixed_value)
R *= 255.0; G *= 255.0; B *= 255.0;
}
rgb_color color = { round(R), round(G), round(B), 255 };
rgb_color color = { (uint8)round(R), (uint8)round(G), (uint8)round(B),
255 };
fBgBitmap[0]->Unlock();

View File

@ -82,7 +82,8 @@ ColorPickerView::layout(BRect frame)
void
ColorPickerView::AttachedToWindow()
{
rgb_color color = { (int)(r * 255), (int)(g * 255), (int)(b * 255), 255 };
rgb_color color = { (uint8)(r * 255), (uint8)(g * 255), (uint8)(b * 255),
255 };
BView::AttachedToWindow();
@ -266,7 +267,8 @@ ColorPickerView::MessageReceived(BMessage *message)
HSV_to_RGB(h, s, v, r, g, b);
}
rgb_color color = { round(r*255), round(g*255), round(b*255), 255 };
rgb_color color = { (uint8)round(r * 255), (uint8)round(g * 255),
(uint8)round(b * 255), 255 };
SetColor(color);
@ -275,7 +277,8 @@ ColorPickerView::MessageReceived(BMessage *message)
case MSG_HEXTEXTCONTROL: {
if (fHexTextControl->TextView()->TextLength()==6) {
const char *string = fHexTextControl->TextView()->Text();
rgb_color color = { hexdec(string, 0), hexdec(string, 2), hexdec(string, 4), 255 };
rgb_color color = { (uint8)hexdec(string, 0), (uint8)hexdec(string, 2),
(uint8)hexdec(string, 4), 255 };
SetColor(color);
}
} break;
@ -449,7 +452,8 @@ ColorPickerView::_UpdateColor(float value, float value1, float value2)
else
HSV_to_RGB(h, s, v, r, g, b);
rgb_color color = { (int)(r*255), (int)(g*255), (int)(b*255), 255 };
rgb_color color = { (uint8)round(r * 255), (uint8)round(g*255),
(uint8)round(b * 255), 255 };
fColorPreview->SetColor(color);
}