Make sure your every Red Green Blue Alpha component is a valid NSInteger in the range [0 ; 255].
/** Check whether a number might be a valid RGB component.
Range of RGB is [0;255].
@param num Number to test.
@return Returns true if the number is in the range, false otherwise.
*/
+ (BOOL)isValidRgbComponent:(NSInteger)num {
if (num < 0 || num > 255) {
return NO;
}
return YES;
}
Download the ready-for-use source file (.m) of How to check if a number is a valid RGB component
No comments:
Post a Comment