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. Invert greyscale Image?

Invert greyscale Image?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 525 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.
  • P Offline
    P Offline
    patrickkidd
    wrote on last edited by
    #1

    I am using greyscale Image for png-based buttons. I need to invert the image bitmap when the background changes from white to black. How is this possible?

    Thanks!

    https://alaskafamilysystems.com/

    P 1 Reply Last reply
    0
    • P patrickkidd

      I am using greyscale Image for png-based buttons. I need to invert the image bitmap when the background changes from white to black. How is this possible?

      Thanks!

      P Offline
      P Offline
      patrickkidd
      wrote on last edited by
      #2

      @patrickkidd This did it, and required making an all-white mask png:

      import QtQuick 2.12
      import QtGraphicalEffects 1.13
      
      Rectangle {
      
          id: root
          property string source: 'icon.png'
          property bool inverted: true    
      
          height: 200
          width: 300
      
          Image {
              id: mainImage
              source: root.source
              anchors.fill: parent
              visible: !inverted
          }
      
          Image {
              id: allWhite
              visible: false
              source: 'resources/all-white.png'
          }
      
          Blend {
              visible: inverted
              source: mainImage
              foregroundSource: allWhite
              mode: 'negation'
              anchors.fill: parent
          }
      }
      

      https://alaskafamilysystems.com/

      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