Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

mosaic.h File Reference

#include "manipulationOptions.h"
#include <qsize.h>

Include dependency graph for mosaic.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  MosaicOptions

Functions

QImage * mosaicEffect (QString filename, MosaicOptions *options)


Function Documentation

QImage* mosaicEffect QString  filename,
MosaicOptions options
 

Definition at line 290 of file mosaic.cpp.

References colorTiles, constructColorTiles(), constructImageTiles(), editedImage, MosaicOptions::getFileList(), ManipulationOptions::getStatus(), MosaicOptions::getTileSize(), imageTiles, StatusWidget::incrementProgress(), newProgress, StatusWidget::showProgressBar(), splatBestTile(), status, and updateIncrement.

Referenced by EditingInterface::applyEffect().

00291 { 00292 //load image 00293 QImage* editedImage = new QImage( filename ); 00294 00295 //convert to 32-bit depth if necessary 00296 if( editedImage->depth() < 32 ) 00297 { 00298 QImage* tmp = editedImage; 00299 editedImage = new QImage( tmp->convertDepth( 32, Qt::AutoColor ) ); 00300 delete tmp; tmp=NULL; 00301 } 00302 00303 //determine if busy indicators will be used 00304 bool useBusyIndicators = false; 00305 StatusWidget* status = NULL; 00306 if( options != NULL && options->getStatus() != NULL ) 00307 { 00308 useBusyIndicators = true; 00309 status = options->getStatus(); 00310 } 00311 00312 //intialize seed using current time 00313 srand( unsigned(time(NULL)) ); 00314 00315 //determine tile size 00316 QSize tileSize; 00317 if(options == NULL) tileSize = QSize(6,6); //6 is big enough to be visible, but not so blocky the image looks bad 00318 else tileSize =options->getTileSize(); 00319 00320 //construct tile set 00321 TileSet* tileSet = NULL; 00322 if( options != NULL && options->getFileList().size() > 0 ) 00323 { 00324 constructImageTiles(options->getFileList(), tileSize); 00325 tileSet = &imageTiles; 00326 } 00327 else 00328 { 00329 constructColorTiles(tileSize); 00330 tileSet = &colorTiles; 00331 } 00332 00333 //setup progress bar 00334 if(useBusyIndicators) 00335 { 00336 QString statusMessage = qApp->translate( "mosaicEffect", "Applying Mosaic Effect:" ); 00337 status->showProgressBar( statusMessage, 100 ); 00338 qApp->processEvents(); 00339 } 00340 00341 //update progress bar for every 1% of completion 00342 const int updateIncrement = (int) ( (0.01 * editedImage->width() * editedImage->height()) / 00343 (tileSize.width() * tileSize.height()) ); 00344 int newProgress = 0; 00345 00346 //iterate over each selected scanline 00347 int x, y; 00348 for(y=0; y<editedImage->height(); y+=tileSize.height()) 00349 { 00350 for( x=0; x<editedImage->width(); x+=tileSize.width()) 00351 { 00352 //splat the best tile 00353 splatBestTile( editedImage, QPoint(x,y), tileSet ); 00354 00355 //update status bar if significant progress has been made since last update 00356 if(useBusyIndicators) 00357 { 00358 newProgress++; 00359 if(newProgress >= updateIncrement) 00360 { 00361 newProgress = 0; 00362 status->incrementProgress(); 00363 qApp->processEvents(); 00364 } 00365 } 00366 00367 } 00368 } 00369 00370 //return pointer to edited image 00371 return editedImage; 00372 }


Generated on Sun Mar 4 19:43:01 2007 for AlbumShaper by doxygen 1.3.7