void S60ImageEncoderControl::setImageSettings(const QImageEncoderSettings &settings)
{
    if (!settings.isNull()) {
        // Notify that settings have been implicitly set and there's no need to
        // initialize them in case camera is changed
        m_session->settings()->notifySettingsSet();

        if (!settings.codec().isEmpty())
            m_session->settings()->setImageCodec(settings.codec());

        // Set quality before resolution as quality defines the
        // resolution used in case it's not explicitly set
        m_session->settings()->setImageQuality(settings.quality());
        m_session->settings()->setImageResolution(settings.resolution());

        // Prepare ImageCapture with the settings and set error if needed
        int prepareSuccess = m_session->prepareImageCapture();

        // Preparation fails with KErrNotReady if camera has not been started.
        // That can be ignored since settings are set internally in that case.
        if (prepareSuccess != KErrNotReady && prepareSuccess != KErrNone)
            m_session->setError(prepareSuccess, tr("Failed to apply image settings."), true);
    } else {
        m_session->setError(KErrNotSupported, tr("Unable to set undefined settings."), true);
    }
}
Exemple #2
0
void FSWebCam::setCamera(const QByteArray &cameraDevice)
{
    delete camera;
    delete imageCapture;
    if (cameraDevice.isEmpty()){
        camera = new QCamera;
    }else{
        camera = new QCamera(cameraDevice);
    }
    imageCapture = new QCameraImageCapture(camera);
    QImageEncoderSettings imageSettings = imageCapture->encodingSettings();
        qDebug() << imageCapture->supportedResolutions();
        qDebug() << imageSettings.resolution();
    //QImageEncoderSettings imageSettings;

    #ifdef LINUX
    #else
    imageSettings.setCodec("image/jpeg");
    imageSettings.setResolution(1280, 960);
    #endif

    imageCapture->setEncodingSettings(imageSettings);

    camera->setViewfinder(FSController::getInstance()->controlPanel->ui->viewfinder );
    FSController::getInstance()->controlPanel->ui->cameraLabel->setStyleSheet("border-style: solid; border-color: black; border-width: 3px 1px 3px 1px;");
    FSController::getInstance()->controlPanel->ui->cameraLabel->setText("");
    camera->setCaptureMode(QCamera::CaptureStillImage);

    //connect(imageCapture, SIGNAL(readyForCaptureChanged(bool)), this, SLOT(readyForCapture(bool)));
    connect(imageCapture, SIGNAL(imageCaptured(int,QImage)), this, SLOT(processCapturedImage(int,QImage)));
    connect(imageCapture, SIGNAL(imageSaved(int,QString)), this, SLOT(imageSaved(int,QString)));

    camera->start();
    QStringList res = imageCapture->supportedImageCodecs();
    //QList<QSize> res = imageCapture->supportedResolutions();
    //QSize r;
    QString r;
    foreach(r,res){
        qDebug() << "Supported Resolutions:"<<r;
    }
    qDebug() << "set camera:" << cameraDevice;
}
void AndroidCamImageEncoderControl::setImageSettings(const QImageEncoderSettings &settings)
{
    m_imageSettings.clear();
    if(settings.codec() == QLatin1String("JPEG"))
    {
        m_imageSettings.append(256);
    }
    else if(settings.codec() == QLatin1String("NV21"))
    {
        m_imageSettings.append(17);
    }
    else if(settings.codec() == QLatin1String("RGB_565"))
    {
        m_imageSettings.append(4);
    }
    else if(settings.codec() == QLatin1String("YUY2"))
    {
        m_imageSettings.append(20);
    }
    else
    {
        m_imageSettings.append(256);
    }
    QSize resolution = settings.resolution();
    if(!resolution.isEmpty())
    {
        m_imageSettings.append(resolution.width());
        m_imageSettings.append(resolution.height());
    }
    else
    {
        m_imageSettings.append(QtCameraJni::getSupportedImageResolutions().at(0));
        m_imageSettings.append(QtCameraJni::getSupportedImageResolutions().at(1));
    }
    QtCameraJni::setImageSettings(m_imageSettings);
}