2012-03-31 58 views
0

我想爲我的一個圖片應用程序創建一些很酷的效果。我使用this project來幫助我的過程中不斷變化的曲線,提亮,對比度等更改UIImage曲線時出現大塊顏色?

下面是我使用的代碼:

- (UIImage*)coolifyTheImage { 
UIImage *image = self; 
NSArray *redPoints = [NSArray arrayWithObjects: 
         [NSValue valueWithCGPoint:CGPointMake(0, 43)], 
         [NSValue valueWithCGPoint:CGPointMake(52, 136)], 
         [NSValue valueWithCGPoint:CGPointMake(107, 201)], 
         [NSValue valueWithCGPoint:CGPointMake(255, 255)], 
         nil]; 
NSArray *greenPoints = [NSArray arrayWithObjects: 
         [NSValue valueWithCGPoint:CGPointMake(0, 27)], 
         [NSValue valueWithCGPoint:CGPointMake(54, 86)], 
         [NSValue valueWithCGPoint:CGPointMake(214, 219)], 
         [NSValue valueWithCGPoint:CGPointMake(214, 255)], 
         nil]; 
NSArray *bluePoints = [NSArray arrayWithObjects: 
         [NSValue valueWithCGPoint:CGPointMake(0, 86)], 
         [NSValue valueWithCGPoint:CGPointMake(49, 86)], 
         [NSValue valueWithCGPoint:CGPointMake(122, 100)], 
         [NSValue valueWithCGPoint:CGPointMake(201, 167)], 
         [NSValue valueWithCGPoint:CGPointMake(255, 167)], 
         nil]; 

image = [[[image applyCurve:redPoints toChannel:CurveChannelRed] 
      applyCurve:greenPoints toChannel:CurveChannelGreen] 
     applyCurve:bluePoints toChannel:CurveChannelBlue]; 

return image; 
} 

它精美的作品上的圖像的下半部分,但不頂端。下面是它應該看起來像(從Photoshop採取截圖):

enter image description here

這裏是在Photoshop中的設置:

enter image description here

enter image description here

而這裏的後怎麼弄出來我跑上它的代碼:

enter image description here

在圖片中,有一個巨大的藍色部分,在改變了藍色的曲線後,就是這樣。這是添加曲線的主要功能的問題還是我應該改變點?

請幫忙!

回答

0

這只是一個猜測,但是您確定在綠色曲線和藍色曲線上的最後2個端點之間得到了一條直線段嗎?一般來說,如果您使用與Photoshop相同的方式應用三次曲線,則會在該部分中產生較大的隆起或傾斜。 Photoshop對端點進行了特殊處理,其中的所有內容都是筆直的,但數學運算並不總是如此。

編輯: 事實上,你可以通過測試黑色到白色的漸變,看看結果是什麼。理想情況下,一條掃描線看起來就像你的圖,但如果沒有,那就是問題所在。

+0

我用黑色/白色漸變替換它,它們看起來確切。那麼,在編碼版本(不是photoshop)最頂端有一條小黑線...... – iosfreak 2012-04-01 00:22:16

+0

好的,那麼在你通過曲線傳遞之前還是之後還有其他什麼?通過曲線的順序是否有影響? – user1118321 2012-04-01 00:24:27

+0

之前沒有任何反應。不,訂單無關緊要。 – iosfreak 2012-04-01 00:30:22