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. How to manipulate with Canvas image in C++ code?

How to manipulate with Canvas image in C++ code?

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 2.2k 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.
  • Z Offline
    Z Offline
    zvava
    wrote on last edited by
    #1

    Hello!
    I have used Qt 4.8.4 and have had C++ component which have been derived from QDeclarativeItem with my method "void paint(QPainter *p, const QStyleOptionGraphicsItem *s, QWidget *w);"
    I moved my project to Qt 5 and there was a lot of lags and I tried to use new QML item "Canvas" with "renderStrategy: Canvas.Threaded"/ It works really good for me but now I have problem...
    I have a lot of C++ code which manipulate with pixels of my "old item" and i don't want to move it in QML.
    How can I get Image in C++ from QML Canvas element?
    I have tried to send "CanvasImageData" and "CanvasImageData.data" elements from my canvas's context (canvas.context.getImageData) but it was failed ((
    Please, help me
    PS. I really need to get image data in C++ code. Don't advise me to move my C++ code to QML.

    1 Reply Last reply
    0
    • V Offline
      V Offline
      Vincent007
      wrote on last edited by
      #2

      http://qt-project.org/doc/qt-5/qml-qtquick-canvas.html#save-method

      bool save(string filename)

      Save the current canvas content into an image file filename. The saved image format is automatically decided by the filename's suffix.

      Note: calling this method will force painting the whole canvas, not just the current canvas visible window.

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        zvava
        wrote on last edited by
        #3

        This method is bad for me because there is some lags while saving...

        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