[Qt-interest] QImage.drawImage() on huge image doesn't work as expected. Bug?

Samuel Rødal sroedal at trolltech.com
Tue Mar 31 10:47:55 CEST 2009


Thorben Kröger wrote:
> Hi,
> 
> I'm drawing a small red image on a huge 40 megapixel black QImage. If I draw 
> it on the top, it works as expected, if I draw it at a position of say 50000, 
> it doesn't.
> 
> Here is a small testcase.
> See try2.png, there's the red rectangle.
> And in try3.png, no red rectangle at all.
> 
> Is this a bug?
> Or am I just doing sth. wrong?
> 
> #include <QtGui>
> #include <qdebug.h>
> 
> void superimpose(const QImage& background, const QImage& overlay, const 
> QPoint& origin, QString filename) {
>     QImage img = background;
>     QPainter p(&img);
>     p.drawImage(origin, overlay);
>     img.save(filename);
> }
> 
> int main(int argc, char** argv) {
>     //Huge background image
>     QImage bg(QSize(289, 141564), QImage::Format_RGB32);
>     bg.fill(0);
>     
>     //Some small image
>     QImage patch(QSize(287,7077), QImage::Format_RGB32);
>     for(int i=0; i<287; i++) {
>         for(int j=0; j<7077; j++) {
>             patch.setPixel(i,j, qRgb(255,0,0));
>         }
>     }
>     
>     superimpose(bg, patch, QPoint(0,0),     "try1.png");
>     superimpose(bg, patch, QPoint(0,1000),  "try2.png");
>     superimpose(bg, patch, QPoint(0,50000), "try3.png");
>     
> 	return 0;
> }
> 
> Cheers,
> Thorben

Painting outside +- 2^15 is not fully supported.

http://doc.trolltech.com/4.5/qpainter.html#limitations

Cheers,
Samuel



More information about the Qt-interest-old mailing list