diff --git a/symbian/QQrDecoder/MyVideoSurface.cpp b/symbian/QQrDecoder/MyVideoSurface.cpp index cc7ee5719..635a407be 100644 --- a/symbian/QQrDecoder/MyVideoSurface.cpp +++ b/symbian/QQrDecoder/MyVideoSurface.cpp @@ -6,6 +6,10 @@ MyVideoSurface::MyVideoSurface(QWidget* widget, VideoIF* target, QObject* parent m_targetWidget = widget; m_target = target; m_imageFormat = QImage::Format_Invalid; + + timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), this, SLOT(sendImageToDecode())); + timer->start(500); } MyVideoSurface::~MyVideoSurface() @@ -77,3 +81,20 @@ QList MyVideoSurface::supportedPixelFormats( } } +void MyVideoSurface::sendImageToDecode() +{ + if (m_frame.map(QAbstractVideoBuffer::ReadOnly)) { + QImage image( + m_frame.bits(), + m_frame.width(), + m_frame.height(), + m_frame.bytesPerLine(), + m_imageFormat); + + if (!image.isNull()) + emit imageCaptured(image); + + m_frame.unmap(); + } +} + diff --git a/symbian/QQrDecoder/QCameraControllerWidget.cpp b/symbian/QQrDecoder/QCameraControllerWidget.cpp index 28e0d0e56..84beec662 100644 --- a/symbian/QQrDecoder/QCameraControllerWidget.cpp +++ b/symbian/QQrDecoder/QCameraControllerWidget.cpp @@ -90,7 +90,7 @@ QCameraControllerWidget::QCameraControllerWidget(QWidget *parent) : m_stackedWidget->addWidget(secondWidget); m_stackedWidget->setCurrentIndex(0); - hboxl->addWidget(m_stackedWidget); + // Buttons QSize iconSize(80, 80); @@ -98,23 +98,24 @@ QCameraControllerWidget::QCameraControllerWidget(QWidget *parent) : vboxl->setSpacing(0); vboxl->setMargin(0); - // Exit button - m_exit = new Button(this); - QObject::connect(m_exit, SIGNAL(pressed()), qApp, SLOT(quit())); - QPixmap p = QPixmap(":/icons/exit.png"); - m_exit->setPixmap(p.scaled(iconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation)); - vboxl->addWidget(m_exit); - vboxl->setAlignment(m_exit,Qt::AlignHCenter | Qt::AlignTop); + zoomIn = new Button(this); + QObject::connect(zoomIn, SIGNAL(pressed()), this, SLOT(onZoomIn())); + QPixmap p = QPixmap(":/icons/zoomIn"); + zoomIn->setPixmap(p.scaled(iconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation)); + vboxl->addWidget(zoomIn); + vboxl->setAlignment(zoomIn,Qt::AlignTop | Qt::AlignHCenter); - // Camera button - m_cameraBtn = new Button(this); - QObject::connect(m_cameraBtn, SIGNAL(pressed()), this, SLOT(searchAndLock())); - p = QPixmap(":/icons/camera.png"); - m_cameraBtn->setPixmap(p.scaled(iconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation)); - vboxl->addWidget(m_cameraBtn); - vboxl->setAlignment(m_cameraBtn, Qt::AlignBottom); + zoomOut = new Button(this); + QObject::connect(zoomOut, SIGNAL(pressed()), this, SLOT(onZoomOut())); + p = QPixmap(":/icons/zoomOut"); + zoomOut->setPixmap(p.scaled(iconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation)); + vboxl->addWidget(zoomOut); + vboxl->setAlignment(zoomOut, Qt::AlignBottom | Qt::AlignHCenter); + //hboxl->addLayout(vboxl); + hboxl->addWidget(m_stackedWidget); hboxl->addLayout(vboxl); + setLayout(hboxl); // Enable camera after 1s, so that the application is started @@ -139,6 +140,7 @@ void QCameraControllerWidget::enableCamera() m_camera->setCaptureMode(QCamera::CaptureStillImage); connect(m_camera, SIGNAL(error(QCamera::Error)), this, SLOT(error(QCamera::Error))); connect(m_camera, SIGNAL(lockStatusChanged(QCamera::LockStatus,QCamera::LockChangeReason)), this, SLOT(lockStatusChanged(QCamera::LockStatus,QCamera::LockChangeReason))); + connect(m_camera, SIGNAL(stateChanged( QCamera::State) ), this, SLOT(onStateChanged(QCamera::State))); // Own video output drawing that shows camera view finder pictures //! [0] @@ -146,6 +148,9 @@ void QCameraControllerWidget::enableCamera() QVideoRendererControl* vrc = ms->requestControl(); m_myVideoSurface = new MyVideoSurface(this,this,this); vrc->setSurface(m_myVideoSurface); + + connect(m_myVideoSurface, SIGNAL(imageCaptured(QImage)), this, SLOT(redirectImageSignalFromVideoFinder(QImage))); + //! [0] // Image capturer m_stillImageCapture = new QCameraImageCapture(m_camera); @@ -158,6 +163,10 @@ void QCameraControllerWidget::enableCamera() m_videoWidget->show(); m_camera->start(); showViewFinder = true; + + cameraFocus = m_camera->focus(); + // cameraFocus->setFocusMode(QCameraFocus::ContinuousFocus); + // cameraFocus->setFocusPointMode(QCameraFocus::FocusPointAuto); } void QCameraControllerWidget::mousePressEvent(QMouseEvent *event) @@ -337,18 +346,63 @@ void QCameraControllerWidget::paintEvent(QPaintEvent *event) // Draw black painter.fillRect(event->rect(), palette().background()); // Show captured image - if (pictureCaptured) { - // Paint captured image - QPoint centerPic((qAbs(r.size().width() - m_capturedImage.size().width())) / 2, (qAbs( - r.size().height() - m_capturedImage.size().height())) / 2); +// if (pictureCaptured) { +// // Paint captured image +// QPoint centerPic((qAbs(r.size().width() - m_capturedImage.size().width())) / 2, (qAbs( +// r.size().height() - m_capturedImage.size().height())) / 2); - painter.drawImage(centerPic, m_capturedImage); +// painter.drawImage(centerPic, m_capturedImage); - // Paint filename - // painter.drawText(r, Qt::AlignBottom | Qt::AlignCenter, m_imageName); - } +// // Paint filename +// // painter.drawText(r, Qt::AlignBottom | Qt::AlignCenter, m_imageName); +// } } +} +void QCameraControllerWidget::redirectImageSignalFromVideoFinder(QImage image) +{ + emit imageCaptured(image); } +void QCameraControllerWidget::onZoomIn() +{ + qreal optical = cameraFocus->opticalZoom(); + qreal digital = cameraFocus->digitalZoom(); + + if(optical == cameraFocus->maximumOpticalZoom()) + cameraFocus->zoomTo(optical, digital + 0.1); + else + cameraFocus->zoomTo(optical + 0.1, 1.0); +} + +void QCameraControllerWidget::onZoomOut() +{ + qreal optical = cameraFocus->opticalZoom(); + qreal digital = cameraFocus->digitalZoom(); + + + if(optical == cameraFocus->maximumOpticalZoom() && digital != 0.0) + { + if(digital - 0.1 >= 1) + cameraFocus->zoomTo(optical, digital - 0.1); + else + cameraFocus->zoomTo(optical, 1.0); + } + else + { + if(optical - 0.1 >= 1) + cameraFocus->zoomTo(optical - 0.1, 1.0); + else + cameraFocus->zoomTo(1.0, 1.0); + } +} + +void QCameraControllerWidget::onStateChanged(QCamera::State state) +{ + if(state == QCamera::ActiveState) + { + // cameraFocus->setFocusMode(QCameraFocus::AutoFocus); + // cameraFocus->setFocusPointMode(QCameraFocus::FocusPointAuto); + } +} diff --git a/symbian/QQrDecoder/QCameraControllerWidget.h b/symbian/QQrDecoder/QCameraControllerWidget.h index 13b3fdff6..3bbce5501 100644 --- a/symbian/QQrDecoder/QCameraControllerWidget.h +++ b/symbian/QQrDecoder/QCameraControllerWidget.h @@ -48,6 +48,7 @@ // the Multimedia API is not in the QtMobility namespace "QTM_USE_NAMESPACE" #include #include +#include // QtMobility API //#include @@ -78,6 +79,11 @@ public slots: void captureImage(); void onImageCaptured(int id, const QImage &preview); void error(QCamera::Error); + void redirectImageSignalFromVideoFinder(QImage image); + + void onStateChanged(QCamera::State state) ; + void onZoomIn(); + void onZoomOut(); signals: @@ -85,13 +91,13 @@ signals: private: QWidget* m_videoWidget; + QWidget* zoomButtons; QCamera* m_camera; QCameraImageCapture* m_stillImageCapture; QStackedWidget* m_stackedWidget; - Button* m_exit; - Button* m_cameraBtn; - Button* m_mms; + Button* zoomIn; + Button* zoomOut; QImage m_capturedImage; QString m_imageName; QString m_focusMessage; @@ -102,7 +108,7 @@ private: bool pictureCaptured; bool showViewFinder; MyVideoSurface* m_myVideoSurface; - //QSystemScreenSaver* m_systemScreenSaver; + QCameraFocus* cameraFocus; }; #endif // QCAMERA_H diff --git a/symbian/QQrDecoder/QQrDecoder.pro b/symbian/QQrDecoder/QQrDecoder.pro index 018e86cf6..ecbcadcea 100644 --- a/symbian/QQrDecoder/QQrDecoder.pro +++ b/symbian/QQrDecoder/QQrDecoder.pro @@ -3,7 +3,7 @@ TARGET = QQrDecoder QT += core \ gui -VERSION = 1.1.0 +VERSION = 1.2.0 CONFIG += mobility MOBILITY = multimedia #\ diff --git a/symbian/QQrDecoder/QQrDecoder.sis b/symbian/QQrDecoder/QQrDecoder.sis index c0359f947..7e2e0caf7 100644 Binary files a/symbian/QQrDecoder/QQrDecoder.sis and b/symbian/QQrDecoder/QQrDecoder.sis differ diff --git a/symbian/QQrDecoder/icons/camera.png b/symbian/QQrDecoder/icons/camera.png deleted file mode 100644 index dc4ecbf74..000000000 Binary files a/symbian/QQrDecoder/icons/camera.png and /dev/null differ diff --git a/symbian/QQrDecoder/icons/exit.png b/symbian/QQrDecoder/icons/exit.png deleted file mode 100644 index dbe586a93..000000000 Binary files a/symbian/QQrDecoder/icons/exit.png and /dev/null differ diff --git a/symbian/QQrDecoder/icons/zoomIn.png b/symbian/QQrDecoder/icons/zoomIn.png new file mode 100644 index 000000000..bfb0c1860 Binary files /dev/null and b/symbian/QQrDecoder/icons/zoomIn.png differ diff --git a/symbian/QQrDecoder/icons/zoomOut.png b/symbian/QQrDecoder/icons/zoomOut.png new file mode 100644 index 000000000..4741de331 Binary files /dev/null and b/symbian/QQrDecoder/icons/zoomOut.png differ diff --git a/symbian/QQrDecoder/myvideosurface.h b/symbian/QQrDecoder/myvideosurface.h index db19a4a8f..1a4d95e7b 100644 --- a/symbian/QQrDecoder/myvideosurface.h +++ b/symbian/QQrDecoder/myvideosurface.h @@ -9,6 +9,7 @@ #include #include #include +#include class VideoIF { @@ -33,12 +34,19 @@ public: void paint(QPainter*); +public slots: + void sendImageToDecode(); + +signals: + void imageCaptured(QImage image); + private: QWidget* m_targetWidget; VideoIF* m_target; QVideoFrame m_frame; QImage::Format m_imageFormat; QVideoSurfaceFormat m_videoFormat; + QTimer* timer; }; #endif // MYVIDEOSURFACE_H diff --git a/symbian/QQrDecoder/resources.qrc b/symbian/QQrDecoder/resources.qrc index f9ad84bb1..81169bbba 100644 --- a/symbian/QQrDecoder/resources.qrc +++ b/symbian/QQrDecoder/resources.qrc @@ -1,6 +1,8 @@ - icons/camera.png - icons/exit.png + icons/camera.png + icons/exit.png + icons/zoomIn.png + icons/zoomOut.png