Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-96705

The preview parameter from imageCaptured() can no longer be used as image source (QML)

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 6.2.0 RC
    • Fix Version/s: 6.2.0, 6.2.1, 6.2, 6.3.0 Alpha
    • Component/s: Multimedia
    • Labels:
      None
    • Platform/s:
      All
    • Commits:
      31fa752209c4a6dfbd0aa7874350fd0ba37f8623 (qt/qtmultimedia/dev) 255e8cde23ae609f5109cb3caff639fbbae23334 (qt/qtmultimedia/6.2) 0df6cc0151a6c6dc564b2cee2bcf34182baa5243 (qt/qtmultimedia/6.2.0)

      Description

      In Qt5, the imageCaptured signal was embedded a URL as in the preview parameter. In Qt6, this parameter is now a QVariant(QImage).

      While this can be useful, it breaks the usage of the preview parameter as a Image.source. The documentation still states that it can be used as such though.

      qml: QVariant(QImage, QImage(QSize(1280, 720),format=QImage::Format_RGB32,depth=32,devicePixelRatio=1,bytesPerLine=5120,sizeInBytes=3686400))
      Error: Cannot assign QImage to QUrl

      Questions:

      • Is this expected?
      • Is there another way to grasp the preview image from QML?

      Here is a sample to reproduce the behavior:

      import QtQuick
      import QtQuick.Controls
      import QtMultimedia
      
      Window {
          id: root
      
          width: 1024
          height: 600
          visible: true
      
          CaptureSession {
              id: captureSession
              videoOutput: output
              camera: Camera {} 
              imageCapture: ImageCapture {
                  onImageCaptured: function (id, preview) {
                      console.log(preview)
                      image.source = preview
                  }
              }
          }
      
          VideoOutput {
              id: output
              anchors.fill: parent
              Button {
                  text: qsTr("Shot!")
                  onClicked: captureSession.imageCapture.capture()
              }
          }
      
          Window {
              x: root.x - width
              y: root.y
              width: 250
              height: 250
              Image {
                  id: image
                  anchors.fill: parent
                  fillMode: Image.PreserveAspectFit
              }
          }
      
          Component.onCompleted: captureSession.camera.start()
      }
      

        Attachments

        For Gerrit Dashboard: QTBUG-96705
        # Subject Branch Project Status CR V

          Activity

            People

            Assignee:
            laknoll Lars Knoll
            Reporter:
            c.lorquet Cyril Lorquet
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes