1
這是我的第一個問題。
我有,我想改變圖像效果看起來像彩色負片效果的應用如何給UIImage帶來負面的色彩效果
這是我的第一個問題。
我有,我想改變圖像效果看起來像彩色負片效果的應用如何給UIImage帶來負面的色彩效果
它是如此簡單,你必須選擇圖像,並在下面的代碼
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();
製作的方法設置圖像:
- (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;
}
@CocoaMatters可能是他寫的同時你發佈了! – 2012-03-30 10:09:21
@Jennis同意你的評論 – Hiren 2012-03-30 10:15:40
是啊對不起,我寫了它,而你正在寫它 – MCKapur 2012-03-30 10:16:20