Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Canvas element context putImageData issue
QtWS25 Last Chance

Canvas element context putImageData issue

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 2 Posters 896 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.
  • cmessineoC Offline
    cmessineoC Offline
    cmessineo
    wrote on last edited by
    #1

    This code worked in Qt 5.3.2, but since I upgraded to Qt 5.5.1 it doesn't work anymore.
    I'm guessing putImageData has changed but I can't find any examples of it's use.

    Any ideas?
    Thanks

    @
    Canvas{
    width: 300
    height: 300

        onPaint:{
            var ctx = getContext("2d");
            ctx.fillStyle = "red";
            ctx.fillRect(10,10, 50, 50);
            var copy = ctx.getImageData(10,10,50,50);
            ctx.putImageData(copy, 20, 20);
        }
    

    }

    @

    p3c0P 1 Reply Last reply
    0
    • cmessineoC cmessineo

      This code worked in Qt 5.3.2, but since I upgraded to Qt 5.5.1 it doesn't work anymore.
      I'm guessing putImageData has changed but I can't find any examples of it's use.

      Any ideas?
      Thanks

      @
      Canvas{
      width: 300
      height: 300

          onPaint:{
              var ctx = getContext("2d");
              ctx.fillStyle = "red";
              ctx.fillRect(10,10, 50, 50);
              var copy = ctx.getImageData(10,10,50,50);
              ctx.putImageData(copy, 20, 20);
          }
      

      }

      @

      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @cmessineo It seems it works using Qt5.6 on Ubuntu 14.04. It shows a red rectangle if thats is what you are expecting.

      157

      1 Reply Last reply
      0
      • cmessineoC Offline
        cmessineoC Offline
        cmessineo
        wrote on last edited by
        #3

        I would expect to see two red rectangles. One overlapping the one at the 10, 10 position.

        1 Reply Last reply
        0
        • cmessineoC Offline
          cmessineoC Offline
          cmessineo
          wrote on last edited by
          #4

          Well apparently you need to use:

          ctx.drawImage(copy, 20, 20);

          to make it work.

          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