Example #1
0
        public ActionResult Image(string imageFile, int?width, int?height, int?id)
        {
            var memoryStream = new MemoryStream();
            var image        = new Bitmap(ObjectsRepository.CatalogFolder + imageFile.Replace("___", "/"));

            if (width != null && height != null)
            {
                image = image.Clip10X15();
                image = image.ResizeImage(width.Value, height.Value);
            }
            if (id != null)
            {
                image = image.AddBluredRect(30);
                var htmlText = ObjectsRepository.GetObjectDescription(id.Value);
                if (!string.IsNullOrEmpty(htmlText))
                {
                    image = image.AddText(30, 0, htmlText);
                }
                //var backImage = new Bitmap(Server.MapPath("~\\Content\\images\\keyend.png"));
                //image = image.AddBackBitmap(backImage);
            }
            image.Save(memoryStream, ImageFormat.Jpeg);
            memoryStream.Seek(0, SeekOrigin.Begin);
            return(File(memoryStream, "image/jpeg"));
        }