PDA

View Full Version : Turn off Smoothing/AntiAliasing for my app (Win/Lin)



CyberWorker
13th April 2015, 15:06
Hi guys in this forum,

first i am rather beginner with Qt, but my question will require rather in-depth knowledge, therefore I didn't choose the beginners section.

My situation: I am currently using the QPainter.drawText function on a QImage. The QImage is then simply saved into a .bmp file. So far so good.

Challenge:
Currently a saved QImage looks like this (please click to see in proper size):
11083

But I want it to be displayed "unchanged" and pixel-exact, like this:
11084

You might ask yourself now how I got the proper result I want? Well there is 2 answers to that depending on the OS.
Windows: Simply switching off ClearType completely (with a free app called ClearType switch; saves time instead of you doing the work with the registry)
Linux(in my case CentOS): Switching off Smoothing etc right here:
11085

I need to know how to use Qt in order to tell my app to NOT use those Smoothing, AntiAlias, Subpixel or Hinting Features at all.
The global settings as mentioned above are not usable, as I need my app to run anywhere without having to have admin-rights.
I did try things like

CustomFont.setStyleStrategy(QFont::NoAntialias);
CustomFont.setStyleStrategy(QFont::PreferBitmap);
CustomFont.setStyleStrategy(QFont::NoSubpixelAntia lias);
CustomFont.setHintingPreference(QFont::PreferNoHin ting);
CustomPainter.setRenderHint(QPainter::Antialiasing , false);
CustomPainter.setRenderHint(QPainter::HighQualityA ntialiasing, false);

they didn't help at all.

I am quite deperate to find a solution, appreciate any help on this.

Best regards

yeye_olive
13th April 2015, 15:51
This works fine on my Linux system:


QImage my_image(/* ... */);
{
QPainter p(&my_image);
QFont font(/* ... */);
font.setStyleStrategy(QFont::NoAntialias);
p.setFont(font);
p.drawText(/* ... */);
}

CyberWorker
14th April 2015, 11:59
Ok. Well for me setStyleStrategy doesn't do any difference to it, particularly I am talking about small Pointsizes, such as 7,8,9.

Anyone else some advice?