Example #1
0
        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);

            Program.Print("-> 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(IOUtils.GetAppDataDir(), "lastnoiseimg.png"));
                img.Composite(noiseImg, CompositeOperator.Multiply);
            }
            else
            {
                img.AddNoise(chosenNoiseType, att);
            }
            img.Write(path);
            PostProcessing(img, path, path);
        }
Example #2
0
        private static void OnFormClose(Object sender, FormClosingEventArgs e)
        {
            string tempImgPath = Path.Combine(IOUtils.GetAppDataDir(), "previewImg.png");

            if (File.Exists(tempImgPath))
            {
                File.Delete(tempImgPath);
            }
        }
Example #3
0
 public static void Init()
 {
     configPath = Path.Combine(IOUtils.GetAppDataDir(), "config.ini");
     if (!File.Exists(configPath))
     {
         File.Create(configPath).Close();
     }
     Reload();
 }
        public static void MedianPreview()
        {
            Program.mainForm.SetMedianVars();
            FileInfo firstImg    = IOUtils.GetFiles()[0];
            string   tempImgPath = Path.Combine(IOUtils.GetAppDataDir(), "medianpreview" + firstImg.Extension);

            if (File.Exists(tempImgPath))
            {
                File.Delete(tempImgPath);
            }
            File.Copy(firstImg.FullName, tempImgPath);
            EffectsUtils.Median(tempImgPath, medianRadiusMin, medianRadiusMax);
            Program.mainForm.PreviewImage(tempImgPath);
        }
        public static void NoisePreview()
        {
            Program.mainForm.SetNoiseVars();
            FileInfo firstImg    = IOUtils.GetFiles()[0];
            string   tempImgPath = Path.Combine(IOUtils.GetAppDataDir(), "noisepreview" + firstImg.Extension);

            if (File.Exists(tempImgPath))
            {
                File.Delete(tempImgPath);
            }
            File.Copy(firstImg.FullName, tempImgPath);
            Random rand = new Random();

            EffectsUtils.AddNoise(tempImgPath, GetNoiseTypeList(), attenMin, attenMax, monochrome);
            Program.mainForm.PreviewImage(tempImgPath);
        }
Example #6
0
        public void PreviewImage(string imgPath)
        {
            MagickImage tempImg = IOUtils.ReadImage(imgPath);

            if (tempImg == null)
            {
                return;
            }
            tempImg.Format = MagickFormat.Png;
            string tempImgPath = Path.Combine(IOUtils.GetAppDataDir(), "previewImg.png");

            tempImg.Write(tempImgPath);
            Program.previewImgPath = tempImgPath;
            var imgForm = new ImagePreviewPopup();

            imgForm.Show();
        }
Example #7
0
        //public static bool currentMipMode;

        public static void Extract(bool overwrite = false)
        {
            GetPaths();

            if (File.Exists(nvCompExePath) && File.Exists(crunchExePath) && !overwrite)
            {
                return;
            }

            File.WriteAllBytes(ddsResPath, Resources.dds);
            ZipFile zip = ZipFile.Read(ddsResPath);

            foreach (ZipEntry e in zip)
            {
                e.Extract(IOUtils.GetAppDataDir(), ExtractExistingFileAction.OverwriteSilently);
            }

            Program.Print("[DdsInterface] Extracted DDS encoding resources to " + ddsResPath);
        }
Example #8
0
        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);

            Program.Print("-> Using blur radius " + blurRad);
            var    result   = blur.Process(blurRad);
            string tempPath = Path.Combine(IOUtils.GetAppDataDir(), "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);
        }
Example #9
0
 static void GetPaths()
 {
     ddsResPath    = Path.Combine(IOUtils.GetAppDataDir(), "dds.zip");
     nvCompExePath = Path.Combine(IOUtils.GetAppDataDir(), "dds", "nvcompress.exe");
     crunchExePath = Path.Combine(IOUtils.GetAppDataDir(), "dds", "crunch.exe");
 }
Example #10
0
 static void GetExePath()
 {
     flifExePath = Path.Combine(IOUtils.GetAppDataDir(), "flif.exe");
 }