コード例 #1
0
        public FrameByteBrightnessContrast(int brigtness, int contrast, bool preProcessFrames, int bitPix)
            : base(preProcessFrames, bitPix)
        {
            m_Brigtness = brigtness;
            m_Contrast  = (sbyte)contrast;

            uint maxPixelValue = bitPix.GetMaxValueForBitPix();

            Trace.Assert(maxPixelValue <= int.MaxValue, "32bit images not supported.");

            Pixelmap image = new Pixelmap((int)maxPixelValue + 1, 1, bitPix, new uint[maxPixelValue + 1], null, null);
            {
                for (int i = 0; i <= maxPixelValue; i++)
                {
                    image[i, 0] = (uint)i;
                }

                BitmapFilter.Brightness(image, m_Brigtness);
                BitmapFilter.Contrast(image, m_Contrast);

                for (int i = 0; i <= maxPixelValue; i++)
                {
                    m_MappedBytes[i] = image[i, 0];
                }
            }
        }
コード例 #2
0
        private void filterbrightness_Click(object sender, EventArgs e)
        {//Brightness Correction
            Parameter dlg = new Parameter();

            dlg.nValue = 0;

            if (DialogResult.OK == dlg.ShowDialog())
            {
                if (BitmapFilter.Brightness(image, dlg.nValue))
                {
                    this.Invalidate();
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// 指定した画像にフィルタをかける
        /// </summary>
        /// <param name="image"></param>
        private bool _SetFilter(Bitmap image)
        {
            if (image == null)
            {
                throw new ArgumentNullException("image");
            }

            switch (filter)
            {
            case ImageFilter.Alpha:
                return(BitmapFilter.Brightness(image, 100));

            case ImageFilter.Mosaic:
                return(BitmapFilter.Pixelate(image, 3, false));

            case ImageFilter.GrayScale:
                return(BitmapFilter.GrayScale(image));

            default:
                return(false);
            }
        }
コード例 #4
0
    private void applyEffectButton_Click(object sender, EventArgs e)
    {
        uploadToSiteButton.Enabled = false;
        uploadToFtpButton.Enabled  = false;
        applyEffectButton.Enabled  = false;
        this.lifeTimer.Enabled     = false;
        try
        {
            Bitmap p        = (Bitmap)Bitmap.FromFile(_FileNameToHandle);
            Bitmap bpicture = new Bitmap(p);

            p.Dispose();
            System.IO.File.Delete(_FileNameToHandle);

            switch (effectsComboBox.SelectedItem.ToString().ToLower())
            {
            case "grayscale":
                if (BitmapFilter.GrayScale(bpicture))
                {
                    bpicture.Save(_FileNameToHandle);
                    utilities.ShowMessage("image grayscaled", "apply effects");
                }
                else
                {
                    utilities.ShowMessage("unable to grayscale", "failed");
                }
                break;

            case "invert":
                if (BitmapFilter.Invert(bpicture))
                {
                    bpicture.Save(_FileNameToHandle);
                    utilities.ShowMessage("image inverted", "apply effects");
                }
                else
                {
                    utilities.ShowMessage("unable to invert", "failed");
                }
                break;

            case "watermark":
                utilities.ShowMessage("not supported", "failed");
                break;

            case "flip":
                utilities.ShowMessage("not supported", "failed");
                break;

            case "brightness":
                if (BitmapFilter.Brightness(bpicture, 40))
                {
                    bpicture.Save(_FileNameToHandle);
                    utilities.ShowMessage("image inverted", "apply effects");
                }
                else
                {
                    utilities.ShowMessage("unable to invert", "failed");
                }
                break;

            default:
                break;
            }

            bpicture.Dispose();
        }
        catch (Exception)
        {
            utilities.ShowMessage("unable to apply effect", "failed");
        }
        this.applyEffectButton.Enabled  = true;
        this.uploadToSiteButton.Enabled = true;
        this.uploadToFtpButton.Enabled  = true;
        this.lifeTimer.Enabled          = true;
    }
コード例 #5
0
        public FImageTest()
        {
            InitializeComponent();

            Invert.OnGetImage += (value) =>
            {
                var image = Properties.Resources.sample.Clone() as Bitmap;
                BitmapFilter.Invert(image);
                return(image);
            };

            Gray.OnGetImage += (value) =>
            {
                var image = Properties.Resources.sample.Clone() as Bitmap;
                BitmapFilter.GrayScale(image);
                return(image);
            };

            Brightness.OnGetImage += (value) =>
            {
                var bright = Properties.Resources.sample.Clone() as Bitmap;
                BitmapFilter.Brightness(bright, value);
                return(bright);
            };

            Contrast.OnGetImage += (value) =>
            {
                var c = Properties.Resources.sample.Clone() as Bitmap;
                BitmapFilter.Contrast(c, (sbyte)value);
                return(c);
            };

            var g = Properties.Resources.sample.Clone() as Bitmap;

            BitmapFilter.Gamma(g, RTracBar.Value, GTracBar.Value, BTracBar.Value);
            GammaRLabel.Text       = RTracBar.Value.ToString();
            GammaGLabel.Text       = GTracBar.Value.ToString();
            GammaBLabel.Text       = BTracBar.Value.ToString();
            Pict5.Image            = g;
            RTracBar.ValueChanged += (_s, _e) =>
            {
                if (Pict5.Image != null)
                {
                    Pict5.Image.Dispose();
                }
                var g2 = Properties.Resources.sample.Clone() as Bitmap;
                BitmapFilter.Gamma(g2, RTracBar.Value, GTracBar.Value, BTracBar.Value);
                Pict5.Image      = g2;
                GammaRLabel.Text = RTracBar.Value.ToString();
            };
            GTracBar.ValueChanged += (_s, _e) =>
            {
                if (Pict5.Image != null)
                {
                    Pict5.Image.Dispose();
                }
                var g2 = Properties.Resources.sample.Clone() as Bitmap;
                BitmapFilter.Gamma(g2, RTracBar.Value, GTracBar.Value, BTracBar.Value);
                Pict5.Image      = g2;
                GammaGLabel.Text = GTracBar.Value.ToString();
            };
            BTracBar.ValueChanged += (_s, _e) =>
            {
                if (Pict5.Image != null)
                {
                    Pict5.Image.Dispose();
                }
                var g2 = Properties.Resources.sample.Clone() as Bitmap;
                BitmapFilter.Gamma(g2, RTracBar.Value, GTracBar.Value, BTracBar.Value);
                Pict5.Image      = g2;
                GammaBLabel.Text = BTracBar.Value.ToString();
            };

            Smooth.OnGetImage += (value) =>
            {
                var image = Properties.Resources.sample.Clone() as Bitmap;
                BitmapFilter.Smooth(image, value);
                return(image);
            };

            Blur.OnGetImage += (value) =>
            {
                var image = Properties.Resources.sample.Clone() as Bitmap;
                BitmapFilter.GaussianBlur(image, value);
                return(image);
            };

            Removal.OnGetImage += (value) =>
            {
                var image = Properties.Resources.sample.Clone() as Bitmap;
                BitmapFilter.MeanRemoval(image, value);
                return(image);
            };

            Ave.OnGetImage += (value) =>
            {
                var image = Properties.Resources.sample.Clone() as Bitmap;
                BitmapFilter.ave(image, value);
                return(image);
            };

            Sharpen.OnGetImage += (value) =>
            {
                var image = Properties.Resources.sample.Clone() as Bitmap;
                BitmapFilter.Sharpen(image, value);
                return(image);
            };

            Emboss.OnGetImage += (value) =>
            {
                var image = Properties.Resources.sample.Clone() as Bitmap;
                BitmapFilter.EmbossLaplacian(image);
                return(image);
            };

            Edge.OnGetImage += (value) =>
            {
                var image = Properties.Resources.sample.Clone() as Bitmap;
                BitmapFilter.EdgeDetectQuick(image);
                return(image);
            };

            Median.OnGetImage += (value) =>
            {
                var image = Properties.Resources.sample.Clone() as Bitmap;
                BitmapFilter.MedianFilter(image);
                return(image);
            };

            Kuwahara.OnGetImage += (value) =>
            {
                var image = Properties.Resources.sample.Clone() as Bitmap;
                BitmapFilter.Kuwahara(image, value);
                return(image);
            };
        }