Ejemplo n.º 1
0
        public Task <IBitmap> Load(Stream sourceStream, float?desiredWidth, float?desiredHeight)
        {
            var data = NSData.FromStream(sourceStream);

            var tcs = new TaskCompletionSource <IBitmap>();

            UIApplication.SharedApplication.InvokeOnMainThread(() => {
                try {
#if UIKIT
                    tcs.TrySetResult(new CocoaBitmap(UIImage.LoadFromData(data)));
#else
                    tcs.TrySetResult(new CocoaBitmap(new UIImage(data)));
#endif
                } catch (Exception ex) {
                    tcs.TrySetException(ex);
                }
            });
            return(tcs.Task);
        }