We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Color.GetR() returns -1 instead of 255 for RED

Hi,

Not sure why Color.getR() / getG() / getB() return -1 when the RGB value is 255, even for system defined color.

Color red = Color.getRed();
int r = red.getR(); //it returns -1 which is supposed to be 255.

or

Color red = Color.fromArgb(255, 0, 0);
int r = red.getR(); //it returns -1 which is supposed to be 255.

Could you please check?

Thanks,
Hui Chen

@huichen,
We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSJAVA-43136 – Color.GetR() returns -1 instead of 255 for RED

@huichen,
For Apis of Color.getR()/getG()/getB(), the returned type is defined as byte, for java program its value range is just -128~127. If you need to get the positive int value, you should use code like (Color.getR() & 0xFF). We cannot change the returned value type for those APIs because it may cause corruptions for other users’ existing applications.