Reputation: 1459
I am downloading an image from api. This api provides me the bytes of image. Now I want to show this image in gallery (like normal images that is available in gallery). Means when user click the button in app, it should download the image's byte array and the image should open in full screen in gallery.
Like this
Upvotes: 1
Views: 505
Reputation: 6643
If you want to save this to system gallery. You can try to convert your byte array to UIImage
, then save this image:
NSData data = NSData.FromStream(new MemoryStream(imageBytes));
// Or NSData data = NSData.FromArray(imageBytes);
UIImage img = UIImage.LoadFromData(data);
img.SaveToPhotosAlbum((image, error) =>
{
});
On iOS 11, if you want to add images to photo library, do not forget to add the NSPhotoLibraryAddUsageDescription
key in info.plist:
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Our application needs permission to write photos...</string>
Upvotes: 1