public static void AddNoise(string path, List <NoiseType> noiseTypes, double attenMin, double attenMax, bool monoChrome) { if (noiseTypes.Count < 1) { return; } MagickImage img = IOUtils.ReadImage(path); if (img == null) { return; } NoiseType chosenNoiseType = GetRandomNoiseType(noiseTypes); PreProcessing(path, "- Noise Type: " + chosenNoiseType.ToString()); Random rand = new Random(); double att = (double)rand.Next((int)attenMin, (int)attenMax + 1); Logger.Log("-> Using attenuate factor " + att); if (monoChrome) { MagickImage noiseImg = new MagickImage(MagickColors.White, img.Width, img.Height); noiseImg.AddNoise(chosenNoiseType, att); noiseImg.ColorSpace = ColorSpace.LinearGray; noiseImg.Write(Path.Combine(Paths.GetDataPath(), "lastnoiseimg.png")); img.Composite(noiseImg, CompositeOperator.Multiply); } else { img.AddNoise(chosenNoiseType, att); } img.Write(path); PostProcessing(img, path, path); }
private static void OnFormClose(Object sender, FormClosingEventArgs e) { string tempImgPath = Path.Combine(Paths.GetDataPath(), "previewImg.png"); if (File.Exists(tempImgPath)) { File.Delete(tempImgPath); } }
public static void Blur(string path, int radiusMin, int radiusMax) { PreProcessing(path); MagickImage sourceImg = new MagickImage(path); var image = Image.FromFile(path); var blur = new SuperfastBlur.GaussianBlur(image as Bitmap); Random rand = new Random(); int blurRad = rand.Next(radiusMin, radiusMax + 1); Logger.Log("-> Using blur radius " + blurRad); var result = blur.Process(blurRad); string tempPath = Path.Combine(Paths.GetDataPath(), "blur-out.png"); result.Save(tempPath, ImageFormat.Png); result.Dispose(); image.Dispose(); MagickImage outImg = new MagickImage(tempPath); outImg.Format = sourceImg.Format; outImg.Write(path); PostProcessing(null, path, path); }
public static void PreviewImage(string imgPath, bool run = false) { MagickImage tempImg = IOUtils.ReadImage(imgPath); if (tempImg == null) { return; } tempImg.Format = MagickFormat.Png; string tempImgPath = Path.Combine(Paths.GetDataPath(), "previewImg.png"); tempImg.Write(tempImgPath); tempImg.Dispose(); previewImgPath = tempImgPath; if (run) { Application.Run(new ImagePreviewPopup()); } else { new ImagePreviewPopup().Show(); } }
static string GetExePath() { return(Path.Combine(Paths.GetDataPath(), "runtimes", "flif", "flif.exe")); }
static void GetPaths() { nvCompExePath = Path.Combine(Paths.GetDataPath(), "runtimes", "dds", "nvcompress.exe"); crunchExePath = Path.Combine(Paths.GetDataPath(), "runtimes", "dds", "crunch.exe"); texconvExePath = Path.Combine(Paths.GetDataPath(), "runtimes", "dds", "texconv.exe"); }