Antialiased text on transparent bitmap

后端 未结 2 696
执笔经年
执笔经年 2020-12-03 18:36

I\'d like to draw antialiased text on a transparent bitmap and have the antialiasing drawn as alpha blended pixels. This way, I can draw the bitmap onto any color surface (o

2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-03 18:52

    Your text is displayed as it is because you have ClearType subpixel anti-aliasing mode enabled (which is the default on Vista and above). ClearType, by definintion, cannot play nice with alpha channel, since it blends colors, and thus isn't background-agnostic. So it ignores the alpha channel, and blends to black (which is your transparent color otherwise is). You need to enable plain grayscale anti-aliasing for the desired effect:

    g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
    

提交回复
热议问题