ImageResizer  3.4.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events
Public Member Functions | Protected Attributes | Properties | List of all members
ImageResizer.Plugins.Watermark.ImageLayer Class Reference
Inheritance diagram for ImageResizer.Plugins.Watermark.ImageLayer:
Inheritance graph
[legend]
Collaboration diagram for ImageResizer.Plugins.Watermark.ImageLayer:
Collaboration graph
[legend]

Public Member Functions

 ImageLayer (NameValueCollection attrs, Config c)
 
 ImageLayer (Config c)
 
void CopyTo (ImageLayer other)
 
override object[] GetHashBasis ()
 
ImageLayer Copy ()
 
Bitmap GetMemCachedBitmap (string virtualPath, ResizeSettings query)
 Loads a bitmap, cached using asp.net's cache More...
 
override void RenderTo (Resizing.ImageState s)
 
- Public Member Functions inherited from ImageResizer.Plugins.Watermark.Layer
 Layer (NameValueCollection settings)
 
virtual void CopyTo (Layer other)
 
int GetDataHash ()
 
delegate Size CalculateLayerContentSize (double maxwidth, double maxheight)
 
RectangleF CalculateLayerCoordinates (ImageState s, CalculateLayerContentSize actualSizeCalculator, bool forceInsideCanvas)
 Returns a rectangle with canvas-relative coordinates. A callback is required to calculate the actual size of the content based on the specified bounds. The callback may be passed double.NaN for one or more paramters to indicate that they are not specified. More...
 
double Resolve (DistanceUnit value, double relativeToValue, double percentRelativeTo, bool invert)
 
virtual void RenderTo (ImageState s)
 

Protected Attributes

string _path = null
 
ResizeSettings _imageQuery = new ResizeSettings()
 
Config c = null
 

Properties

string Path [get, set]
 The virtual path to the watermark image More...
 
Config ConfigInstance [get, set]
 
ResizeSettings ImageQuery [get, set]
 Settings to apply to the watermark before overlaying it on the image. More...
 
- Properties inherited from ImageResizer.Plugins.Watermark.Layer
DistanceUnit Top [get, set]
 The offset from the top of the container. Percentages are relative to the container height. Defines the upper boundary for the layer. If null, Bottom will be used to calcuate the value based on the height. If Bottom is not specified, defaults to 0. Positive values are inside the container, negative values outside it. More...
 
DistanceUnit Left [get, set]
 The offset from the left of the container. Percentages are relative to the container width. Defines the leftmost boundary for the layer. If null, Right will be used to calcuate the value based on the width. If Right is not specified, defaults to 0. Positive values are inside the container, negative values outside it. More...
 
DistanceUnit Right [get, set]
 The offset relative to the right side of the container. Percentages are relative to the container width. Defines the rightmost boundary for the layer. If null, Top will be used to calcuate the value based on the height. If Top is not specified, defaults to 0. Positive values are inside the container, negative values outside it. More...
 
DistanceUnit Bottom [get, set]
 The offset relative to the bottom of the container. Percentages are relative to the container height. Defines the bottom-most boundary for the layer. If null, Top will be used to calcuate the value based on the height. If Top is not specified, defaults to 0. Positive values are inside the container, negative values outside it. More...
 
DistanceUnit Width [get, set]
 The width of the layer. If used with both Left and Right, the smaller result wins. I.e, with a 100px container, width=50, left=30, right=30, the resulting width will be 40. If null, Left and Right will be used to calcuate the value. If both Left and Right are not specified, the natural width of the layer's contents will be used. Percentages are relative to the container width. More...
 
DistanceUnit Height [get, set]
 The height of the layer. If used with both Top and Bottom, the smaller result wins. I.e, with a 100px container, height=50, top=30, top=30, the resulting height will be 40. If null, Top and Bottom will be used to calcuate the value. If both Top and Bottom are not specified, the natural height of the layer's contents will be used. Percentages are relative to the container height. More...
 
string RelativeTo [get, set]
 Specifies the container that the position values (top,left,right,bottom,width,heght) are relative to. The default is 'image' (the innermost square, which contains the original photo). Additional valid values include 'imageArea' (includes whitespace added to preserve aspect ratio), 'padding', 'border', 'margin', and 'canvas'. More...
 
ContentAlignment Align [get, set]
 The alignment to use when (a) all 3 horizontal or vertical values are specified, and they need to be resolved, (b) when only width/height are specified, (c) when no positioning values are specified, or (d) when the content doesn't precisely fill they layer bounds. More...
 
bool Fill [get, set]
 (defaults false). When true, the image or text will attempt to fill 1 of the layer's bounds, even if upscaling is required. When Width is not specified, and both left and right are not specififed, this causes the image to fill the container width (if possible). When Height is not specified, and both top and bottom are not specififed, this causes the image to fill the container height (if possible). This causes &scale=both to be used on images unless another setting is specified in imageQuery. More...
 
LayerPlacement DrawAs [get, set]
 The z-order at which to draw the layer. Curret options are Overlay (over everything) and Background (over the background color). More...
 

Additional Inherited Members

- Public Types inherited from ImageResizer.Plugins.Watermark.Layer
enum  LayerPlacement { Overlay, Background }
 

Detailed Description

Definition at line 14 of file ImageLayer.cs.

Member Function Documentation

Bitmap ImageResizer.Plugins.Watermark.ImageLayer.GetMemCachedBitmap ( string  virtualPath,
ResizeSettings  query 
)
inline

Loads a bitmap, cached using asp.net's cache

Parameters
query
virtualPath
Returns

Definition at line 73 of file ImageLayer.cs.

73  {
74  //If not ASP.NET, don't cache.
75  if (HttpContext.Current == null) return c.CurrentImageBuilder.LoadImage(virtualPath, query);
76 
77  string key = virtualPath.ToLowerInvariant() + query.ToString();
78  Bitmap b = HttpContext.Current.Cache[key] as Bitmap;
79  if (b != null) return b;
80  try
81  {
82  b = c.CurrentImageBuilder.LoadImage(virtualPath, query);
83  }
84  catch (FileNotFoundException fe)
85  {
86  throw new ImageProcessingException(500, "Failed to located watermark " + virtualPath, "Failed to located a watermarking file", fe);
87  }
88  //Query VPPs for cache dependency. TODO: Add support for IVirtualImageProviders to customize cache dependencies.
89  CacheDependency cd = null;
90  if (HostingEnvironment.VirtualPathProvider != null) cd = HostingEnvironment.VirtualPathProvider.GetCacheDependency(virtualPath, new string[] { }, DateTime.UtcNow);
91 
92  HttpContext.Current.Cache.Insert(key, b, cd);
93  return b;
94  }

Property Documentation

ResizeSettings ImageResizer.Plugins.Watermark.ImageLayer.ImageQuery
getset

Settings to apply to the watermark before overlaying it on the image.

Definition at line 41 of file ImageLayer.cs.

string ImageResizer.Plugins.Watermark.ImageLayer.Path
getset

The virtual path to the watermark image

Definition at line 29 of file ImageLayer.cs.


The documentation for this class was generated from the following file: