我有这个代码
private static UIImage Copy(UIImage self) {
var inImage = self.CGImage;
var width = inImage.Width;
var height = inImage.Height;
var bits = inImage.BitsPerComponent;
var bitsPerRow = inImage.BytesPerRow;
var colorSpace = inImage.ColorSpace;
var alphaInfo = inImage.AlphaInfo;
using (var jpeg = UIImage.FromImage (inImage).AsJPEG ()) {
var bytes = new Byte[jpeg.Length];
System.Runtime.InteropServices.Marshal.Copy (jpeg.Bytes, bytes, 0, Convert.ToInt32 (jpeg.Length));
using (CGBitmapContext ctx = new CGBitmapContext (bytes, width, height, bits, bitsPerRow, colorSpace, alphaInfo)) {
return UIImage.FromImage (ctx.ToImage ());
}
}
}
我只是从原始图像中获取字节数组并使用 CGBitmapContext 创建图像,但结果是: