Beispiel #1
0
        public unsafe override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode)
        {
            int       blurRadius = GetFieldValueAsInt(FieldType.BLUR_RADIUS);
            Rectangle applyRect  = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);

            if (applyRect.Width == 0 || applyRect.Height == 0)
            {
                return;
            }
            GraphicsState state = graphics.Save();

            if (Invert)
            {
                graphics.SetClip(applyRect);
                graphics.ExcludeClip(rect);
            }
            if (GDIplus.isBlurPossible(blurRadius))
            {
                GDIplus.DrawWithBlur(graphics, applyBitmap, applyRect, null, null, blurRadius, false);
            }
            else
            {
                using (IFastBitmap fastBitmap = FastBitmap.CreateCloneOf(applyBitmap, applyRect))
                {
                    ImageHelper.ApplyBoxBlur(fastBitmap, blurRadius);
                    fastBitmap.DrawTo(graphics, applyRect);
                }
            }
            graphics.Restore(state);
            return;
        }