Beispiel #1
0
        private async Task <string> DownloadAdnApplyFilterAndSave()
        {
            IHttpProxyService httpProxyService = new HttpProxyService();
            var storageService = new StorageManagerService();

            var imageColorizationService = new ImageColorizationService(storageService, httpProxyService);

            var localUri = await imageColorizationService.ApplyColorizationFilterAndSaveAsync("https://smartthings-plus.s3.amazonaws.com/category-icons/garden-icon%402x.png");

            return(localUri.AbsoluteUri);
        }
Beispiel #2
0
        private async Task SaveImageAsync()
        {
            var writeableBitmap = (WriteableBitmap)ColorizedImage;

            var storageService = new StorageManagerService();


            StorageFile savefile = await storageService.CreateFileAsync(Guid.NewGuid().ToString(), "png");

            if (savefile == null)
            {
                return;
            }
            IRandomAccessStream stream = await savefile.OpenAsync(FileAccessMode.ReadWrite);

            BitmapEncoder encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId,
                                                                    stream);

            // Get pixels of the WriteableBitmap object
            Stream pixelStream = writeableBitmap.PixelBuffer.AsStream();

            byte[] pixels = new byte[pixelStream.Length];
            await pixelStream.ReadAsync(pixels, 0, pixels.Length);

            encoder.SetPixelData(BitmapPixelFormat.Bgra8,
                                 BitmapAlphaMode.Straight,
                                 (uint)writeableBitmap.PixelWidth,
                                 (uint)writeableBitmap.PixelHeight,
                                 96.0,
                                 96.0,
                                 pixels);
            await encoder.FlushAsync();

            stream.Dispose();

            var fileUri = storageService.GetUriFromFile(savefile);

            SavedImage = fileUri.AbsoluteUri;
        }
Beispiel #3
0
 public MediaPlaylistViewModel(StorageManagerService storageManager)
 {
     StorageManager = storageManager;
 }
 public MediaStorageSelectorViewModel(StorageManagerService storageManagerService)
 {
     StorageManager = storageManagerService;
 }
 public MediaLibraryViewModel(StorageManagerService storageManager)
 {
     StorageManager = storageManager;
 }