public override Image ApplyEffect(Image img)
        {
            ColorMatrix matrix = ColorMatrixMgr.IdentityMatrix;

            matrix[4, 0] = matrix[4, 1] = matrix[4, 2] = -1.0f;

            using (Image blackImage = ColorMatrixMgr.ApplyColorMatrix(img, matrix))
                using (Image shadow = Blur.ApplyBlur((Bitmap)blackImage, radius, true))
                    using (Image shadow2 = ColorMatrixMgr.ApplyColorMatrix(shadow, ColorMatrixMgr.Alpha(transparency, 0)))
                    {
                        Bitmap result = new Bitmap(shadow.Width + Math.Abs(offsetX), shadow.Height + Math.Abs(offsetY));

                        using (Graphics g = Graphics.FromImage(result))
                        {
                            Rectangle shadowRect = new Rectangle(0, 0, shadow.Width, shadow.Height);
                            Rectangle imageRect  = new Rectangle(radius, radius, img.Width, img.Height);

                            if (offsetX < 0)
                            {
                                imageRect.X += -offsetX + Math.Min(radius, -offsetX);
                            }
                            else
                            {
                                imageRect.X  = Math.Max(0, radius - offsetX);
                                shadowRect.X = offsetX;
                            }

                            if (offsetY < 0)
                            {
                                imageRect.Y += -offsetY + Math.Min(radius, -offsetX);
                            }
                            else
                            {
                                imageRect.Y  = Math.Max(0, radius - offsetY);
                                shadowRect.Y = offsetY;
                            }

                            g.DrawImage(shadow2, shadowRect);
                            g.DrawImage(img, imageRect);
                        }

                        return(result);
                    }
        }
Example #2
0
 public override Image ApplyEffect(Image img)
 {
     return(ColorMatrixMgr.ApplyColorMatrix(img, ColorMatrixMgr.Alpha(percentage, addition)));
 }
 public override Image ApplyEffect(Image img)
 {
     return(ColorMatrixMgr.ApplyColorMatrix(img, ColorMatrixMgr.Hue(angle)));
 }
 public override Image ApplyEffect(Image img)
 {
     return(ColorMatrixMgr.ApplyColorMatrix(img, ColorMatrixMgr.Saturation(SaturationValue)));
 }
Example #5
0
 public override Image ApplyEffect(Image img)
 {
     return(ColorMatrixMgr.ApplyColorMatrix(img, ColorMatrixMgr.Grayscale()));
 }
Example #6
0
 public override Image ApplyEffect(Image img)
 {
     return(ColorMatrixMgr.ApplyColorMatrix(img, ColorMatrixMgr.Brightness(BrightnessValue)));
 }
 public override Image ApplyEffect(Image img)
 {
     return(ColorMatrixMgr.ApplyColorMatrix(img, ColorMatrixMgr.Contrast(ContrastValue)));
 }
Example #8
0
 public override Image ApplyEffect(Image img)
 {
     return(ColorMatrixMgr.ApplyColorMatrix(img, ColorMatrixMgr.Colorize(color, percentage)));
 }