-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathWebThumb.cs
52 lines (45 loc) · 1.5 KB
/
WebThumb.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Threading;
using Bitboxx.Web.GeneratedImage.Transform;
using DotNetNuke.Services.GeneratedImage;
namespace Bitboxx.Services.GeneratedImage
{
public class WebThumb : ImageTransform
{
/// <summary>
/// Sets the Url. Defaultvalue is empty
/// </summary>
public string Url { get; set; }
/// <summary>
/// Sets the resulting ratio. (Full,Screen,Cinema)
/// </summary>
public string Ratio { get; set; }
public override string UniqueString
{
get
{
return base.UniqueString + "-" + this.Url + "-" + this.Ratio.ToString();
}
}
public WebThumb()
{
InterpolationMode = InterpolationMode.HighQualityBicubic;
SmoothingMode = SmoothingMode.Default;
PixelOffsetMode = PixelOffsetMode.Default;
CompositingQuality = CompositingQuality.HighSpeed;
}
public override Image ProcessImage(Image image)
{
IEBrowser.UrlRatioMode ratio ;
if (!Enum.TryParse(Ratio, true, out ratio))
ratio = IEBrowser.UrlRatioMode.Screen;
AutoResetEvent resultEvent = new AutoResetEvent(false);
IEBrowser browser = new IEBrowser(Url, ratio, resultEvent);
WaitHandle.WaitAll(new[] { resultEvent });
return browser.Thumb;
}
}
}