Beispiel #1
0
void Plot::exportToPng(QwtPlotRenderer& renderer, const QString& path)
{
    renderer.renderDocument(this, path, getExportSize(), resolution);
}
Beispiel #2
0
void MainWindow2::exportImage()
{
    QSettings settings( PENCIL2D, PENCIL2D );

    // Get the camera layer
    Layer *cameraLayer = mEditor->layers()->currentLayer();
    if (cameraLayer->type() != Layer::CAMERA) {
        QMessageBox::warning( this,
                              tr( "Error" ),
                              tr( "You must select a Camera Layer to export an image." ),
                              QMessageBox::Ok,
                              QMessageBox::Ok );
        return;// false;
    }

    // Options
    auto dialog =  new ExportImageSeqDialog( this );
    OnScopeExit( dialog->deleteLater() );

    dialog->setExportSize( mScribbleArea->getViewRect().toRect().size() );
    dialog->exec();

    QSize exportSize = dialog->getExportSize();
    QString exportFormat = dialog->getExportFormat();
    bool useTranparency = dialog->getTransparency();

    if ( dialog->result() == QDialog::Rejected )
    {
        return; // false;
    }


    // Path
    QString initPath = settings.value( "lastExportPath", QDir::homePath() + "/untitled.png" ).toString();

    QFileInfo info( initPath );
    initPath = info.path() + "/" + info.baseName() + "." + exportFormat.toLower();


    QString filePath = QFileDialog::getSaveFileName( this,
                                                     tr( "Save Image" ),
                                                     initPath);
    if ( filePath.isEmpty() )
    {
        qDebug() << "empty file";
        return;// false;
    }
    settings.setValue( "lastExportPath", QVariant( filePath ) );


    // Export
    QTransform view = RectMapTransform( mScribbleArea->getViewRect(), QRectF( QPointF( 0, 0 ), exportSize ) );
//    view = mScribbleArea->getView() * view;

    int projectLength = mEditor->layers()->projectLength();
    if ( !mEditor->object()->exportIm( mEditor->currentFrame(),
                                       projectLength,
                                       view,
                                       exportSize,
                                       filePath,
                                       exportFormat,
                                       true,
                                       useTranparency ) )
    {
        QMessageBox::warning( this,
                              tr( "Warning" ),
                              tr( "Unable to export image." ),
                              QMessageBox::Ok,
                              QMessageBox::Ok );
        return;// false;
    }
    return; // true;
}