Details
-
Bug
-
Resolution: Done
-
P2: Important
-
4.7.1
-
None
-
Maemo 5, N900 sw20.2010.36-3.203.1
-
69ed34d2aa77a3bacc7f66797baa514f35358b7e
Description
When trying to use QPainter and OpenGL graphics system to draw a QImage with dimensions bigger than the maximum texture size in N900 (2048x2048), the result is either no output at all (black rectangle), or severe artifacts (only some sub-tiles are rendered).
QOpenGLPaintEngine::drawImage() should be able to partition/scale the image down to the max. supported texture size, but this doesn't seem to work on Maemo platform. Same applies to drawPixmap().
Simple test application to reproduce the issue:
#include <QApplication> #include <QPaintEngine> #include <QImage> #include <QPainter> #include <QWidget> class Widget : public QWidget { Q_OBJECT public: Widget(QWidget* parent = 0); protected: void paintEvent (QPaintEvent* event); private: QImage m_image; int m_imgWidth; int m_imgHeight; }; Widget::Widget(QWidget* parent) :QWidget(parent), m_imgWidth(2560), // fails to render if width or height > 2048 m_imgHeight(1440) { QRect rect(0, 0, m_imgWidth, m_imgHeight); m_image = QImage(rect.size(), QImage::Format_RGB32); QPainter painter(&m_image); QColor color(200, 240, 160); QBrush brush(color); painter.setBrush(brush); painter.setPen(color); painter.drawRect(rect); // draw a checkerboard pattern on image color = QColor(240, 160, 200); brush.setColor(color); painter.setPen(color); painter.setBrush(brush); int length = 157; int y = 0; int c = 0; while(y*length+length < m_imgHeight) { int x = c % 2; while(x*length+length < m_imgWidth) { rect.setCoords(x*length, y*length, x*length+length, y*length+length); painter.drawRect(rect); x +=2; } ++y; ++c; } } void Widget::paintEvent(QPaintEvent* event) { Q_UNUSED(event) QPainter painter(this); QRect imageRect(20, 20, m_imgWidth/1.3, m_imgHeight/1.3); // draw image scaled to widget's size painter.drawImage(contentsRect(), m_image, imageRect); } #include "main.moc" int main(int argc, char **argv) { QApplication::setGraphicsSystem("opengl"); QApplication a(argc, argv); Widget w; w.resize(800, 400); w.show(); return a.exec(); }