开发者

how to change value of NSColor object into its 8 bit value

I need to convert Value of NSColor object into 8 bit integer value

code :

uint8_t r = (uint32_t)(MIN(1.0f, MAX(0.0f, [[CWhiteBoardController ReturnFillColor] redComponent])) * 0xff);

uint8_t g = (uint32_t)(MIN(1.0f, MAX(0.0f, [[CWhiteBoardController ReturnFillColor] greenComponent])) * 0xff);

uint8_t b = (uint32_t)(MIN(1.0f, MAX(0.0f, [[CWhiteBoardController ReturnFillColor] blueComponent])) * 0xff);

uint8_t a = (uint32_t)(MIN(1.0f, 开发者_运维百科MAX(0.0f, [[CWhiteBoardController ReturnFillColor] alphaComponent])) * 0xff);

uint8_t value = (a << 24) | (r<< 16) | (g << 8) | b;

value that I received is 0.

i am not getting where I am wrong. So anyone help me out plz.


I come to know the problem,actually I need to write

int value = (a << 24) | (r<< 16) | (g << 8) | b; in place of uint8_t value = (a << 24) | (r<< 16) | (g << 8) | b;

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜