How can I get the pixel data bytes from a Xamarin.IOS UIImage object or from a Xamarin.IOS UIImageView.Image ?
I want to get the pixel data bytes so I can write them to a file, and later use LoadFromData() to load the UIImage.
How can I get the pixel data bytes from a Xamarin.IOS UIImage object or from a Xamarin.IOS UIImageView.Image ?
I want to get the pixel data bytes so I can write them to a file, and later use LoadFromData() to load the UIImage.
You can use this.
using (NSData imageData = image.AsPNG()) {
Byte[] myByteArray = new Byte[imageData.Length];
System.Runtime.InteropServices.Marshal.Copy(imageData.Bytes, myByteArray, 0, Convert.ToInt32(imageData.Length));
}
Source: Converting UIImage to Byte Array