Exemplo n.º 1
0
bool ScribbleArea::saveImage(const QString &fileName, const char *fileFormat)
{
    QImage visibleImage = image;
    if (visibleImage.save(fileName, fileFormat)) {
            // Create new doc link
        QContent lnk;
          // Perserve name and category
        lnk.setName(QFileInfo(fileName).baseName() );
          //   lnk.setCategories( _lnk.categories() );
        lnk.setFile( fileName );
        lnk.commit();

        modified = false;
        return true;
    } else {
        return false;
    }
}
Exemplo n.º 2
0
void Screenshot::saveScreenshot()
{
    QString format = "png";
    QString initialPath = QDir::currentPath() + tr("/untitled.") + format;
#ifdef Q_WS_QWS

    QString  fileName = "sc_" + QDateTime::currentDateTime().toString();
    fileName.replace(QRegExp("'"), "");
    fileName.replace(QRegExp(" "), "_");
    fileName.replace(QRegExp(":"), ".");
    fileName.replace(QRegExp(","), "");
    QString dirName = QDir::homePath() + "/Documents/image/png/";

    if ( !QDir( dirName).exists() ) {
        QDir homeDir(QDir::homePath());
        homeDir.mkpath("Documents/image/png");
    }
#else
    QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"),
                       initialPath,
                       tr("%1 Files (*.%2);;All Files (*)")
                       .arg(format.toUpper())
                       .arg(format));
    if (!fileName.isEmpty())
#endif
#ifdef Q_WS_QWS
    QString new_file = dirName+"/"+fileName+".png";
    originalPixmap.save(new_file, format.toAscii());
    QContent content;
    content.setName( fileName);
    content.setFile( new_file );
    content.commit();

#else
    originalPixmap.save(fileName, format.toAscii());
#endif


}
Exemplo n.º 3
0
void CameraMainWindow::takePhotoNow()
{
    QImage img = camera->videocaptureview->image();
    if ( snapRequest != 0 ) {
        // Rescale the image and pop it into a QDSData object
        QImage scaledimg = img.scaled( snap_max,
                                       Qt::KeepAspectRatio,
                                       Qt::SmoothTransformation);
        QByteArray savedImageData;
        {
            QDataStream stream( &savedImageData, QIODevice::WriteOnly );
            stream << QPixmap::fromImage( scaledimg );
        }
        QDSData snappedImage( savedImageData, QMimeType( "image/x-qpixmap" ) );

        // Send response with the data
        snapRequest->respond( snappedImage );

        // Reset snap mode
        setSnapMode( false );
        delete snapRequest;
        snapRequest = 0;

        // Finished serving QDS request so close the application
        close();
        hideWaitScreen();
    } else {
        showWaitScreen();
        QContent f;
        QList<QString> c;

        f.setType("image/jpeg");
        f.setName(tr("Photo, %1","date")
                .arg(QTimeString::localYMDHMS(QDateTime::currentDateTime(),QTimeString::Short)));
        f.setMedia( settings->location->documentPath() );

        c.append(camcat);
        f.setCategories(c);

        QIODevice*  contentDevice = f.open(QIODevice::WriteOnly);

        if (contentDevice != 0)
        {
            QImage  temp = img.convertToFormat(QImage::Format_RGB32);

            temp.save(contentDevice, "JPEG", pquality);

            contentDevice->close();

            f.commit();

            pushThumb(f, img);

            hideWaitScreen();

        }
        else
        {
            QString errorText = f.errorString();
            if (errorText.isEmpty())
                errorText = tr("Unknown error");

            QMessageBox::warning(0,
                                 tr("Error saving photo"),
                                 tr("Could not save photo: %1").arg(errorText));
        }
    }

    preview();
}