I'm trying to find the fastest way to convert a bunch of QPixmaps from one color table to another color table. Here is how I'm currently doing it:

I have a huge QImage (10K pixel by 10K pixel or more) that I break up into tiles.

The tiles are then converted into QPixmaps and added to the QGraphicsScene.

I keep a backup of the original QImage.

When the user decides to change the color table, this is what I do

Qt Code:
  1. // Grab the table
  2. QVector< QRgb > table;
  3. table = colorTables.find( tableName ).value();
  4.  
  5. // Change the image now (chartImage is my entire QImage)
  6. QImage tempImage = chartImage;
  7.  
  8. // Apply the color table
  9. tempImage.setColorTable( table );
  10.  
  11. // Convert the changed image to pixmap
  12. QPixmap tempPix;
  13. tempPix = tempPix.fromImage( tempImage);
  14.  
  15. // For every tile...
  16. // Update every tile
  17. for( int ii = 0; ii < tiles.size(); ii++ )
  18. {
  19. // Update this tile's pixmap
  20. tiles[ ii ]->setPixmap( tempPix.copy( tiles[ ii ]->getTopLeft().x(),
  21. tiles[ ii ]->getTopLeft().y(), tileSize, tileSize ) );
  22. }
To copy to clipboard, switch view to plain text mode 

This is what setPixmap does (inside the tiles vector)

Qt Code:
  1. void ChartTile::setPixmap( QPixmap pixmap )
  2. {
  3. // Keep a local copy of the QPixmap
  4. image = pixmap;
  5. // Set my QGraphicsPixmapItem* to point to this new QPixmap
  6. // This QGraphicsPixmapItem* is already added to the QGraphicsScene
  7. pixPoint->setPixmap( image );
  8. }
To copy to clipboard, switch view to plain text mode 

But as you can imagine... due to the large size of this QImage, this takes anywhere from 16 - 40 seconds to complete.

How would you guys optimize something like this? I've tried having the QPixmaps in the tiles convert to smaller QImages, change those smaller QImages, then convert back to a QPixmap, but the result is the same. Slow.

Any input is appreciated. Constructive input, that is.