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. QML canvas.save() or Item grabToImage() create a png file with transparent background

QML canvas.save() or Item grabToImage() create a png file with transparent background

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 4 Posters 2.4k Views 1 Watching
  • 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.
  • T Offline
    T Offline
    Tân Ngọc Đỗ
    wrote on last edited by A Former User
    #1

    Hello guys,

    I have a picture drawn on Qml canvas. I want to store that picture by calling canvas.save() or cavas.grabToImage() .
    When I tried to save with "png" type , my image have a black background but the image generated with a transparent background like this: https://bugreports.qt.io/browse/QTBUG-44288
    Saving to Jpeg or bmp is ok.

    Could you please help ?

    Thank you!

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @Tân-Ngọc-Đỗ Isn't it a bug then ?

      157

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        I'd be cool if people would vote the bug up

        1 Reply Last reply
        0
        • V Offline
          V Offline
          VinamraKumarJha
          wrote on last edited by VinamraKumarJha
          #4
          Canvas
          {
              id: canvas
              anchors
              {
                  fill       : parent
              }
              // antialiasing: true
          
              onPaint:
              {
                  var ctx = canvas.getContext("2d")
          
                  ctx.fillStyle = "white"
                  ctx.fillRect(0, 0, canvas.width, canvas.height)
              }
          

          }

          // Adding a fillStyle might help !!!!

          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