void MainWindow::renderingFinished() { QImage img; auto map = futureWatcher.result(); if (map != nullptr) { if (auto heightmap = dynamic_cast<const HeightMap*>(map)) { img = heightmapToImage(heightmap->data); } else if (auto colormap = dynamic_cast<const ColorMap*>(map)) { img = colormapToImage(colormap->data); } else { Q_ASSERT(0); } } QString msg; if (img.size().isNull()) { msg = tr("No output image"); } else { int w = qMin(ui->image->maximumWidth(), img.width()); int h = qMin(ui->image->maximumHeight(), img.height()); ui->image->setPixmap(QPixmap::fromImage(img).scaled(w, h, Qt::KeepAspectRatio)); int timeElapsed = updateStartTime.elapsed(); msg = QString(tr("Rendering finished in %1 ms")).arg(timeElapsed); } statusBar()->showMessage(msg); }
int main(int argc, char * argv[] ) { struct cmdlineInfo cmdline; FILE * ifP; int format; struct pam colormapPam; struct pam outpam; tuple ** colormapRaster; tupletable2 colormap; pnm_init(&argc, argv); parseCommandLine(argc, argv, &cmdline); ifP = pm_openr(cmdline.inputFilespec); computeColorMapFromInput(ifP, cmdline.allcolors, cmdline.newcolors, cmdline.methodForLargest, cmdline.methodForRep, &format, &colormapPam, &colormap); pm_close(ifP); colormapToImage(format, &colormapPam, colormap, cmdline.sort, cmdline.square, &outpam, &colormapRaster); if (cmdline.verbose) pm_message("Generating %u x %u image", outpam.width, outpam.height); outpam.file = stdout; pnm_writepam(&outpam, colormapRaster); pnm_freetupletable2(&colormapPam, colormap); pnm_freepamarray(colormapRaster, &outpam); pm_close(stdout); return 0; }