private static void BuildIcon(string filePath, int width, int height, byte[] imageBytes, int imageWidth, int imageHeight, int imageX, int imageY) { IoUtils.ForceDelete(filePath); using (var fs = new FileStream(filePath, FileMode.Create)) { var outputBitmap = new Bitmap(width, height); var tempImage = ImageUtils.ByteArrayToImage(imageBytes); tempImage = ImageUtils.ScaleImage(tempImage, imageWidth, imageHeight); using (var graphics = Graphics.FromImage(outputBitmap)) { graphics.CompositingMode = CompositingMode.SourceCopy; graphics.CompositingQuality = CompositingQuality.HighQuality; graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; graphics.SmoothingMode = SmoothingMode.HighQuality; graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; graphics.DrawImage(tempImage, new PointF(imageX, imageY)); } outputBitmap.Save(fs, ImageFormat.Png); outputBitmap.Dispose(); tempImage.Dispose(); } }
public void SaveConfig(string filePath) { if (string.IsNullOrEmpty(filePath)) { return; } var dirPath = Path.GetDirectoryName(filePath); if (dirPath != null && !Directory.Exists(dirPath)) { Directory.CreateDirectory(dirPath); } IoUtils.ForceDelete(filePath); using (var xmlFile = new FileStream(filePath, FileMode.Create)) { var xmlSerializer = new XmlSerializer(typeof(Config)); xmlSerializer.Serialize(xmlFile, this); } }
private static void BuildIcon(string filePath, int width, int height, byte[] imageBytes, int imageWidth, int imageHeight, int imageX, int imageY, Enums.ColorSelection tileIconifierColorSelection, string backgroundColor) { IoUtils.ForceDelete(filePath); using (var fs = new FileStream(filePath, FileMode.Create)) { var outputBitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb); var tempImage = ImageUtils.ByteArrayToImage(imageBytes); tempImage = ImageUtils.ScaleImage(tempImage, imageWidth, imageHeight); using (var graphics = Graphics.FromImage(outputBitmap)) { if (Config.StartMenuUpgradeEnabled && tileIconifierColorSelection != Enums.ColorSelection.Default) { var color = ColorUtils.HexOrNameToColor(backgroundColor); graphics.Clear(color); } else { graphics.CompositingMode = CompositingMode.SourceCopy; } graphics.CompositingQuality = CompositingQuality.HighQuality; graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; graphics.SmoothingMode = SmoothingMode.HighQuality; graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; graphics.DrawImage(tempImage, new PointF(imageX, imageY)); } outputBitmap.Save(fs, ImageFormat.Png); outputBitmap.Dispose(); tempImage.Dispose(); } }
public void SaveSmallIconMetadata(string filePath) { IoUtils.ForceDelete(filePath); CurrentState.SmallImage.Save(filePath); }