2012-03-30 10 views

答えて

6

それはあなたが画像を選択し、以下のコード

UIGraphicsBeginImageContext(renderImage.size); 
CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeCopy); 
[renderImage drawInRect:CGRectMake(0, 0, renderImage.size.width, renderImage.size.height)]; 
CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeDifference); 
CGContextSetFillColorWithColor(UIGraphicsGetCurrentContext(),[UIColor whiteColor].CGColor); 
CGContextFillRect(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, renderImage.size.width, renderImage.size.height)); 
renderImage = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext(); 
4

方法を作るに画像を設定する必要がありますので、簡単です:

- (UIImage *)makeImageNegative:(UIImage *)image{ 
UIGraphicsBeginImageContext(image.size); 
CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeCopy); 
[image drawInRect:CGRectMake(0, 0, image.size.width, image.size.height)]; 
CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeDifference); 
CGContextSetFillColorWithColor(UIGraphicsGetCurrentContext(),[UIColor  whiteColor].CGColor); 
CGContextFillRect(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, image.size.width, image.size.height)); 
UIImage *returnImage = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext();  
return returnImage; 
} 
+0

@ココアマターズ –

+0

@Jennisさんがあなたのコメントに同意します – Hiren

+0

ええ、あなたが書いている間にそれを書いたのはごめんなさい – MCKapur

関連する問題