Esempio n. 1
0
        public override bool Execute()
        {
            var splash = MauiSplashScreen[0];

            var img = ResizeImageInfo.Parse(splash);

            Directory.CreateDirectory(IntermediateOutputPath);

            var appTool = new SkiaSharpAppIconTools(img, this);

            Log.LogMessage(MessageImportance.Low, $"Splash Screen: Intermediate Path " + IntermediateOutputPath);

            foreach (var dpi in DpiPath.Windows.SplashScreen)
            {
                Log.LogMessage(MessageImportance.Low, $"Splash Screen: " + dpi);

                var destination = Resizer.GetFileDestination(img, dpi, IntermediateOutputPath);

                Log.LogMessage(MessageImportance.Low, $"Splash Screen Destination: " + destination);

                appTool.Resize(dpi, Path.ChangeExtension(destination, ".png"));
            }

            return(!Log.HasLoggedErrors);
        }
Esempio n. 2
0
        void ProcessAppIcon(SharedImageInfo img, ConcurrentBag <ResizedImageInfo> resizedImages)
        {
            var appIconName = img.OutputName;

            // Generate the actual bitmap app icons themselves
            var appIconDpis = DpiPath.GetAppIconDpis(PlatformType, appIconName);

            Log.LogMessage(MessageImportance.Low, $"App Icon");

            // Apple and Android have special additional files to generate for app icons
            if (PlatformType == "android")
            {
                Log.LogMessage(MessageImportance.Low, $"Android Adaptive Icon Generator");

                appIconName = appIconName.ToLowerInvariant();

                var adaptiveIconGen = new AndroidAdaptiveIconGenerator(img, appIconName, IntermediateOutputPath, this);
                var iconsGenerated  = adaptiveIconGen.Generate();

                foreach (var iconGenerated in iconsGenerated)
                {
                    resizedImages.Add(iconGenerated);
                }
            }
            else if (PlatformType == "ios")
            {
                Log.LogMessage(MessageImportance.Low, $"iOS Icon Assets Generator");

                var appleAssetGen = new AppleIconAssetsGenerator(img, appIconName, IntermediateOutputPath, appIconDpis, this);

                var assetsGenerated = appleAssetGen.Generate();

                foreach (var assetGenerated in assetsGenerated)
                {
                    resizedImages.Add(assetGenerated);
                }
            }

            Log.LogMessage(MessageImportance.Low, $"Generating App Icon Bitmaps for DPIs");

            var appTool = new SkiaSharpAppIconTools(img, this);

            Log.LogMessage(MessageImportance.Low, $"App Icon: Intermediate Path " + IntermediateOutputPath);

            foreach (var dpi in appIconDpis)
            {
                Log.LogMessage(MessageImportance.Low, $"App Icon: " + dpi);

                var destination = Resizer.GetFileDestination(img, dpi, IntermediateOutputPath)
                                  .Replace("{name}", appIconName);

                Log.LogMessage(MessageImportance.Low, $"App Icon Destination: " + destination);

                appTool.Resize(dpi, Path.ChangeExtension(destination, ".png"));
            }
        }
Esempio n. 3
0
        public override bool Execute()
        {
            var splash = MauiSplashScreen[0];

            var colorMetadata = splash.GetMetadata("Color");
            var color         = Utils.ParseColorString(colorMetadata);

            if (color == null && !string.IsNullOrEmpty(colorMetadata))
            {
                Log.LogWarning($"Unable to parse color value '{colorMetadata}' for '{splash.ItemSpec}'.");
            }

            var fileInfo = new FileInfo(splash.GetMetadata("FullPath"));

            if (!fileInfo.Exists)
            {
                throw new FileNotFoundException("Unable to find background file: " + fileInfo.FullName, fileInfo.FullName);
            }

            var img = new ResizeImageInfo
            {
                Filename = fileInfo.FullName,
                Color    = color ?? SKColors.Transparent,
            };

            Directory.CreateDirectory(IntermediateOutputPath);

            var appTool = new SkiaSharpAppIconTools(img, this);

            Log.LogMessage(MessageImportance.Low, $"Splash Screen: Intermediate Path " + IntermediateOutputPath);

            foreach (var dpi in DpiPath.Windows.SplashScreen)
            {
                Log.LogMessage(MessageImportance.Low, $"Splash Screen: " + dpi);

                var destination = Resizer.GetFileDestination(img, dpi, IntermediateOutputPath);

                Log.LogMessage(MessageImportance.Low, $"Splash Screen Destination: " + destination);

                appTool.Resize(dpi, Path.ChangeExtension(destination, ".png"));
            }

            return(!Log.HasLoggedErrors);
        }