public AndroidAdaptiveIconGenerator(SharedImageInfo info, string appIconName, string intermediateOutputPath, ILogger logger) { Info = info; Logger = logger; IntermediateOutputPath = intermediateOutputPath; AppIconName = appIconName; }
public AppleIconAssetsGenerator(SharedImageInfo info, string appIconName, string intermediateOutputPath, DpiPath[] dpis, ILogger logger) { Info = info; Logger = logger; IntermediateOutputPath = intermediateOutputPath; AppIconName = appIconName; Dpis = dpis; }
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")); } }
void ProcessImageCopy(SharedImageInfo img, DpiPath originalScaleDpi, ConcurrentBag <ResizedImageInfo> resizedImages) { var resizer = new Resizer(img, IntermediateOutputPath, this); Log.LogMessage(MessageImportance.Low, $"Copying {img.Filename}"); var r = resizer.CopyFile(originalScaleDpi, InputsFile, PlatformType.ToLower().Equals("android")); resizedImages.Add(r); Log.LogMessage(MessageImportance.Low, $"Copied {img.Filename}"); }
void ProcessImageResize(SharedImageInfo img, DpiPath[] dpis, ConcurrentBag <ResizedImageInfo> resizedImages) { var resizer = new Resizer(img, IntermediateOutputPath, this); foreach (var dpi in dpis) { Log.LogMessage(MessageImportance.Low, $"Resizing {img.Filename}"); var r = resizer.Resize(dpi, InputsFile); resizedImages.Add(r); Log.LogMessage(MessageImportance.Low, $"Resized {img.Filename}"); } }
public static string GetFileDestination(SharedImageInfo info, DpiPath dpi, string intermediateOutputPath) { var fullIntermediateOutputPath = new DirectoryInfo(intermediateOutputPath); var destination = Path.Combine(fullIntermediateOutputPath.FullName, dpi.Path, info.OutputName + dpi.FileSuffix + info.OutputExtension); var fileInfo = new FileInfo(destination); if (!fileInfo.Directory.Exists) { fileInfo.Directory.Create(); } return(destination); }
public SkiaSharpAppIconTools(SharedImageInfo info, ILogger logger) { Info = info; Logger = logger; AppIconName = info.OutputName; hasForeground = File.Exists(info.ForegroundFilename); if (hasForeground) { foregroundTools = SkiaSharpTools.Create(info.ForegroundIsVector, info.ForegroundFilename, null, info.TintColor, logger); } backgroundTools = SkiaSharpTools.Create(info.IsVector, info.Filename, null, null, logger); backgroundOriginalSize = backgroundTools.GetOriginalSize(); if (hasForeground) { foregroundOriginalSize = foregroundTools.GetOriginalSize(); } }
public SkiaSharpBitmapTools(SharedImageInfo info, ILogger logger) : this(info.Filename, info.BaseSize, info.TintColor, logger) { }
public Resizer(SharedImageInfo info, string intermediateOutputPath, ILogger logger) { Info = info; Logger = logger; IntermediateOutputPath = intermediateOutputPath; }
List <SharedImageInfo> ParseImageTaskItems(ITaskItem[] images) { var r = new List <SharedImageInfo>(); if (images == null) { return(r); } foreach (var image in images) { var info = new SharedImageInfo(); var fileInfo = new FileInfo(image.GetMetadata("FullPath")); info.Filename = fileInfo.FullName; info.Alias = image.GetMetadata("Link"); info.BaseSize = Utils.ParseSizeString(image.GetMetadata("BaseSize")); if (bool.TryParse(image.GetMetadata("Resize"), out var rz)) { info.Resize = rz; } info.TintColor = Utils.ParseColorString(image.GetMetadata("TintColor")); if (bool.TryParse(image.GetMetadata("IsAppIcon"), out var iai)) { info.IsAppIcon = iai; } if (float.TryParse(image.GetMetadata("ForegroundScale"), out var fsc)) { info.ForegroundScale = fsc; } var fgFile = image.GetMetadata("ForegroundFile"); if (!string.IsNullOrEmpty(fgFile)) { var bgFileInfo = new FileInfo(info.Filename); if (!Path.IsPathRooted(fgFile)) { fgFile = Path.Combine(bgFileInfo.Directory.FullName, fgFile); } else { fgFile = Path.GetFullPath(fgFile); } Logger.Log($"AppIcon Foreground: " + fgFile); if (File.Exists(fgFile)) { info.ForegroundFilename = fgFile; } } // TODO: // - Parse out custom DPI's r.Add(info); } return(r); }
List <SharedImageInfo> ParseImageTaskItems(ITaskItem[] images) { var r = new List <SharedImageInfo>(); if (images == null) { return(r); } foreach (var image in images) { var info = new SharedImageInfo(); var fileInfo = new FileInfo(image.GetMetadata("FullPath")); if (!fileInfo.Exists) { throw new FileNotFoundException("Unable to find background file: " + fileInfo.FullName, fileInfo.FullName); } info.Filename = fileInfo.FullName; info.Alias = image.GetMetadata("Link"); info.BaseSize = Utils.ParseSizeString(image.GetMetadata("BaseSize")); if (bool.TryParse(image.GetMetadata("Resize"), out var rz)) { info.Resize = rz; } info.TintColor = Utils.ParseColorString(image.GetMetadata("TintColor")); if (bool.TryParse(image.GetMetadata("IsAppIcon"), out var iai)) { info.IsAppIcon = iai; } if (float.TryParse(image.GetMetadata("ForegroundScale"), out var fsc)) { info.ForegroundScale = fsc; } var fgFile = image.GetMetadata("ForegroundFile"); if (!string.IsNullOrEmpty(fgFile)) { var fgFileInfo = new FileInfo(fgFile); if (!fgFileInfo.Exists) { throw new FileNotFoundException("Unable to find foreground file: " + fgFileInfo.FullName, fgFileInfo.FullName); } info.ForegroundFilename = fgFileInfo.FullName; } // TODO: // - Parse out custom DPI's r.Add(info); } return(r); }