Need to make sure value is within 0-255
Posted
by igor
on Stack Overflow
See other posts from Stack Overflow
or by igor
Published on 2010-04-13T23:05:14Z
Indexed on
2010/04/13
23:13 UTC
Read the original article
Hit count: 346
This is probably really easy, but I'm lost on how to "make sure" it is in this range..
So basically we have class Color
and many functions to implement from it.
this function I need is:
Effects: corrects a color value to be within 0-255 inclusive. If value is outside this range, adjusts to either 0 or 255, whichever is closer.
This is what I have so far:
static int correctValue(int value)
{
if(value<0)
value=0;
if(value>255)
value=255;
}
Sorry for such a simple question ;/
© Stack Overflow or respective owner