Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Drawing glow pulsing image animation
Forum Updated to NodeBB v4.3 + New Features

Drawing glow pulsing image animation

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
8 Posts 2 Posters 1.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Marek Belisko
    wrote on last edited by
    #1

    Hi,

    I'm trying to draw glow image on top of background image. Code looks like (called when some even occur):

     QImage image = QImage();
     image.load("image1.png");
    
     QPainter p;
     if (!p.begin(&image)) {
           qDebug() << "Cannot begin painter";
     }
     p.drawImage(QRect(120, 120, 240, 240), QImage("image_center.png"));
      
    ...
    

    So basically I have image in center of other image. Question is how to implement some animation (pulsing center image) for center image. I was looking into QPropertyAnimation but I'm unsure how to do it in this case when one image is overlay to other ones. Thanks a lot for any pointers.

    jsulmJ 1 Reply Last reply
    0
    • M Marek Belisko

      Hi,

      I'm trying to draw glow image on top of background image. Code looks like (called when some even occur):

       QImage image = QImage();
       image.load("image1.png");
      
       QPainter p;
       if (!p.begin(&image)) {
             qDebug() << "Cannot begin painter";
       }
       p.drawImage(QRect(120, 120, 240, 240), QImage("image_center.png"));
        
      ...
      

      So basically I have image in center of other image. Question is how to implement some animation (pulsing center image) for center image. I was looking into QPropertyAnimation but I'm unsure how to do it in this case when one image is overlay to other ones. Thanks a lot for any pointers.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Marek-Belisko If this animation is static you could simply use an animated GIF.

      "QPropertyAnimation but I'm unsure how to do it in this case when one image is overlay to other ones" - ell, since you're rewriting the whole image in each iteration it should work. I just don't know what exactly you want to animate (the size of the second image?).

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      M 1 Reply Last reply
      0
      • M Offline
        M Offline
        Marek Belisko
        wrote on last edited by
        #3

        I'll try to use animated gif file.
        My intention is to be able to change frequency of breathing in animation and not update gif file all the time.
        I'm rewriting image only when some event happens -> it can be 3-4 secs but breathing should be in 1sec or so. Can I hook QPropertyAnimation to QPainter when I'm writing center image?

        What I'm trying to achieve is something like: https://drive.google.com/file/d/1jwSo2i09wJQM1oEoFWY9qJVA3uyI0ZDP/view?usp=sharing

        Thanks.

        jsulmJ 1 Reply Last reply
        0
        • M Marek Belisko

          I'll try to use animated gif file.
          My intention is to be able to change frequency of breathing in animation and not update gif file all the time.
          I'm rewriting image only when some event happens -> it can be 3-4 secs but breathing should be in 1sec or so. Can I hook QPropertyAnimation to QPainter when I'm writing center image?

          What I'm trying to achieve is something like: https://drive.google.com/file/d/1jwSo2i09wJQM1oEoFWY9qJVA3uyI0ZDP/view?usp=sharing

          Thanks.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Marek-Belisko said in Drawing glow pulsing image animation:

          Can I hook QPropertyAnimation to QPainter when I'm writing center image?

          You could add a custom property to your class and in its set method do the drawing of the image and then call update() which triggers paintEvent where you show the image :-)

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • jsulmJ jsulm

            @Marek-Belisko If this animation is static you could simply use an animated GIF.

            "QPropertyAnimation but I'm unsure how to do it in this case when one image is overlay to other ones" - ell, since you're rewriting the whole image in each iteration it should work. I just don't know what exactly you want to animate (the size of the second image?).

            M Offline
            M Offline
            Marek Belisko
            wrote on last edited by
            #5

            I have pushed my code which I'm using for testing here: https://github.com/nandra/qml-test/blob/master/imageprocessor.cpp.
            My idea is to have background image changed based on event and also in middle have breathing glow. I tried to add gif image but it's static only and no animation is performed. I pushed more less whole code. Is my approach correct or am I completely on wrong track? Thanks.

            jsulmJ 1 Reply Last reply
            0
            • M Marek Belisko

              I have pushed my code which I'm using for testing here: https://github.com/nandra/qml-test/blob/master/imageprocessor.cpp.
              My idea is to have background image changed based on event and also in middle have breathing glow. I tried to add gif image but it's static only and no animation is performed. I pushed more less whole code. Is my approach correct or am I completely on wrong track? Thanks.

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Marek-Belisko There is no animation, right?

              p.drawImage(QRect(120, 120, 240, 240), QImage(GLOW_IMAGE_PATH)); // Fix numbers here
              

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • M Offline
                M Offline
                Marek Belisko
                wrote on last edited by
                #7

                Yes this is actual code I have now without animation. I'm unsure how to add animation to that :)

                jsulmJ 1 Reply Last reply
                0
                • M Marek Belisko

                  Yes this is actual code I have now without animation. I'm unsure how to add animation to that :)

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @Marek-Belisko I already gave you a hint.

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved