本文整理汇总了C#中IImageProvider.GetImage方法的典型用法代码示例。如果您正苦于以下问题:C# IImageProvider.GetImage方法的具体用法?C# IImageProvider.GetImage怎么用?C# IImageProvider.GetImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IImageProvider
的用法示例。
在下文中一共展示了IImageProvider.GetImage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateImage
public Image CreateImage(
String src,
IDictionary<String, String> attrs,
ChainedProperties chain,
IDocListener document,
IImageProvider img_provider,
Dictionary<String, Image> img_store,
String img_baseurl) {
Image img = null;
// getting the image using an image provider
if (img_provider != null)
img = img_provider.GetImage(src, attrs, chain, document);
// getting the image from an image store
if (img == null && img_store != null) {
Image tim;
img_store.TryGetValue(src, out tim);
if (tim != null)
img = Image.GetInstance(tim);
}
if (img != null)
return img;
// introducing a base url
// relative src references only
if (!src.StartsWith("http") && img_baseurl != null) {
src = img_baseurl + src;
}
else if (img == null && !src.StartsWith("http")) {
String path = chain[HtmlTags.IMAGEPATH];
if (path == null)
path = "";
src = Path.Combine(path, src);
}
img = Image.GetInstance(src);
if (img == null)
return null;
float actualFontSize = HtmlUtilities.ParseLength(
chain[HtmlTags.SIZE],
HtmlUtilities.DEFAULT_FONT_SIZE);
if (actualFontSize <= 0f)
actualFontSize = HtmlUtilities.DEFAULT_FONT_SIZE;
String width;
attrs.TryGetValue(HtmlTags.WIDTH, out width);
float widthInPoints = HtmlUtilities.ParseLength(width, actualFontSize);
String height;
attrs.TryGetValue(HtmlTags.HEIGHT, out height);
float heightInPoints = HtmlUtilities.ParseLength(height, actualFontSize);
if (widthInPoints > 0 && heightInPoints > 0) {
img.ScaleAbsolute(widthInPoints, heightInPoints);
} else if (widthInPoints > 0) {
heightInPoints = img.Height * widthInPoints
/ img.Width;
img.ScaleAbsolute(widthInPoints, heightInPoints);
} else if (heightInPoints > 0) {
widthInPoints = img.Width * heightInPoints
/ img.Height;
img.ScaleAbsolute(widthInPoints, heightInPoints);
}
String before = chain[HtmlTags.BEFORE];
if (before != null)
img.SpacingBefore = float.Parse(before, CultureInfo.InvariantCulture);
String after = chain[HtmlTags.AFTER];
if (after != null)
img.SpacingAfter = float.Parse(after, CultureInfo.InvariantCulture);
img.WidthPercentage = 0;
return img;
}