Example #1
0
        static void Main(string[] args)
        {
            PictureProvider pictureProvider = new PictureProvider();
            IPicture        picOrig         = pictureProvider.GetPicture("jac.jpg");

            FilterNegative negative = new FilterNegative();
            //https://twitter.com/POOUCU?lang=en&lang=en
            FilterTwitterPublish twitterPublish = new FilterTwitterPublish();
            FilterCognitive      faceRecog      = new FilterCognitive();

            IConvolutionMatrix matrix    = new BlurConvolutionMatrix();
            FilterConvolution  blurConvo = new FilterConvolution(matrix);

            PipeNull pipeEnd = new PipeNull();
            //PipeSerial pipe32 = new PipeSerial(negative,pipeEnd);
            PipeSerial      pipe22 = new PipeSerial(negative, pipeEnd);
            PipeSerial      pipe21 = new PipeSerial(twitterPublish, pipeEnd);
            PipeConditional pipe1  = new PipeConditional(faceRecog, pipe21, pipe22);

            pictureProvider.SavePicture(pipe1.Send(picOrig), "jacFiltrado.jpg");
        }
        static void Main(string[] args)
        {
            string          Shrek     = @"..\..\SmilingShrek.jpg";
            string          NewShrek  = @"..\..\" + Guid.NewGuid().ToString() + ".jpg";
            string          NewShrek2 = @"..\..\" + Guid.NewGuid().ToString() + ".jpg";
            string          NewShrek3 = @"..\..\" + Guid.NewGuid().ToString() + ".jpg";
            string          NewShrek4 = @"..\..\" + Guid.NewGuid().ToString() + ".jpg";
            PictureProvider p         = new PictureProvider();
            IPicture        pic       = p.GetPicture(Shrek);

            // Conjunto de filtros a utilizar en las 5 partes
            IFilter               GrayFilter     = new FilterGreyscale();
            IFilter               NegativeFilter = new FilterNegative();
            IFilter               Save           = new FilterSaver(NewShrek);
            IFilter               Tweet1         = new FilterTwitterPublish("Shrek is love, Shrek is life.", NewShrek);
            IFilter               Tweet2         = new FilterTwitterPublish("Shrek is love, Shrek is life.", NewShrek2);
            IFilter               Tweet3         = new FilterTwitterPublish("Shrek is love, Shrek is life.", NewShrek3);
            IFilter               Tweet4         = new FilterTwitterPublish("Shrek is love, Shrek is life.", NewShrek4);
            IConditionFilter      FaceCondition  = new FilterSearchFace(Shrek);
            FilterBlurConvolution LightBlur      = new FilterBlurConvolution();

            //PipeNull
            IPipe NullPipe = new PipeNull();

            // Parte1
            PipeSerial pipe2 = new PipeSerial(NegativeFilter, NullPipe);
            IPipe      pipe1 = new PipeSerial(GrayFilter, pipe2);

            pipe1.Send(pic);

            // Parte 2 (guardar una copia de la imagen cada vez que se le aplica un filtro)
            IPipe FourthPipe2 = new PipeSerial(Save, NullPipe);
            IPipe ThirdPipe2  = new PipeSerial(NegativeFilter, FourthPipe2);
            IPipe SecondPipe2 = new PipeSerial(Save, ThirdPipe2);

            IPipe InitialPipe2 = new PipeSerial(GrayFilter, SecondPipe2);

            InitialPipe2.Send(pic);

            // Parte 3
            IPipe FifthPipe3  = new PipeSerial(Tweet2, NullPipe);
            IPipe FourthPipe3 = new PipeSerial(Save, FifthPipe3);
            IPipe ThirdPipe3  = new PipeSerial(NegativeFilter, FourthPipe3);
            IPipe SecondPipe3 = new PipeSerial(Save, ThirdPipe3);

            IPipe InitialPipe3 = new PipeSerial(GrayFilter, SecondPipe3);

            InitialPipe3.Send(pic);

            // Parte 4
            IPipe SerialTweet4 = new PipeSerial(Tweet3, NullPipe);
            IPipe SerialSave   = new PipeSerial(Save, NullPipe);
            IPipe PipeFork4    = new PipeFork(SerialTweet4, SerialSave, FaceCondition.condition);

            IPipe InitialPipe4 = new PipeSerial(GrayFilter, PipeFork4);

            InitialPipe4.Send(pic);

            // Parte 5
            IPipe ThirdPipe5  = new PipeSerial(Tweet4, NullPipe);
            IPipe SecondPipe5 = new PipeSerial(Save, ThirdPipe5);

            IPipe InitialPipe5 = new PipeSerial(LightBlur, SecondPipe5);

            InitialPipe5.Send(pic);
        }