예제 #1
0
        public async Task <SoftwareBitmap> readImageFile(string uri)
        {
            KeyValuePair <string, string> PathNamePair = WebManager.convertPathFilenameFromUri(uri);

            StorageFolder storageFolder =
                await ApplicationData.Current.LocalFolder
                .CreateFolderAsync(PathNamePair.Key, CreationCollisionOption.OpenIfExists);

            StorageFile storageFile = await storageFolder.GetFileAsync(PathNamePair.Value);

            using (var stream = await storageFile.OpenAsync(FileAccessMode.Read))
            {
                if (stream.Size == 0)   // Иногда картинки криво сохраняются и совершенно не собираются читаться
                {
                    return(null);
                }
                BitmapDecoder decoder = await BitmapDecoder.CreateAsync(stream);        // Тут этот гад кидает System.Exception при нулевом размере файла

                SoftwareBitmap resultBitmap = await decoder.GetSoftwareBitmapAsync();

                resultBitmap = SoftwareBitmap.Convert(resultBitmap, BitmapPixelFormat.Bgra8, BitmapAlphaMode.Ignore);

                return(resultBitmap);
            }
        }
예제 #2
0
        public async Task <bool> isFileActual(string uri)
        {
            KeyValuePair <string, string> PathNamePair = WebManager.convertPathFilenameFromUri(uri);

            StorageFolder storageFolder =
                await ApplicationData.Current.LocalFolder
                .CreateFolderAsync(PathNamePair.Key, CreationCollisionOption.OpenIfExists);

            if (await storageFolder.TryGetItemAsync(PathNamePair.Value) == null)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
예제 #3
0
        public async Task <bool> createImageFile(string uri, SoftwareBitmap image)
        {
            KeyValuePair <string, string> PathNamePair = WebManager.convertPathFilenameFromUri(uri);

            StorageFolder storageFolder =
                await ApplicationData.Current.LocalFolder
                .CreateFolderAsync(PathNamePair.Key, CreationCollisionOption.OpenIfExists);

            StorageFile storageFile = await storageFolder
                                      .CreateFileAsync(PathNamePair.Value, CreationCollisionOption.ReplaceExisting);

            using (var stream = await storageFile.OpenAsync(FileAccessMode.ReadWrite))
            {
                BitmapEncoder encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.JpegEncoderId, stream);

                encoder.SetSoftwareBitmap(image);

                await encoder.FlushAsync();
            }

            return(true);
        }
예제 #4
0
 public TabunAPIManager()
 {
     webManager = WebManager.Instance;
 }