Friday, 15 May 2015

ios - 8 bit color to UIColor -



ios - 8 bit color to UIColor -

i 8 bit color code xml file , need represent text color. example: reddish color is: 255 ( 0xe0), black color is: 0 (0x00); how can init uicolor 8 bit code? expensive way split code in 3 reddish bits, 3 greenish bits , 2 bluish bits , split , multiple , 1 , far. maybe know easy way this?

if color rgb coded 3:3:2 bits, 0xe0 should red, 0xc1 greenish , 0x03 bluish - 0xff not red, white. i'm assuming illustration 0xff beingness reddish wrong. convert 8-bit coded color uicolor have apply bitmask color component , normalize values.

notice 3 bit values have range 0-7, , 2 bit value has range 0-3.

uicolor *mycolor = [uicolor colorwithred:((bitvalue & 0xe0) >> 5) / 7.0f) green:((bitvalue & 0xc1) >> 2) / 7.0f) blue:((bitvalue & 0x03) / 3.0f) alpha:1.0f];

reference uicolor

ios iphone objective-c uicolor

No comments:

Post a Comment