I was wondering if anyone here could look at this code and tell me what would be the best container to use for merging pixmaps and still be fast and efficient.
This code is from the practical qt book and had to modified to work with qt4.
I noticed in assistant it says that a Q3ValueList is provided to keep old code working and they strongly advise not to use it. What would be a good replacement?. Here is the code. Thanks
#include <qapplication.h>
#include <qpixmap.h>
#include <q3valuelist.h>
#include <qlabel.h>
typedef Q3ValueList<QPixmap> PixmapList;
QPixmap pixmapMerge( const PixmapList& pixmaps )
{
int width = 0;
int height = 0;
for ( PixmapList::ConstIterator it = pixmaps.begin(); it != pixmaps.end(); ++it )
{
height += (*it).height();
width = QMAX( width, (*it).width() );
}
QPixmap NewImage( width, height );
int x = 0;
for ( PixmapList::ConstIterator it2 = pixmaps.begin(); it2 != pixmaps.end(); ++it2 )
{
bitBlt( &NewImage, 0, x, &(*it2) );
x += (*it2).height();
}
return NewImage;
}
int main( int argc, char** argv )
{
QApplication app( argc, argv );
QPixmap pixmap1( "./image1.png" );
QPixmap pixmap2( "./image2.png" );
QPixmap pixmap3( "./image3.png" );
PixmapList list;
list.append(pixmap1);
list.append(pixmap2);
list.append(pixmap3);
QPixmap p = pixmapMerge( list );
QLabel* label = new QLabel( 0 );
label->setPixmap( p );
label->resize( p.size() );
label->show();
return app.exec();
}
Bookmarks