Ejemplo n.º 1
0
        public ActionResult Decorator()
        {
            IPhoto             p = new Photo();
            var                b = p.GetPhoto();
            WatermarkDecorator w = new WatermarkDecorator(p);

            b = w.GetPhoto();

            return(View());
        }
        public IActionResult GetImageWatermarked()
        {
            string             fileName  = hostingEnvironment.MapPath("images/computer.png");
            IPhoto             photo     = new Photo(fileName);
            WatermarkDecorator decorator = new WatermarkDecorator(photo, "Copyright (C) 2015.");
            Bitmap             bmp       = decorator.GetPhoto();
            MemoryStream       stream    = new MemoryStream();

            bmp.Save(stream, ImageFormat.Png);
            byte[] data = stream.ToArray();
            stream.Close();
            return(File(data, "image/png"));
        }