答案 0 :(得分:1)
使用图像上下文,您可以在必要的位置绘制原始图像,然后绘制水印,并从上下文中获取新图像。
var originalImage = UIImage.FromBundle("buymore.jpg");
var watermarkImage = UIImage.FromFile("vs.png");
UIGraphics.BeginImageContextWithOptions(originalImage.Size, true, 1.0f);
originalImage.Draw(CGPoint.Empty);
watermarkImage.Draw(new CGRect(new CGPoint(200, 200), watermarkImage.Size));
var processedImage = UIGraphics.GetImageFromCurrentImageContext();
如果您的原始图像和水印图像尺寸相同,则可以使用CIFilter
(CISourceOverCompositing
)将一个图像“叠加”在另一个图像上(假设您的水印具有白色或Alpha背景)由于速度的原因,这是我的首选方法。
UIImage processedimage;
using (var filter = new CISourceOverCompositing())
{
filter.Image = new CIImage(UIImage.FromBundle("vs.png"));
filter.BackgroundImage = new CIImage(UIImage.FromBundle("buymore.jpg"));
processedimage = UIImage.FromImage(filter.OutputImage);
}