The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,046 other followers

Reminder to self: you cannot repeatedly draw anti-aliased text without damaging the background

Posted by jpluimers on 2013/04/11

A small duh moment when I found this out myself the hard way: when repeatedly drawing anti-aliased text, it will alter the background on each draw.

So you cannot do that. Not in Delphi, not in .NET, not in Cocoa, nowhere (:

–jeroen

via: delphi – “Additive” text rendering on TCanvas? – Stack Overflow.

7 Responses to “Reminder to self: you cannot repeatedly draw anti-aliased text without damaging the background”

  1. Sounds like you need a better graphics library. Or framework… ;)

    • jpluimers said

      Anti-alising per definition modifies the background no matter the graphics library/framework. So if you paint the same thing twice, the background get modified twice. The more you repeat the painting, the more you will see artifacts.

      • The problem only occurs when you use an inappropriate blend/combine mode. E.g. in the Graphics32 Library you can use the CombineMode = cmMerge which does not change the alphachannel of the background below its original value.

      • Kloops said

        If the background doesn’t vary much then one technic is to cache it to a bitmap. Before drawing the elements which varies much (some text, some animated shapes, etc) you draw the cached graphic background. Finally the background is only modified once.

      • SilverWarior said

        Wouldn’t it be better to render the thext into some bitmap without using anti-aliasing and then combine that butmap with the background using anti-aliasing.
        I mean just for rendering text you need to call multiple cals (even several hundreds) especially if you are rendering it using BitFonts.
        So wouldn’t rendering text into some chached texture save you the need for calling several hundred cals for each redraw.

  2. Good to know.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

 
%d bloggers like this: