Results 1 to 4 of 4

Thread: animated image in a schadermask

  1. #1
    Join Date
    Jul 2015
    Posts
    2
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default animated image in a schadermask

    Hi,

    I tried to make a animated Icon in a special mask.

    Icon_Blink.jpgIcon_Kranz.jpg

    The blue pixmap rotate and can only seen in the black area.
    For that I use the maskshader form http://doc.qt.io/qt-4.8/http://doc.qt.io/qt-5/qml-qtquick-shadereffect.html

    qml-code snippet:

    Image {
    id: color
    width: 200
    height: 200
    source: "/Icon_Blink.png"
    anchors.centerIn: parent

    //does not work
    RotationAnimation on rotation {
    loops: Animation.Infinite
    from: 0
    to: 360
    duration: 500
    }
    }

    Image {
    id: mask
    anchors.fill: logo
    source: "/Icon_Kranz.png"
    layer.enabled: true
    layer.samplerName: "maskSource"
    layer.effect: ShaderEffect {
    property var colorSource: ShaderEffectSource { sourceItem: color; hideSource: true}
    fragmentShader: "
    uniform lowp sampler2D colorSource;
    uniform lowp sampler2D maskSource;
    uniform lowp float qt_Opacity;
    varying highp vec2 qt_TexCoord0;
    void main() {
    gl_FragColor =
    texture2D(colorSource, qt_TexCoord0)
    * texture2D(maskSource, qt_TexCoord0).a
    * qt_Opacity;
    }
    "
    }
    }

    The backgound have to be alpha = 0.

    Is there a way to rotate the surceimage of the Image or in the shader?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: animated image in a schadermask

    You can place the image in an item, rotate the image and create ShaderEffectSource from that item instead of the image.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jul 2015
    Posts
    2
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: animated image in a schadermask

    Insane! Thanks

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: animated image in a schadermask

    By the way, when using an Image, you don't need a ShaderEffectSource operating on it, you can reference the image item directly.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Animated GIF Problem
    By MSUdom5 in forum Qt Programming
    Replies: 9
    Last Post: 25th January 2016, 07:29
  2. best way for a own animated loader?
    By janton in forum Newbie
    Replies: 2
    Last Post: 28th February 2012, 20:52
  3. Pb with animated gif on Mac os
    By mourad in forum Qt Programming
    Replies: 0
    Last Post: 17th April 2008, 14:38
  4. Animated Cursor
    By kemp in forum Qt Programming
    Replies: 1
    Last Post: 22nd January 2007, 08:53
  5. animated gif's
    By :db:sStrong in forum Newbie
    Replies: 2
    Last Post: 31st May 2006, 16:22

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.