Example #1
0
        public async Task LoadColoringPageFilesAsync()
        {
            var imageName = Settings.ColoringImageName +
                            Tools.GetResolutionTypeAsString(Settings.ColoringResolutionType);

            TemplateImage = await ColoringBookBitmapLibraryImage.LoadImageFromFileAsync(
                await Settings.GetLibraryImageLocationAsync(),
                await Settings.GetLibraryImagePreprocessingLocationAsync(),
                imageName + Tools.GetResourceString("FileType/png"),
                imageName + Tools.GetResourceString("FileType/preprocessing"));
            await LoadInkAsync(Settings.ColoringDirectory);
        }
Example #2
0
        private async Task InitializeAsync(string coloringName, string templateImageName)
        {
            Settings = new ColoringBookColoringSettings(coloringName, templateImageName, Tools.ResolutionType);
            await Settings.SaveSettingsToFileAsync();

            var imageName = Settings.ColoringImageName +
                            Tools.GetResolutionTypeAsString(Settings.ColoringResolutionType);

            TemplateImage = await ColoringBookBitmapLibraryImage.LoadImageFromFileAsync(
                await Settings.GetLibraryImageLocationAsync(),
                await Settings.GetLibraryImagePreprocessingLocationAsync(),
                imageName + Tools.GetResourceString("FileType/png"),
                imageName + Tools.GetResourceString("FileType/preprocessing"));

            InkStrokeContainer = new InkStrokeContainer();
        }
        public static async Task <ColoringBookBitmapLibraryImage> LoadImageFromFileAsync(StorageFolder imageLocation,
                                                                                         StorageFolder preprocessingLocation, string imageName, string preprocessingName)
        {
            var templateImageObj = new ColoringBookBitmapLibraryImage(imageLocation, imageName);

            var imgfile = await Tools.GetFileAsync(imageLocation, imageName);

            var preprocessingfile = await Tools.GetFileAsync(preprocessingLocation, preprocessingName);

            // Do not load preprocessing file now, just check that it exists.
            if (imgfile == null)
            {
                throw new FileNotFoundException("Coloring image file not found");
            }

            if (preprocessingfile == null)
            {
                throw new FileNotFoundException("Coloring image preprocessing not found");
            }

            using (var fileStream = await imgfile.OpenAsync(FileAccessMode.Read))
            {
                templateImageObj.LibraryBitmapImage = new BitmapImage();

                var dec = await BitmapDecoder.CreateAsync(fileStream);

                templateImageObj.LibraryBitmapImage.DecodePixelWidth = (int)dec.PixelWidth;

                var data = await dec.GetPixelDataAsync();

                templateImageObj.BitmapImageBytes = data.DetachPixelData();
                templateImageObj.Width            = dec.PixelWidth;
                templateImageObj.Height           = dec.PixelHeight;

                await templateImageObj.LibraryBitmapImage.SetSourceAsync(fileStream);
            }

            return(templateImageObj);
        }