コード例 #1
0
ファイル: cipEffects.cs プロジェクト: kyzmitch/Cip
        /// <summary>
        /// Processing without background worker.
        /// </summary>
        public override Raster ProcessWithoutWorker(Raster rOriginal)
        {
            int width = rOriginal.Width;
            int height = rOriginal.Height;
            Raster raster = new Raster(width, height);

            byte threshold = (byte)(this.lightThreshold * 255);
            VectorRgb color;
            //bright pass
            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    color = rOriginal[i, j];
                    if (color.R > threshold || color.G > threshold || color.B > threshold)
                        raster[i, j] = color;
                    else
                        raster[i, j] = new VectorRgb(0, 0, 0);
                }
            }
            //blur
            SmoothingFilter filterSmoothing = new SmoothingFilter(ColorSpaceMode.RGB, this.blurRadius);
            raster = filterSmoothing.ProcessWithoutWorker(raster);
            //processing (mixing original raster with blured light raster)
            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    color = raster[i, j] * this.bloomBlendFactor;
                    raster[i, j] = rOriginal[i, j] + color;
                }
            }
            return raster;
        }
コード例 #2
0
ファイル: FormSmoothing.cs プロジェクト: kyzmitch/Cip
 public void ReDraw()
 {
     this.Check();
     switch (sMode)
     {
         case SmoothingMode.Smoothing:
             {
                 SmoothingFilter filter = new Cip.Filters.SmoothingFilter(this.mode, this.radius);
                 Raster result = filter.ProcessWithoutWorker(this.raster);
                 result.ShowFilter(this.pBoxPreview);
                 break;
             }
         case SmoothingMode.Blur:
             {
                 LinearFilter filter = Cip.Filters.LinearFilter.SimpleBlurFilter(this.radius);
                 Raster result = filter.ProcessWithoutWorker(this.raster);
                 result.ShowFilter(this.pBoxPreview);
                 break;
             }
         case SmoothingMode.GaussianBlur:
             {
                 LinearFilter filter = Cip.Filters.LinearFilter.GaussianBlurFilter(this.radius, this.sigma);
                 Raster result = filter.ProcessWithoutWorker(this.raster);
                 result.ShowFilter(this.pBoxPreview);
                 break;
             }
     }
 }