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); }
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) { 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 }