Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    QRadialGradient is pixelated

    General and Desktop
    1
    1
    1305
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      goocreations last edited by

      I've been experimenting with QRadialGradient and noticed that the gradient shows up as rectangles (pixelated). I guess this was implemented like this to reduce the intensity of the computation (it looks something like bilinear interpolation or cubic convolution), after all, it is easier to draw rectangles than circles.

      My problem is that this pixelation gets well visible at smaller circles (eg: 80, 80). Is there any way I can reduce this pixelation?
      I've added the code I'm using and the results of the drawing. I've also tried to use QPainter::HighQualityAntialiasing and QPainter::SmoothPixmapTransform, but without much change.

      @ QImage::Format format = QImage::Format_ARGB32;
      QImage buffer(qCeil(width), qCeil(height), format);
      buffer.fill(qRgba(255, 255, 255, 0));

      QPainter painter(&buffer);
      painter.setPen(Qt::NoPen);
      painter.setRenderHint(QPainter::Antialiasing, true);

      QRadialGradient radialGradient(QPointF(width / 2, height /2), qMax(width, height) / 2);
      QColor color = ViThemeManager::color(14);
      color.setAlpha(150);
      radialGradient.setColorAt(1, Qt::transparent);
      radialGradient.setColorAt(0.8, ViThemeManager::color(14));
      radialGradient.setColorAt(0.7, color);
      radialGradient.setColorAt(0, color);

      painter.setBrush(radialGradient);
      painter.drawRect(0, 0, width, height);

      painter.end();@

      !http://visore.org/other/1.png(Image 1)!

      !http://visore.org/other/2.png(Image 2)!

      1 Reply Last reply Reply Quote 0
      • First post
        Last post