public void CreateIconFromPngFilesTest() { var target = new ImageMagicProvider(new ConsoleOutLogger(GetType().Name,LogLevel.All,true,true,true,"yyyy-MM-dd-HH-mm-ss" )); ToDo.Implement(ToDoPriority.Critical, "trondr","Replace hardcoding of svg test file."); var iconInfo = new IconInfo(@"C:\Dev\github-trondr\NMultiTool\src\NMultiTool.Tests\Module\Commands\ConvertSvgToIco\address.svg", new []{16,24,32,48,64,72,128,256}); File.Delete(iconInfo.IconFile.FullName); Assert.IsFalse(File.Exists(iconInfo.IconFile.FullName),"Icon file exists: " + iconInfo.IconFile.FullName); target.CreateIconFromPngFilesResized(iconInfo); Assert.IsTrue(File.Exists(iconInfo.IconFile.FullName),"Icon file does not exists: " + iconInfo.IconFile.FullName); File.Delete(iconInfo.IconFile.FullName); }
public void CreateIconFromPngFilesResized(IconInfo iconInfo) { _logger.InfoFormat("Creating: {0}", iconInfo.IconFile.FullName); var pngFileInfo = new FileInfo(iconInfo.LargestPngFile.FullName); using (var image = new MagickImage(pngFileInfo)) { var defines = new IconDefines(iconInfo.Sizes); var icoFileInfo = new FileInfo(iconInfo.IconFile.FullName); image.Write(icoFileInfo, defines); } }
private bool ConvertSvgToPngs(IconInfo iconInfo, int[] sizes, bool refresh) { var isUpdated = false; //Export from svg to png bool needUpdate = iconInfo.NeedUpdate(); if (needUpdate || refresh) { _inkscapeProvider.ExportSvgToPngs(iconInfo); isUpdated = true; } return isUpdated; }
public void ExportSvgToPngs(IconInfo iconInfo) { foreach (var pngFileInfo in iconInfo.PngFiles) { if (iconInfo.NeedUpdate(pngFileInfo)) { ExportSvgToPng(iconInfo.SvgFile, pngFileInfo); } else { _logger.Info("Png up to date: " + pngFileInfo.FullName); } } }
public void CreateIconFromPngFilesFromSvg(IconInfo iconInfo) { if (iconInfo.NeedUpdate()) { using (var imageCollection = new MagickImageCollection()) { foreach (var iconInfoPngFile in iconInfo.PngFiles) { var image = new MagickImage(iconInfoPngFile.FullName); imageCollection.Add(image); } imageCollection.Write(iconInfo.IconFile.FullName); } } }
public int ConvertSvgToIco(string svgFileName, int[] sizes, bool refresh) { var exitCode = 0; VerifySvgFile(svgFileName); var iconInfo = new IconInfo(svgFileName, sizes); if (refresh || iconInfo.NeedUpdate()) { _inkscapeProvider.ExportSvgToPngs(iconInfo); _imageMagicProvider.CreateIconFromPngFilesFromSvg(iconInfo); } else { _logger.Info("Icon up to date: " + iconInfo.IconFile.FullName); } return exitCode; }