Quantcast
Channel: HTML Renderer
Viewing all articles
Browse latest Browse all 693

New Post: HtmlRender.Render - Pixilated Images

$
0
0
I wrote the following code which worked flawlessly. Started up the project the next day and now all the images are pixilated, bolded text. I have no idea what would have caused the issue. Any suggestions would be greatly appreciated.
        protected Bitmap createAutoHeightImage( string htmlString, int bitmapWidth )
        {
            Bitmap m_Bitmap = new Bitmap( 400, 600 );
            PointF point = new PointF( 0, 0 );
            SizeF maxSize = new System.Drawing.SizeF( 500, 500 );

            var css = HtmlRenderer.CssData.Parse( "font-family:Arial,san-serif;font-size:10px;", true );

            maxSize = HtmlRenderer.HtmlRender.Measure( Graphics.FromImage( m_Bitmap ), htmlString, bitmapWidth );
            Bitmap theImage = new Bitmap( (int)maxSize.Width, (int)maxSize.Height );
            HtmlRenderer.HtmlRender.Render( Graphics.FromImage( theImage ), htmlString, point, maxSize, css );

            return theImage;
        }

string myHTML = "<html><body><p>This is a <strong>nice</strong> html code</p></body></html>";
createAutoHeightImage( myHTML, 600 ).Save( @"D:\inetpub\wwwroot\imagetext\question.png", ImageFormat.Png );
Before: Image
After: Image

Viewing all articles
Browse latest Browse all 693

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>