Exemplo n.º 1
0
        static void Main(string[] args)
        {
            //Ejercicio1

            PictureProvider p          = new PictureProvider();
            IPicture        pic        = p.GetPicture("..\\Adds\\índice.jpg");
            IPipe           thirdpipe  = new PipeNull();
            IPipe           secondpipe = new PipeSerial(new FilterNegative(), thirdpipe);
            IPipe           firstpipe  = new PipeSerial(new FilterGreyscale(), secondpipe);

            p.SavePicture(firstpipe.Send(pic), "..\\Adds\\Ejercicio1.jpg");

            //Ejercicio2

            PictureProvider p1          = new PictureProvider();
            IPicture        pic1        = p1.GetPicture("..\\Adds\\índice.jpg");
            IPipe           fifthpipe1  = new PipeNull();
            IPipe           fourthpipe1 = new PipeSerial(new FilterSave(), fifthpipe1);
            IPipe           thirdpipe1  = new PipeSerial(new FilterNegative(), fourthpipe1);
            IPipe           secondpipe1 = new PipeSerial(new FilterSave(), thirdpipe1);
            IPipe           firstpipe1  = new PipeSerial(new FilterGreyscale(), secondpipe1);

            firstpipe1.Send(pic1);

            //Ejercicio3

            PictureProvider p2   = new PictureProvider();
            IPicture        pic2 = p2.GetPicture("..\\Adds\\índice.jpg");

            IPipe fifthpipe2 = new PipeNull();

            IPipe fourthpipe2 = new PipeSerial(new FilterTwitter(), fifthpipe2);

            IPipe thirdpipe2 = new PipeSerial(new FilterNegative(), fourthpipe2);

            IPipe secondpipe2 = new PipeSerial(new FilterTwitter(), thirdpipe2);

            IPipe firstpipe2 = new PipeSerial(new FilterGreyscale(), secondpipe2);

            firstpipe2.Send(pic2);


            //Ejercicio4

            PictureProvider p3   = new PictureProvider();
            PictureProvider p4   = new PictureProvider();
            IPicture        pic3 = p3.GetPicture("..\\Adds\\índice.jpg");
            IPicture        pic4 = p4.GetPicture("..\\Adds\\Auto.jpg");

            IPipe fifthpipe3 = new PipeNull();

            IPipe fourthpipe3 = new PipeSerial(new FilterNegative(), fifthpipe3);

            IPipe thirdpipe3 = new PipeSerial(new FilterTwitter(), fifthpipe3);

            IPipe secondpipe3 = new PipeConditionalFork(new FilterConditional(), thirdpipe3, fourthpipe3);

            IPipe firstpipe3 = new PipeSerial(new FilterGreyscale(), secondpipe3);

            firstpipe3.Send(pic3);
            p4.SavePicture(firstpipe.Send(pic4), "..\\Adds\\auto2.jpg");



            //Ejercicio5
            PictureProvider p5          = new PictureProvider();
            IPicture        pic5        = p5.GetPicture("..\\Adds\\índice.jpg");
            IPipe           secondpipe5 = new PipeNull();
            IPipe           firstpipe5  = new PipeSerial(new FilterRandomConvolution(), secondpipe5);

            p5.SavePicture(firstpipe5.Send(pic5), "..\\Adds\\Ejercicio5.jpg");
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            PictureProvider p   = new PictureProvider();
            IPicture        pic = p.GetPicture("../faceImage.jpg");

            IFilter filterGreyscale          = new FilterGreyscale();
            IFilter filterNegative           = new FilterNegative();
            IFilter filterProvider           = new FilterProvider();
            IFilter filterTwiter             = new FilterTwitter();
            IFilter filterConditional        = new FilterConditional();
            IFilter filterBlurConvolution    = new FilterBlurConvolution();
            IFilter filterSharpenConvolution = new FilterSharpenConvolution();

            //EJERCICIO 1

            IPipe pipeNull_ej1    = new PipeNull();
            IPipe pipeSerial2_ej1 = new PipeSerial(filterNegative, pipeNull_ej1);
            IPipe pipeSerial1_ej1 = new PipeSerial(filterGreyscale, pipeSerial2_ej1);

            pipeSerial1_ej1.Send(pic);

            //EJERCICIO 2

            IPipe pipeNull_ej2      = new PipeNull();
            IPipe pipeProvider2_ej2 = new PipeSerial(filterProvider, pipeNull_ej2);
            IPipe pipeSerial2_ej2   = new PipeSerial(filterNegative, pipeProvider2_ej2);
            IPipe pipeProvider1_ej2 = new PipeSerial(filterProvider, pipeSerial2_ej2);
            IPipe pipeSerial1_ej2   = new PipeSerial(filterGreyscale, pipeProvider1_ej2);

            pipeSerial1_ej2.Send(pic);


            //EJERCICIO 3

            IPipe pipeNull_ej3      = new PipeNull();
            IPipe pipeTwiter2_ej3   = new PipeSerial(filterTwiter, pipeNull_ej3);
            IPipe pipeProvider2_ej3 = new PipeSerial(filterProvider, pipeTwiter2_ej3);
            IPipe pipeSerial2_ej3   = new PipeSerial(filterNegative, pipeProvider2_ej3);
            IPipe pipeTwiter1_ej3   = new PipeSerial(filterTwiter, pipeSerial2_ej3);
            IPipe pipeProvider1_ej3 = new PipeSerial(filterProvider, pipeTwiter1_ej3);
            IPipe pipeSerial1_ej3   = new PipeSerial(filterGreyscale, pipeProvider1_ej3);

            pipeSerial1_ej3.Send(pic);


            //EJERCICIO 4

            IPipe pipeNull_ej4             = new PipeNull();
            IPipe pipeProvider2_ej4        = new PipeSerial(filterProvider, pipeNull_ej4);
            IPipe pipeSerial2_ej4          = new PipeSerial(filterNegative, pipeProvider2_ej4);
            IPipe pipeTwiter1_ej4          = new PipeSerial(filterTwiter, pipeNull_ej4);
            IPipe pipeConditionalFork1_ej4 = new PipeConditionalFork(filterConditional, pipeTwiter1_ej4, pipeSerial2_ej4);
            IPipe pipeProvider1_ej4        = new PipeSerial(filterProvider, pipeConditionalFork1_ej4);
            IPipe pipeSerial1_ej4          = new PipeSerial(filterGreyscale, pipeProvider1_ej4);

            pipeSerial1_ej4.Send(pic);


            //EJERCICIO BONUS

            IPipe pipeNull_ejB      = new PipeNull();
            IPipe pipeProvider2_ejB = new PipeSerial(filterProvider, pipeNull_ejB);
            IPipe pipeSerial2_ejB   = new PipeSerial(filterSharpenConvolution, pipeProvider2_ejB);
            IPipe pipeProvider1_ejB = new PipeSerial(filterProvider, pipeSerial2_ejB);
            IPipe pipeSerial1_ejB   = new PipeSerial(filterBlurConvolution, pipeProvider1_ejB);

            pipeSerial1_ejB.Send(pic);
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            IFilter         Greyscale = new FilterGreyscale();
            IFilter         Negative  = new FilterNegative();
            IFilter         Twitter   = new FilterTwitter();
            IFilter         Save      = new FilterSave();
            IFilter         Sharpen   = new FilterSharpenConvolution();
            IFilterBool     HasFace   = new FilterFace();
            PictureProvider p         = new PictureProvider();
            IPicture        pic       = p.GetPicture("..\\Images\\image.jpg");

            /// <summary>
            /// Las clases Pipe que aplican algún filtro a la imagen delegan la responsabilidad de modificar
            /// la imagen a la clase Filter que la compone.
            /// </summary>
            /// <returns></returns>

            #region Ejercicio 1

            IPipe Pipe1_3 = new PipeNull();
            IPipe Pipe1_2 = new PipeSerial(Negative, Pipe1_3);
            IPipe Pipe1_1 = new PipeSerial(Greyscale, Pipe1_2);
            Pipe1_1.Send(pic);

            #endregion

            #region Ejercicio 2

            IPipe Pipe2_5 = new PipeNull();
            IPipe Pipe2_4 = new PipeSerial(Save, Pipe2_5);
            IPipe Pipe2_3 = new PipeSerial(Negative, Pipe2_4);
            IPipe Pipe2_2 = new PipeSerial(Save, Pipe2_3);
            IPipe Pipe2_1 = new PipeSerial(Greyscale, Pipe2_2);
            Pipe2_1.Send(pic);

            #endregion

            #region Ejercicio 3

            IPipe Pipe3_5 = new PipeNull();
            IPipe Pipe3_4 = new PipeSerial(Twitter, Pipe2_5);
            IPipe Pipe3_3 = new PipeSerial(Negative, Pipe2_4);
            IPipe Pipe3_2 = new PipeSerial(Twitter, Pipe2_3);
            IPipe Pipe3_1 = new PipeSerial(Greyscale, Pipe2_2);
            Pipe3_1.Send(pic);

            #endregion

            #region Ejercicio 4

            IPipe Pipe4_5 = new PipeNull();
            IPipe Pipe4_4 = new PipeSerial(Negative, Pipe4_5);
            IPipe Pipe4_3 = new PipeSerial(Twitter, Pipe4_5);
            IPipe Pipe4_2 = new PipeConditionalFork(Pipe4_3, Pipe4_4, HasFace);
            IPipe Pipe4_1 = new PipeSerial(Greyscale, Pipe4_2);
            Pipe4_1.Send(pic);

            #endregion

            #region Ejercicio Bonus

            IPipe PipeBonus_3 = new PipeNull();
            IPipe PipeBonus_2 = new PipeSerial(Save, PipeBonus_3);
            IPipe PipeBonus_1 = new PipeSerial(Sharpen, PipeBonus_2);
            PipeBonus_1.Send(pic);

            #endregion
        }