Board index » delphi » Font colour from TRect

Font colour from TRect

I have a TRect which I know contains a text string. How do I determine the
colour of the font that was used to draw the text?

I've tried creating a TCanvas and using CopyRect to get the contents of the
TRect onto it, but I get an error message saying that the canvas cannot be
drawn on

Sarah

 

Re:Font colour from TRect


You should not create a TCanvas for that purpose, create a TBitmap instead
and use its "Canvas" property (size the bitmap first).

Retrieving the color of the font might get tricky if the color of the
background is not known/fixed and/or font smoothing is enabled...
you'll have to perform some color-space histogram search...

Eric Grange

Other Threads