using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Xml;
using ImageBlockz.Operations.InOut;
using ImageBlockz.Api;
using ImageBlockz.Core;
using AForge.Imaging.Filters;

namespace ImageBlockz.Operations.Convolutions
{
    public class Edges : AbstractOperation
    {
        public static readonly string OperationName = typeof(Edges).FullName;

        public Edges()
            : base(OperationType.Filter)
        {
        
        }

        public override Bitmap Do(Bitmap bmp)
        {
            int[,] kernel = {
            {  -1,  0,  1},
            {  -1,  0,  1},
            {  -1,  0,  1} };
            AForge.Imaging.Filters.Convolution filter = new AForge.Imaging.Filters.Convolution(kernel);
            bmp = filter.Apply(bmp);

            int[,] kernel2 = {
            {  1,  1,  1},
            {  0,  0,  0},
            {  -1,  1, -1} };
            filter = new AForge.Imaging.Filters.Convolution(kernel2);
            return filter.Apply(bmp);
        }

        public override XmlNode ToXml(XmlDocument xmlDoc)
        {
            return xmlDoc.CreateElement(OperationName);
        }

        public override void FromXml(XmlNode node)
        {
           
        }

        public override string GetFormattedName()
        {
            return "Edges";
        }

        public override string GetInfo()
        {
            return "No parameters.";
        }
    }
}
