The wonders of text rendering and GDI

My research into text rendering in .NET/Windows started with HTML Renderer, I have noticed text issues in the rendered HTML: fonts were pixelated, letter were too close, words were either too close or too far apart (Figure 1). Although minor issues they were bugging me, also I was hoping it will lead to some performance improvements as from my last optimization session text draw/measure were the most time consuming operations.
The resulted improvement exceeded my wildest expectations and worth a post on.
Continue reading

Advertisements

Optimizing images usage in .NET – part 1

Using image is an integral part of GUI application but I have found very little resources on it's resource consumption and how I can optimize it. The goal of this post is exactly that, in part 1 I will show the performance impact and in part 2 I will propose an optimization.
I'm going to consider only the memory usage as CPU performance is generally insignificant.
 
Continue reading

HTML Renderer 1.4.0.0

I'm very happy to release another update for the project, I believe I'm getting very close to remove the 'Beta' tag from it.
This update has many fixes for complex layout and tables to handle much more complex htmls, better support for style sheet loading (see below), context menu, embedded videos and finally fixing the support for preformatted text!
I have dropped support for 'Bridge' object (see below) which can be a breaking change if used, it quite easy to replace it's use with events as can be seen in the demo application. Hopefully this will be the last version that has breaking changes.
For next version (v1.5) I'm planning to rewrite the object model (CssBox monster) and core parsing engine to significantly improve performance, especially the memory allocations that can pretty bad now for large htmls. Of course I will continue to fix bugs and add support for features as requested by the community.
 
Continue reading

Using T4 Templates for caching image resources

In my project I'm doing a lot of native UI rendering1, soon I will blog on why.
Naturally I have many images to render using DrawImage methods, that requires an Image instance.
There are couple of ways to load an image but the best2 and easies option is using a Resource File, just dragging and dropping the images into the resource designer will add the file to the project and generate a nice static property by the name of the file in the static class generated by the name of the resource file.
The problem is that each time image resource property is called a new image instance is created with the requested image, so if the same image is used in multiple places3 it will be loaded multiple times in memory4.
 
Continue reading