Beispiel #1
0
        public IAsyncAction SaveSnapshotAsync(SnapshotData data)
        {
            byte[] pixeldata = data.data;
            int    pitch     = data.pitch;

            Func <Task> helper = async() =>
            {
                if (this.currentROM == null)
                {
                    return;
                }

                int pixelWidth  = pitch / 4;
                int pixelHeight = (int)pixeldata.Length / pitch;

                IStorageFile file = await this.GetFileUsingExtension(".png", true);

                using (IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.ReadWrite))
                {
                    BitmapEncoder encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, stream);

                    encoder.SetPixelData(
                        BitmapPixelFormat.Rgba8, BitmapAlphaMode.Ignore,
                        (uint)pixelWidth, (uint)pixelHeight, 96.0, 96.0, pixeldata);
                    await encoder.FlushAsync();
                }
                await this.RefreshROMListAsync();
            };

            return(helper().AsAsyncAction());
        }
Beispiel #2
0
        public IAsyncAction SaveScreenshotAsync(SnapshotData data)
        {
            byte[] pixeldata = data.data;
            int    pitch     = data.pitch;

            Func <Task> helper = async() =>
            {
                if (this.currentROM == null)
                {
                    return;
                }

                int pixelWidth  = pitch / 4;
                int pixelHeight = (int)pixeldata.Length / pitch;

                //IStorageFile file = await this.GetFileUsingExtension(".png", true);

                var lib = await StorageLibrary.GetLibraryAsync(KnownLibraryId.Pictures);

                StorageFolder saveFolder = lib.SaveFolder;
                saveFolder = await saveFolder.CreateFolderAsync(Package.Current.DisplayName, CreationCollisionOption.OpenIfExists);

                String filename = String.Format(
                    SCREENSHOT_NAME_TEMPLATE,
                    (this.currentROM.File as StorageFile).DisplayName,
                    DateTime.Now.ToString("dd-MM-yyyy HH-mm-ss")
                    ) + ".png";
                StorageFile file = await saveFolder.CreateFileAsync(filename, CreationCollisionOption.GenerateUniqueName);

                using (IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.ReadWrite))
                {
                    BitmapEncoder encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, stream);

                    encoder.SetPixelData(
                        BitmapPixelFormat.Rgba8, BitmapAlphaMode.Ignore,
                        (uint)pixelWidth, (uint)pixelHeight, 96.0, 96.0, pixeldata);
                    await encoder.FlushAsync();
                }
            };

            return(helper().AsAsyncAction());
        }