Recent

Author Topic: ClearType in CanvasBGRA  (Read 7482 times)

lainz

  • Guest
ClearType in CanvasBGRA
« on: October 23, 2011, 09:14:39 pm »
ClearType is supported in CanvasBGRA?

See the attached shot, the top text is TBGRABitmap.CanvasBGRA.TextOut (with Font.Height := 0), the other is TBGRABitmap.Canvas.TextOut.

There is a way to 'enable' ClearType in CanvasBGRA TextOut / TextRect?
« Last Edit: October 23, 2011, 09:18:07 pm by lainz »

circular

  • Hero Member
  • *****
  • Posts: 3961
    • Personal webpage
Re: ClearType in CanvasBGRA
« Reply #1 on: October 24, 2011, 11:06:35 pm »
I don't think there is an easy way to implement this, except by redirecting TextOut and TextRect calls to Canvas. But this would slow down the process. It may be needed to rebuild the TBitmap object for each call to TextOut. An other way would be to implement ClearType algorithm in BGRABitmap library.
Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 3961
    • Personal webpage
Re: ClearType in CanvasBGRA
« Reply #2 on: October 26, 2011, 02:45:42 am »
Hello Lainz, i've added cleartype support on subversion. Can you try it ?
Conscience is the debugger of the mind

lainz

  • Guest
Re: ClearType in CanvasBGRA
« Reply #3 on: October 26, 2011, 04:48:21 am »
Code: [Select]
  Bitmap.Fill(BGRAPixelTransparent);
  Bitmap.CanvasBGRA.Font.Quality := fqFineClearTypeRGB;
  Bitmap.CanvasBGRA.Font.Height := 30;
  Bitmap.CanvasBGRA.TextOut(100, 100, Caption);
  Bitmap.Draw(Canvas, 0, 0, False); 

ClearType is applied but I get some 'gray' in the borders.

circular

  • Hero Member
  • *****
  • Posts: 3961
    • Personal webpage
Re: ClearType in CanvasBGRA
« Reply #4 on: October 26, 2011, 11:13:27 pm »
This has something to do with transparency. In fact drawing with ClearType does not make sense on a transparent canvas. But this should be handled and draw normal antialiasing instead in this case.

The rectangles you see are font overhang, i.e, where text may go out of its box, for example with italic style.

I've made some filters in LazPaint to simulate ClearType. It's on subversion. So you can take an image or a screenshot that does not have ClearType and apply it, or the contrary, take a screenshot and remove ClearType effect afterwards.

Conscience is the debugger of the mind

lainz

  • Guest
Re: ClearType in CanvasBGRA
« Reply #5 on: October 27, 2011, 12:40:55 am »
You can try the latest BGRAControls git. Open testbgracontrols, i'm trying to use the ClearType in the 'Windows 7 ToolBar example' the main problem is the normal state is transparent.

There is a way to avoid the grayed background, and using ClearType?

The drawing code is in the procedure 'DrawTextCanvas' in 'BGRAButton' unit.

circular

  • Hero Member
  • *****
  • Posts: 3961
    • Personal webpage
Re: ClearType in CanvasBGRA
« Reply #6 on: October 27, 2011, 11:25:26 am »
I think I found a way to compute cleartype on alpha pixels. It's on subversion.

Now ClearType just behaves like normal drawing when there are no pixels under.
Conscience is the debugger of the mind

lainz

  • Guest
Re: ClearType in CanvasBGRA
« Reply #7 on: October 28, 2011, 04:05:29 am »
Nice  :D

circular

  • Hero Member
  • *****
  • Posts: 3961
    • Personal webpage
Re: ClearType in CanvasBGRA
« Reply #8 on: October 31, 2011, 05:00:40 pm »
I've improved font rendering in version 5.1. Here is what you get now :
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018