private Stream GetWatermarkedImageStream() { Image watermarkedImage = null; try { try { watermarkedImage = ImageHelper.AddWatermark(MediaObjectFilePath, MediaObject.GalleryId); } catch (Exception ex) { // Can't apply watermark to image. Substitute an error image and send that to the user. if (!(ex is FileNotFoundException)) { // Don't log FileNotFoundException exceptions. This helps avoid clogging the error log // with entries caused by search engine retrieving media objects that have been moved or deleted. AppEventController.LogError(ex); } watermarkedImage = Image.FromFile(_context.Request.MapPath(String.Concat(Utils.SkinPath, "/images/error-xl.png"))); } MemoryStream stream = new MemoryStream(); watermarkedImage.Save(stream, ImageFormat.Jpeg); return(stream); } finally { if (watermarkedImage != null) { watermarkedImage.Dispose(); } } }
private void ProcessMediaObjectWithWatermark() { // Send the specified file to the client with the watermark overlayed on top. IMimeType mimeType = MimeType.LoadInstanceByFilePath(this._filename); this._context.Response.Clear(); this._context.Response.ContentType = mimeType.FullType; Image watermarkedImage = null; try { try { watermarkedImage = ImageHelper.AddWatermark(this._filepath); } catch (Exception ex) { // Can't apply watermark to image. Substitute an error image and send that to the user. AppErrorController.LogError(ex); watermarkedImage = Image.FromFile(this._context.Request.MapPath(String.Concat(Util.GalleryRoot, "/images/error_48x48.png"))); } watermarkedImage.Save(this._context.Response.OutputStream, ImageFormat.Jpeg); } finally { if (watermarkedImage != null) { watermarkedImage.Dispose(); } } }
private void ProcessMediaObjectWithWatermark() { // Send the specified file to the client with the watermark overlayed on top. this._context.Response.Clear(); this._context.Response.ContentType = MediaObject.MimeType.FullType; Image watermarkedImage = null; try { try { watermarkedImage = ImageHelper.AddWatermark(MediaObjectFilePath, MediaObject.GalleryId); } catch (Exception ex) { // Can't apply watermark to image. Substitute an error image and send that to the user. if (!(ex is FileNotFoundException)) { // Don't log FileNotFoundException exceptions. This helps avoid clogging the error log // with entries caused by search engine retrieving media objects that have been moved or deleted. AppErrorController.LogError(ex); } watermarkedImage = Image.FromFile(this._context.Request.MapPath(String.Concat(Utils.GalleryRoot, "/images/error_48x48.png"))); } watermarkedImage.Save(this._context.Response.OutputStream, ImageFormat.Jpeg); } finally { if (watermarkedImage != null) { watermarkedImage.Dispose(); } } }