我有两张图片。第一个 ( avatar
) 是 640x640,第二个 ( like
) 是 21x20。当我试图先画第二个时,我明白了,但质量非常低。这是代码:
var bounds = targeImageView.Bounds;
CGImageAlphaInfo alphaInfo = CGImageAlphaInfo.PremultipliedLast;
CGColorSpace colorSpaceInfo = CGColorSpace.CreateDeviceRGB ();
CGBitmapContext resultBitmap = new CGBitmapContext (IntPtr.Zero, (int)bounds.Width, (int)bounds.Height, 8, 4 * (int)bounds.Width, colorSpaceInfo, alphaInfo);
resultBitmap.DrawImage (bounds, avatar.CGImage);
var likeY = 0;
var likeX = 0;
var likeHeight = (float)Math.Floor (bounds.Height / 2);
var likeWidth = likeHeight;
resultBitmap.DrawImage (new RectangleF (likeX, likeY, likeWidth, likeHeight), like.CGImage);
targetImageView.Image = UIImage.FromImage (resultBitmap.ToImage ());
这是avatar
同一图像视图上的图片,但没有上面的代码,只是imageView.Image = avatar;
这是相同的,但在绘制之后。