From d8c01ded6eb57ba312e1cd62c4fa51dbcce6053a Mon Sep 17 00:00:00 2001 From: LukePulverenti Luke Pulverenti luke pulverenti Date: Wed, 19 Sep 2012 12:51:37 -0400 Subject: made some improvements to the base http handler --- .../Drawing/BaseImageProcessor.cs | 102 --------------------- 1 file changed, 102 deletions(-) delete mode 100644 MediaBrowser.Controller/Drawing/BaseImageProcessor.cs (limited to 'MediaBrowser.Controller/Drawing/BaseImageProcessor.cs') diff --git a/MediaBrowser.Controller/Drawing/BaseImageProcessor.cs b/MediaBrowser.Controller/Drawing/BaseImageProcessor.cs deleted file mode 100644 index a1441cf7f..000000000 --- a/MediaBrowser.Controller/Drawing/BaseImageProcessor.cs +++ /dev/null @@ -1,102 +0,0 @@ -using MediaBrowser.Controller.Entities; -using MediaBrowser.Model.Entities; -using System; -using System.ComponentModel.Composition; -using System.Drawing; -using System.Drawing.Drawing2D; - -namespace MediaBrowser.Controller.Drawing -{ - /// - /// Provides a base image processor class that plugins can use to process images as they are being writen to http responses - /// Since this is completely modular with MEF, a plugin only needs to have a subclass in their assembly with the following attribute on the class: - /// [Export(typeof(BaseImageProcessor))] - /// This will require a reference to System.ComponentModel.Composition - /// - public abstract class BaseImageProcessor - { - /// - /// Processes an image for a BaseEntity - /// - /// The original Image, before re-sizing - /// The bitmap holding the original image, after re-sizing - /// The graphics surface on which the output is drawn - /// The entity that owns the image - /// The image type - /// The image index (currently only used with backdrops) - public abstract void ProcessImage(Image originalImage, Bitmap bitmap, Graphics graphics, BaseEntity entity, ImageType imageType, int imageIndex); - - /// - /// If true, the image output format will be forced to png, resulting in an output size that will generally run larger than jpg - /// If false, the original image format is preserved. - /// - public virtual bool RequiresTransparency - { - get - { - return false; - } - } - - /// - /// Determines if the image processor is configured to process the specified entity, image type and image index - /// This will aid http response caching so that we don't invalidate image caches when we don't have to - /// - public abstract bool IsConfiguredToProcess(BaseEntity entity, ImageType imageType, int imageIndex); - - /// - /// This is used for caching purposes, since a configuration change needs to invalidate a user's image cache - /// If the image processor is hosted within a plugin then this should be the plugin ConfigurationDateLastModified - /// - public abstract DateTime ProcessingConfigurationDateLastModifiedUtc { get; } - } - - /// - /// This is demo-ware and should be deleted eventually - /// - //[Export(typeof(BaseImageProcessor))] - public class MyRoundedCornerImageProcessor : BaseImageProcessor - { - public override void ProcessImage(Image originalImage, Bitmap bitmap, Graphics graphics, BaseEntity entity, ImageType imageType, int imageIndex) - { - var CornerRadius = 20; - - graphics.Clear(Color.Transparent); - - using (GraphicsPath gp = new GraphicsPath()) - { - gp.AddArc(0, 0, CornerRadius, CornerRadius, 180, 90); - gp.AddArc(0 + bitmap.Width - CornerRadius, 0, CornerRadius, CornerRadius, 270, 90); - gp.AddArc(0 + bitmap.Width - CornerRadius, 0 + bitmap.Height - CornerRadius, CornerRadius, CornerRadius, 0, 90); - gp.AddArc(0, 0 + bitmap.Height - CornerRadius, CornerRadius, CornerRadius, 90, 90); - - graphics.SetClip(gp); - graphics.DrawImage(originalImage, 0, 0, bitmap.Width, bitmap.Height); - } - } - - public override bool RequiresTransparency - { - get - { - return true; - } - } - - private static DateTime testDate = DateTime.UtcNow; - - public override DateTime ProcessingConfigurationDateLastModifiedUtc - { - get - { - // This will result in a situation where images are only cached throughout a server session, but again, this is a prototype - return testDate; - } - } - - public override bool IsConfiguredToProcess(BaseEntity entity, ImageType imageType, int imageIndex) - { - return true; - } - } -} -- cgit v1.2.3