iOS RGB 颜色不正确?
UIGraphicsBeginImageContext(self.view.frame.size);
[drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 8.0);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 135.0,213.0,0.0,1.0);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(),currentPoint.x, currentPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
我画一条线使用 RGB(135,213,0),RGB(135,213,0) 应该是 绿色。但是iOS显示黄线!!为什么?
UIGraphicsBeginImageContext(self.view.frame.size);
[drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 8.0);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 135.0,213.0,0.0,1.0);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(),currentPoint.x, currentPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
I am draw a line use RGB(135,213,0),RGB(135,213,0) should be green. but iOS display yellow line!! why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的值需要在 [0,1] 范围内。因此您需要将每个值除以 255。
You need to have the values in the range of [0,1]. Therefore you need to divide each value by 255.
将每个值除以 255 即 RGB(135/255,213/255,0)
Divide each value by 255 ie RGB(135/255,213/255,0)
最大值为 1.0,将每个参数除以 255.0
max value is 1.0, divide each argument by 255.0