Exemplo n.º 1
0
        private void btnMode_Click(object sender, EventArgs e)
        {
            if (sender == btnModeNormal)
            {
                sharpenMode = SharpenMode.Normal;
                grpGaussianParams.Enabled = false;
                grpGdiParams.Enabled      = false;

                grpGaussianParams.Visible = false;
                grpGdiParams.Visible      = false;
            }
            else if (sender == btnModeGaussian)
            {
                sharpenMode = SharpenMode.Gaussian;
                grpGaussianParams.Enabled = true;
                grpGdiParams.Enabled      = false;

                grpGaussianParams.Visible = true;
                grpGdiParams.Visible      = false;
            }
            else if (sender == btnModeGdi)
            {
                sharpenMode = SharpenMode.GDI;
                grpGaussianParams.Enabled = false;
                grpGdiParams.Enabled      = true;

                grpGaussianParams.Visible = false;
                grpGdiParams.Visible      = true;
            }
            imgPreview.Image = addin.Apply(thumb);
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="image"></param>
        /// <returns></returns>
        public override Image Apply(Image image)
        {
            GetParams(fm);

            if (!(image is Image))
            {
                return(image);
            }

            Bitmap dst = AddinUtils.CloneImage(image) as Bitmap;

            SharpenMode sharpenMode       = (SharpenMode)Params["SharpenMode"].Value;
            double      gaussianSigma     = (double)Params["GaussianSigma"].Value;
            int         gaussianSize      = (int)Params["GaussianSize"].Value;
            int         gaussianThreshold = (int)Params["GaussianThreshold"].Value;
            float       gdiRatio          = (float)Params["GdiRatio"].Value;
            float       gdiAmount         = (float)Params["GdiAmount"].Value;

            Accord.Imaging.Filters.IFilter filter = null;
            switch (sharpenMode)
            {
            case SharpenMode.Normal:
                filter = new Accord.Imaging.Filters.Sharpen();
                dst    = (filter as Accord.Imaging.Filters.Sharpen).Apply(dst);
                break;

            case SharpenMode.Gaussian:
                filter = new Accord.Imaging.Filters.GaussianSharpen();
                (filter as Accord.Imaging.Filters.GaussianSharpen).Sigma     = gaussianSigma;
                (filter as Accord.Imaging.Filters.GaussianSharpen).Size      = gaussianSize;
                (filter as Accord.Imaging.Filters.GaussianSharpen).Threshold = gaussianThreshold;
                dst = filter.Apply(dst);
                break;

            case SharpenMode.GDI:
                var effect = new SharpenEffect(gdiRatio, gdiAmount);
                dst.ApplyEffect(effect, new Rectangle(0, 0, dst.Width, dst.Height));
                break;
            }
            AddinUtils.CloneExif(image, dst);
            return(dst);
        }