void Coverage::exportScenarioAndCoverageImage(QString filename) { QImage overlay = createImageWithOverlay(*this->coverageImage, *this->scenarioImage); QFile file(filename); file.open(QIODevice::WriteOnly); overlay.save(&file, "PNG"); }
Widget::Widget(QWidget *parent) : QWidget(parent) { QImage baseImage("D:/TobyYi/yibansvn/github-project/OrderManager/QuickViewTest/logo_72.png"); QImage overlayLogoff("D:/TobyYi/yibansvn/ReleaseVerYibanPC/YibanClient/image/skin/tab_btn_close_hover.png"); imgLb = new QLabel(this); QImage logoffImage = createImageWithOverlay(baseImage, overlayLogoff); imgLb->setScaledContents(true); imgLb->setPixmap(QPixmap::fromImage(logoffImage)); imgLb->show(); logoffImage.save("xx.png"); }
bool MainWindow::renderFrame() { QPoint translateOrigin; framePhase++; finalFrame = background; // we start building the final frame by copying it from the "real" background // and then copy the current work background on top of it finalFrame = createImageWithOverlay(finalFrame, workBackground, QPoint(0,0)); if (phase == 1 && framePhase == 1) { curPhotoOrig.load(photos.at(photo)); // do we need to specify that it should have an alpha layer? fullsizecopy = curPhotoOrig; fullsizecopy = fullsizecopy.scaled(HD, Qt::KeepAspectRatio, Qt::SmoothTransformation); xOffset = HD.width()-fullsizecopy.width(); } if (phase == 1) { finalFrame = createImageWithOverlay(finalFrame, fullsizecopy, QPoint(xOffset,0), qreal(framePhase)/qreal(framesPerPhase[1])); } if (phase == 2) { finalFrame = createImageWithOverlay(finalFrame, fullsizecopy, QPoint(xOffset,0)); } if (phase == 3) { currentShrinkFactor -= shrinkPerFrame; currentRotate += rotatePerFrame; translateX += photo % 2 ? transXperFrame2 : transXperFrame1; translateY += photo % 2 ? transYperFrame1 : transYperFrame2; image = curPhotoOrig; image = image.scaled(HD * currentShrinkFactor, Qt::KeepAspectRatio, Qt::SmoothTransformation); translateOrigin = QPoint(translateX, translateY); // half the photos should rotate right and be moved up, other half rotated left and moved down finalFrame = createImageWithOverlay(finalFrame, image, translateOrigin, 1, photo % 2 ? currentRotate : (360-currentRotate) ); // at the end of one photo, we "seal" it to the work background so it can be scrolled if (framePhase == framesPerPhase[3]) workBackground = createImageWithOverlay(workBackground, image, QPoint(translateX, translateY)); } // now write the frame QString filename = QString("%1/%2.png").arg(destDir).arg(frame, 8, 10, QChar('0')); finalFrame.save(filename); ui->photoWidget->setPixmap(QPixmap::fromImage(finalFrame)); // shift the work background workBackground = workBackground.copy(QRect(QPoint(workBGshiftPerFrame, 0), HD)); // other cleanup if (framePhase == framesPerPhase[phase]) { phase++; if (phase == 4) { phase = 1; photo++; if (photo == photos.size()) return false; workBackground = finalFrame; } framePhase = 0; if (phase == 3) { currentShrinkFactor = 1.0; currentRotate = 0.0; translateX = xOffset; translateY = 0; } } return true; }