00291 {
00292
00293 QImage*
editedImage =
new QImage( filename );
00294
00295
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
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
00313 srand(
unsigned(time(NULL)) );
00314
00315
00316 QSize tileSize;
00317
if(options == NULL) tileSize = QSize(6,6);
00318
else tileSize =options->
getTileSize();
00319
00320
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
00334
if(useBusyIndicators)
00335 {
00336 QString statusMessage = qApp->translate(
"mosaicEffect",
"Applying Mosaic Effect:" );
00337
status->
showProgressBar( statusMessage, 100 );
00338 qApp->processEvents();
00339 }
00340
00341
00342
const int updateIncrement = (
int) ( (0.01 *
editedImage->width() *
editedImage->height()) /
00343 (tileSize.width() * tileSize.height()) );
00344
int newProgress = 0;
00345
00346
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
00353
splatBestTile( editedImage, QPoint(x,y), tileSet );
00354
00355
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
00371
return editedImage;
00372 }