[Qt-interest] Creating large QImage from several small ones

Boudewijn Rempt boud at valdyas.org
Fri Apr 10 16:57:36 CEST 2009


On Fri, 10 Apr 2009, Murphy, Sean M. wrote:

> Is there an easy way to create a large QImage from several small ones?
> I'm trying to build up an image that is a 3x3 mosaic of 9 smaller tiles.
> I've got the tiles, I know where they go, but I don't see an easy (like
> 1 line of code per tile) way to build the big image.  The only way I can
> see is:
>   QImage::setPixel(int x, int y, uint index_or_rgb )
> 
> Where I'd have to explicitly copy each pixel from each tile into the
> correct pixel of the big image.  Obviously this isn't hard to do, but I
> was assuming there'd be something like
>   QImage::setArea(const QPoint& offset, const QImage& src)
> 
> Maybe I'm brain-dead on this Friday, but I could have sworn there was an
> easier way to do this!
> 

There used to be bitBlt functions, but nowadays you can simply create
a QPainter and use drawImage to draw your tiles on the big image.

Boudewijn




More information about the Qt-interest-old mailing list