wxDC / antialiasing

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
art-ganseforth
Earned some good credits
Earned some good credits
Posts: 147
Joined: Mon Sep 01, 2014 10:14 am

wxDC / antialiasing

Post by art-ganseforth »

Hello everyone,

i currently try to replace parts of my UI by more absract control-types, so that the user can custom how values are displayed. For optimisation i use a wxMemoryDC on a bitmap, to render the content that is painted to the control in the paint-event.

I now found out, that text (most important) and also other drawn elements are not antialiased this way. So, if i use wxMemoryDC(wxControl).SetFont(wxControl.GetFont()); and ...DrawText(...);, the result is different to the original output that is rendered by ie. wxControl.SetValue().

Is there any way to apply especially the normal text-anti-aliasing to a wxMemoryDC??

Thank you,
Frank
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxDC / antialiasing

Post by doublemax »

For antialiased drawing you need to use wxGraphicsContext:
https://docs.wxwidgets.org/trunk/classw ... ntext.html

Fortunately there is also a wxGCDC which provides a wxDC compatible API:
https://docs.wxwidgets.org/trunk/classwx_g_c_d_c.html

However, drawing text should be antialiased even when using wxDC.
Use the source, Luke!
art-ganseforth
Earned some good credits
Earned some good credits
Posts: 147
Joined: Mon Sep 01, 2014 10:14 am

Re: wxDC / antialiasing

Post by art-ganseforth »

Hey!

Somehow you're right. For testing the capabilities of my control, i used rotated text (90deg). Obviously antialiasing is only working with horizontal text. So maybe (where it's important) i draw text text horizontally at first to a seperate bitmap to be copied rotated to the output.

Anyway: wxGCDC i did not know. I'll read more about it...

Thanks,
Frank
Post Reply