[英]How erase part of UIImage with an other UIImage
I posted that question and I have not yet found a solution. 我发布了该问题 ,但尚未找到解决方案。
I was wondering if there is a way to use an UIImage
to delete a part of an other UIImage
我想知道是否有一种方法可以使用
UIImage
删除其他UIImage
的一部分
I would use an UIImage
to 'mask' this ugly black background to let a transparency color. 我会使用
UIImage
来“遮盖”这个丑陋的黑色背景,以产生透明色。
Maybe with CGContextAddPath
but I don't know how to use it... 也许与
CGContextAddPath
但我不知道如何使用它...
Regards, 问候,
KL94 KL94
Simple solution 简单的解决方案
- (UIImage*)eraseImage:(UIImage*)img1 WithImage:(UIImage*)img2
{
UIGraphicsBeginImageContext(img1.size);
[img1 drawInRect:CGRectMake(0, 0, img1.size.width, img1.size.height)];
[img2 drawInRect:CGRectMake(0, 0, img2.size.width, img2.size.height) blendMode:kCGBlendModeDestinationIn alpha:1.0];
UIImage* result_img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return result_img;
}
But you better save image as transparent.(Like PNG) 但是您最好将图像另存为透明。(例如PNG)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.