示例#1
0
        static void Main(string[] args)
        {
            PictureProvider p   = new PictureProvider();
            IPicture        pic = p.GetPicture(@"Silla.jpg");

            PipeSerial greyscale = new PipeSerial(new FilterGreyscale(), new PipeNull());

            pic = greyscale.Send(pic);

            //p.SavePicture(pic,@"matrix2.jpg");

            /*
             * La idea es que cuando pase por el FilterSaving se guarde la imagen con el filtro aplicado de donde viene.
             * Le paso la foto al pipe grayScale que lo va a pasar por FilterGrayScale y de ahi a un pipe que se llama saveImage
             * creado para este ejercicio, este pipe le aplica el filto que guarda la imagen. De ahi se va al pipe fork donde decide
             * dependiendo de si tiene cara o no si va al twitterfilter o al negative.
             * Después de ese filtro llega al pipe null.
             */
            FilterSaving saving = FilterSaving.Instance;

            PipeSerial saveImageAlreadyWentThrough = new PipeSerial(saving, new PipeNull());
            PipeSerial negative = new PipeSerial(new FilterNegative(), saveImageAlreadyWentThrough);

            PipeSerial twitterFilter = new PipeSerial(new TwitterFilter(), new PipeNull());

            PipeFork DoesItHaveAFace = new PipeFork(twitterFilter, negative, new HasFaceConditional());

            PipeSerial saveImage = new PipeSerial(saving, DoesItHaveAFace);
            PipeSerial grayScale = new PipeSerial(new FilterGreyscale(), saveImage);

            grayScale.Send(pic);
        }
示例#2
0
        static void Main(string[] args)
        {
            // creamos un objeto PictureProvider y obtenemos una imagen
            PictureProvider p   = new PictureProvider();
            IPicture        pic = p.GetPicture("C:/Users/FIT/programacion2/ejercicio_en_clase/ComposicionYDelegacion/PII_Pipes_Filters-master/gato.png");

            // creamos un pipeNull
            IPipe pipenull = new PipeNull();

            // creamos instancias de todos los filtros que nos interecen
            FilterSave            filtersave            = new FilterSave("../../gato2.png");
            FilterTwitter         filtertwitter         = new FilterTwitter(filtersave.path);
            FilterNegative        filternegative        = new FilterNegative();
            FilterGreyscale       filtergreyscale       = new FilterGreyscale();
            ConditionalFilter     conditionalfilter     = new ConditionalFilter(filtersave.path);
            FilterBlurConvolution filterblurconvolution = new FilterBlurConvolution();

            // creamos instancias de todos los pipeSerial que vayamos a utilizar
            IPipe pipeserial7 = new PipeSerial(filtertwitter, pipenull);
            IPipe pipeserial6 = new PipeSerial(filtersave, pipeserial7);               // en este caso se sobrescribe la imagen guardada ya que estoy usando el mismo filtersave con el mismo path
            IPipe pipeserial5 = new PipeSerial(filterblurconvolution, pipeserial6);
            IPipe pipeserial4 = new PipeSerial(filtertwitter, pipenull);
            IPipe pipefork    = new PipeFork(conditionalfilter, pipeserial4, pipeserial5);
            IPipe pipeserial3 = new PipeSerial(filtersave, pipefork);
            IPipe pipeserial2 = new PipeSerial(filternegative, pipeserial3);
            IPipe pipeserial  = new PipeSerial(filtergreyscale, pipeserial2);

            // enviamos la imagen al primer pipeSerial
            pipeserial.Send(pic);
        }
示例#3
0
        static void Main(string[] args)
        {
            PictureProvider p              = new PictureProvider();
            IPicture        pic            = p.GetPicture("../../Sequence-1.png");
            FilterGreyscale greyscale      = new FilterGreyscale();
            FilterNegative  filternegative = new FilterNegative();
            PipeNull        pipeNull       = new PipeNull();
            FilterSave      saveFilter     = new FilterSave();

            TwitterSave twitterSave = new TwitterSave();

            PipeSerial pipeserial3 = new PipeSerial(saveFilter, pipeNull);

            PipeSerial pipeserial4 = new PipeSerial(twitterSave, pipeNull);

            PipeFork pipeFork4 = new PipeFork(pipeNull, pipeserial4);

            PipeFork pipeFork3 = new PipeFork(pipeNull, pipeserial3);



            PipeSerial pipeserial2 = new PipeSerial(filternegative, pipeFork3);

            PipeFork pipeFork5 = new PipeFork(pipeserial2, pipeserial4);

            PipeFork pipeFork2 = new PipeFork(pipeFork5, pipeserial3);

            PipeSerial pipeSerial = new PipeSerial(greyscale, pipeFork2);

            PipeFork pipeFork1 = new PipeFork(pipeSerial, pipeserial3);



            pipeFork1.Send(pic);
        }
        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);
        }