QLabel and image antialiasing
-
Hi and welcome to the forums
It is a perfectly fine place to ask :)QLabel uses Qt::SmoothTransformation and there seems not to be a way to disable it
https://code.woboq.org/qt5/qtbase/src/widgets/widgets/qlabel.cpp.htmlBut you can easily make a custom widget with paintEvent and draw the image
yourself not using smoothing. -
Hi and welcome to the forums
It is a perfectly fine place to ask :)QLabel uses Qt::SmoothTransformation and there seems not to be a way to disable it
https://code.woboq.org/qt5/qtbase/src/widgets/widgets/qlabel.cpp.htmlBut you can easily make a custom widget with paintEvent and draw the image
yourself not using smoothing. -
@v8671 said in QLabel and image antialiasing:
Holy cow, how can i draw a raw bitmap pixel by pixel ????
That's not what was suggested.
@mrjj was talking of something like:
class NonAntiAliasImage : public QWidget{ Q_OBJECT Q_DISABLE_COPY(NonAntiAliasImage) public: explicit NonAntiAliasImage(QWidget* parent = Q_NULLPTR) : QWidget(parent) {} const QPixmap& pixmap() const { return m_pixmap; } void setPixmap(const QPixmap& px) { m_pixmap = px; update(); } protected: void paintEvent(QPaintEvent*) { QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing, false); style()->drawItemPixmap(&painter, rect(), Qt::AlignCenter, m_pixmap.scaled(rect().size())); } private: QPixmap m_pixmap; };