Skip to content

Commit 93abf63

Browse files
author
ArthurHub
committed
2 parents 426c284 + bc212e2 commit 93abf63

7 files changed

Lines changed: 203 additions & 114 deletions

File tree

‎Source/Demo/Program.cs‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static class Program
2727
private static void Main()
2828
{
2929
// TestPrint();
30-
// TestImage();
30+
// TestImage1();
3131
// return;
3232

3333
Application.EnableVisualStyles();
@@ -39,8 +39,15 @@ private static void Main()
3939

4040
// PerfForm.Run();
4141
}
42+
43+
private static void TestImage1()
44+
{
45+
var html1 = "<p><h2>Hellow</h2><img height='80' src='d:\\b.png'/><h2>world</h2><img height='80' src='http://i.tinyuploads.com/Co66A2.jpg'/><h2>bla</h2></p>";
46+
var img = HtmlRender.RenderToImageGdiPlus(html1, new Size(600, 400));
47+
img.Save(@"d:\test1.png", ImageFormat.Png);
48+
}
4249

43-
private static void TestImage()
50+
private static void TestImage2()
4451
{
4552
var html1 = "<p style='font-size:2em;color: gray'>This is an <b>HtmlLabel</b> on transparent background with <span style='color: red'>colors</span> and links: <a href='http://htmlrenderer.codeplex.com/'>HTML Renderer</a></p>";
4653
var img = HtmlRender.RenderToImageGdiPlus(html1, new Size(600, 200));

‎Source/HtmlRenderer/Dom/CssBox.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,8 +652,8 @@ internal virtual void MeasureWordsSize(IGraphics g)
652652
{
653653
if (BackgroundImage != CssConstants.None && _imageLoadHandler == null)
654654
{
655-
_imageLoadHandler = new ImageLoadHandler(OnImageLoadComplete);
656-
_imageLoadHandler.LoadImage(HtmlContainer, BackgroundImage, HtmlTag != null ? HtmlTag.Attributes : null);
655+
_imageLoadHandler = new ImageLoadHandler(HtmlContainer, OnImageLoadComplete);
656+
_imageLoadHandler.LoadImage(BackgroundImage, HtmlTag != null ? HtmlTag.Attributes : null);
657657
}
658658

659659
MeasureWordSpacing(g);

‎Source/HtmlRenderer/Dom/CssBoxFrame.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,8 @@ private void HandlePostApiCall(object sender)
371371
{
372372
if (_videoImageUrl != null)
373373
{
374-
_imageLoadHandler = new ImageLoadHandler(OnLoadImageComplete);
375-
_imageLoadHandler.LoadImage(HtmlContainer, _videoImageUrl, HtmlTag != null ? HtmlTag.Attributes : null);
374+
_imageLoadHandler = new ImageLoadHandler(HtmlContainer, OnLoadImageComplete);
375+
_imageLoadHandler.LoadImage(_videoImageUrl, HtmlTag != null ? HtmlTag.Attributes : null);
376376
}
377377
else
378378
{

‎Source/HtmlRenderer/Dom/CssBoxImage.cs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ protected override void PaintImp(IGraphics g)
7272
// load image iff it is in visible rectangle
7373
if (_imageLoadHandler == null)
7474
{
75-
_imageLoadHandler = new ImageLoadHandler(OnLoadImageComplete);
76-
_imageLoadHandler.LoadImage(HtmlContainer, GetAttribute("src"), HtmlTag != null ? HtmlTag.Attributes : null);
75+
_imageLoadHandler = new ImageLoadHandler(HtmlContainer, OnLoadImageComplete);
76+
_imageLoadHandler.LoadImage(GetAttribute("src"), HtmlTag != null ? HtmlTag.Attributes : null);
7777
}
7878

7979
var rect = CommonUtils.GetFirstValueOrDefault(Rectangles);
@@ -131,10 +131,10 @@ internal override void MeasureWordsSize(IGraphics g)
131131
{
132132
if (!_wordsSizeMeasured)
133133
{
134-
if (_imageLoadHandler == null && HtmlContainer.AvoidImagesLateLoading)
134+
if (_imageLoadHandler == null && (HtmlContainer.AvoidAsyncImagesLoading || HtmlContainer.AvoidImagesLateLoading))
135135
{
136-
_imageLoadHandler = new ImageLoadHandler(OnLoadImageComplete);
137-
_imageLoadHandler.LoadImage(HtmlContainer, GetAttribute("src"), HtmlTag != null ? HtmlTag.Attributes : null);
136+
_imageLoadHandler = new ImageLoadHandler(HtmlContainer, OnLoadImageComplete);
137+
_imageLoadHandler.LoadImage(GetAttribute("src"), HtmlTag != null ? HtmlTag.Attributes : null);
138138
}
139139

140140
MeasureWordSpacing(g);

0 commit comments

Comments
 (0)