[Interest] Qt Quick and animatic 12MP image

Ola Røer Thorsen ola at silentwings.no
Wed Sep 5 17:20:14 CEST 2018


2018-09-05 14:08 GMT+02:00 Tomasz Olszak <olszak.tomasz at gmail.com>:

> Hi, I want to animate (change flickable contentX and contentY) image
> position in screen. Image is bigger(4000x3000) than screen. Currently, I
> implemented it on I7 ivybridge on Kubuntu 18.04.
> It simply stutters few times a second. If anyone has integrated Intel GPU
> - could I kindly ask to check if it also stutter for him? Is it a GPU limit
> to handle such big texture or perhaps I can tweak something to make it
> fluent:
>
>
Instead of flickable i'd use GridView (which uses flickable). Only the
items actually on screen will be instantiated, so it scales much better.

If your real case is an image and your GPU supports texture sizes as big as
your image size then maybe something like this could be faster (let a
shader to the zooming/cropping):


import QtQuick 2.9

import QtQuick.Window 2.2


Window {

    visible: true

    width: 640

    height: 480


    Image {

        id: img

        source:
"http://www.letsgodigital.org/images/producten/1515/testrapport/underwater-photos.jpg"

        visible: false

    }


    Flickable {

        anchors.fill: parent

        id: flicker

        contentWidth: dummyFlickItem.width

        contentHeight: dummyFlickItem.height


        Item {

            id: dummyFlickItem

            width: img.sourceSize.width

            height: img.sourceSize.height

        }

    }


    ShaderEffect {

        anchors.fill: flicker

        property variant src: img

        property real xPosition: flicker.visibleArea.xPosition

        property real yPosition: flicker.visibleArea.yPosition

        property real widthRatio: flicker.visibleArea.widthRatio

        property real heightRatio: flicker.visibleArea.heightRatio


        vertexShader: "

                  uniform highp mat4 qt_Matrix;

                  attribute highp vec4 qt_Vertex;

                  attribute highp vec2 qt_MultiTexCoord0;


                  uniform highp float xPosition;

                  uniform highp float yPosition;

                  uniform highp float widthRatio;

                  uniform highp float heightRatio;


                  varying highp vec2 coord;

                  void main() {

                      coord.x = xPosition + widthRatio*qt_MultiTexCoord0.x;

                      coord.y = yPosition + heightRatio*qt_MultiTexCoord0.y;

                      gl_Position = qt_Matrix * qt_Vertex;

                  }"

        fragmentShader: "

                  varying highp vec2 coord;

                  uniform sampler2D src;

                  uniform lowp float qt_Opacity;

                  void main() {

                      gl_FragColor = texture2D(src, coord);

                  }"

    }

}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20180905/97d31158/attachment.html>


More information about the Interest mailing list