using System.Drawing;
using System.Drawing.Imaging;

namespace ZionGraphics.Filtering
{
    class BlackAndWhite : IFilter
    {
        public override Bitmap Apply(Bitmap bitmap)
        {
            PixelFormat originalFormat = bitmap.PixelFormat;

            Grayscale grayscale = new Grayscale
            {
                Red = 2125,
                Green = 7154,
                Blue = 721
            };


            bitmap = grayscale.Apply(bitmap);
            bitmap = this.SetPixelFormat(bitmap, PixelFormat.Format8bppIndexed);
            AForge.Imaging.Filters.Threshold filter = new AForge.Imaging.Filters.Threshold();
            return this.SetPixelFormat(filter.Apply(bitmap), originalFormat);
        }
    }
}
