2012-02-06 17 views
0

我通過RGB值255-140-0傳遞RGB值到CGContextSetRGBStrokeColor不是爲橙色正常工作

CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(),紅,綠,藍,1.0);對我來說它的繪畫黃色!不是橙色。

我嘗試測試一些255以下的隨機值到CGContextSetRGBStokeColor,它向我繪製白色。我不知道爲什麼這樣!

@ALL任何一個可以建議我在這個問題上

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{ 


    UITouch *touch = [touches anyObject]; 
    CGPoint currentPoint = [touch locationInView:drawImage]; 
    currentPoint.y -= 20; 
    UIGraphicsBeginImageContext(drawImage.frame.size); 
    [drawImage.image drawInRect:CGRectMake(0, 0, drawImage.frame.size.width, drawImage.frame.size.height)]; 
    CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound); 
    CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 5.0); 
    CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), red, green, blue, 1.0); 

    CGContextBeginPath(UIGraphicsGetCurrentContext()); 
    CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y); 
    CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y); 
    CGContextStrokePath(UIGraphicsGetCurrentContext()); 
    drawImage.image = UIGraphicsGetImageFromCurrentImageContext(); 
    UIGraphicsEndImageContext(); 
} 

回答

2

望着documentation,它指出,通過對紅,綠和藍色的值是彩車

The graphics context for which to set the current stroke color. 
red 
The red intensity value for the color to set. The DeviceRGB color space permits the specification of a value ranging from 0.0 (zero intensity) to 1.0 (full intensity). 
green 
The green intensity value for the color to set. The DeviceRGB color space permits the specification of a value ranging from 0.0 (zero intensity) to 1.0 (full intensity). 
blue 
The blue intensity value for the color to set. The DeviceRGB color space permits the specification of a value ranging from 0.0 (zero intensity) to 1.0 (full intensity). 
alpha 
A value that specifies the opacity level. Values can range from 0.0 (transparent) to 1.0 (opaque). Values outside this range are clipped to 0.0 or 1.0. 

所以值有介於0.0和1.0之間。你輸入的數字太大了。將來,請先查看文檔。

+0

Nick Bull謝謝你!我將這些值與255分開,對我的工作非常感謝! – user905582 2012-02-06 14:48:35