예제 #1
0
        public static async Task <BandImage> FromStreamAsync(Stream stream)
        {
#if __ANDROID__
            var image = await BitmapFactory.DecodeStreamAsync(stream);

            return(FromBitmap(image));
#elif __IOS__
            var image = await Task.Run(() =>
            {
                using (var data = NSData.FromStream(stream))
                {
                    return(NativeBitmap.LoadFromData(data));
                }
            });

            return(FromUIImage(image));
#elif WINDOWS_PHONE_APP
            using (var fileStream = stream.AsRandomAccessStream())
            {
                var bitmap = new NativeBitmap(1, 1);
                await bitmap.SetSourceAsync(fileStream);

                return(FromWriteableBitmap(bitmap));
            }
#else // PORTABLE
            return(null);
#endif
        }
        public static async Task<BandImage> FromStreamAsync(Stream stream)
        {
#if __ANDROID__
            var image = await BitmapFactory.DecodeStreamAsync(stream);
            return FromBitmap(image);
#elif __IOS__
            var image = await Task.Run(() =>
            {
                using (var data = NSData.FromStream(stream))
                {
                    return NativeBitmap.LoadFromData(data);
                }
            });
            return FromUIImage(image);
#elif WINDOWS_PHONE_APP
            using (var fileStream = stream.AsRandomAccessStream())
            {
                var bitmap = new NativeBitmap(1, 1);
                await bitmap.SetSourceAsync(fileStream);
                return FromWriteableBitmap(bitmap);
            }
#else // PORTABLE
            return null;
#endif
        }