3

I am using the canvas draw functions drawrect and filltext to draw onto a Tbitmap but I don't want the results antialiased. Anyone know how to do that ?

Working with OSX and Delphi XE3 (but have XE4 and XE5 if needed)

3
  • Maybe the last answer at stackoverflow.com/questions/10592874/… is of help?
    – Gerard
    Commented Jan 2, 2014 at 23:30
  • Thanks for the link. Aligning drawing co-ordinates with pixels will only avoid anti-aliasing for vertical and horizontal lines. Its not going to be of help with text or rounded corners - at least thats what I assume, there is no help in the documentation as usual. What I need to do is turn it off. Commented Jan 3, 2014 at 12:10
  • Please provide simple code example that demonstrates the problem. Commented Jan 6, 2014 at 19:25

2 Answers 2

1
+50

Is the problem:

  1. the bitmap you create seems to have anti-aliasing present in the data?
  2. or have you got a good bitmap and want to disable anti-aliasing in the viewer/display?

If it is the former, have you checked that the anti-aliasing is actually present in the bitmap, and not introduced by your viewer?

In the past I've found it useful to draw a black-on-white test pattern, and display the image at 1:1 scale. Irfanview is a nice tool for viewing at 'true' scale. Then use a loupe/peak/lens to get a close-up of the actual pixels.

Black-on-white test patterns are particularly good since you should be able to see (hopefully) that the R,G and B sub-pixels are all equally illuminated when there is no anti-aliassing present. If you draw a black-on white pattern and you get solitary bright sub-pixels then you've definitely got anti-aliassing (or some other form of corruption!).

My experience has been that image viewers often do interpolation for you, and it can be tricky to see what is going on unless you look at the actual bitmap data or have a close-up look at the unscaled image...

6
  • Antialiasing is added by all canvas drawing functions in Firemonkey by default - so yes its in the bitmap. I am reading the bitmap pixel by pixel which is how the problem showed itself. In VCL with Delphi 6 there is no problem. Start off with a blank white bitmap and draw on it and you will see the effect. Only straight lines aligned to the pixels will not show antialiasing. Commented Jan 8, 2014 at 11:57
  • @David Drat. Okay, it sounds as though rendering is done by the GDI+ canvas on a per-font basis. Changing back to a GDI canvas would remove anti-aliasing support, but is horribly regressive. You could try to set the global-level settings to prevent AA being allowed when the font is drawn: do have you tried playing with the following parameters: GlobalUseHWEffects, EGlobalUseDirect2D, GlobalUseGDIPlusClearType, GlobalDisableFocusEffect? Commented Jan 8, 2014 at 14:11
  • @David Alternatively, The embarcadero website lets slip that AA can be enabled (disabled?) using the FMX.Form.Quality property. I don't have an install, or I'd go and prod this a little further... Commented Jan 8, 2014 at 14:19
  • form.quality not available in XE3. I had trouble getting XE5 to run but now I have, form.quality is read only. Maybe it can be overridden with a helper function or something. Commented Jan 9, 2014 at 14:26
  • @ David That's a pain. Any luck with the Global parameters? If I find anything else, I'll let you know... Commented Jan 9, 2014 at 17:47
0

Hi in the drawBitmap method you need to set HighSpeed parameter to "True", in the sample below:

NewBitmap.Canvas.DrawBitmap(SmallBmp, RectF(0, 0, SmallBmp.Width, SmallBmp.Height), RectF(0, 0, NewBitmap.Width, NewBitmap.Height), 1,**True**);

rgds Ivan

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.