Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. Making pictures transparent before placement on a graphics scene?
Qt 6.11 is out! See what's new in the release blog

Making pictures transparent before placement on a graphics scene?

Scheduled Pinned Locked Moved Game Development
5 Posts 3 Posters 3.2k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    So I have this problem right and its hard to explain but I am going to give it a shot.
    I have a picture of a soccer ball on a white background which I have added to a graphics scene like so:
    @ QGraphicsPixmapItem *picture = new QGraphicsPixmapItem(QPixmap("C:/Users/Public/Pictures/images (2)"));
    scene.addItem(picture);@
    My scenes background has been set to another color.
    So what I have is a soccerball on white background inside a rectangular frame on my scene's background.
    But that's not what I want
    I want just the ball ,which is round, on my scene's background
    My question is how do I get rid of the rest of the picture and have just the ball on my scene's background?

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

      What type of format is your picture?
      Picture is ALWAYS rectangular. So if you have a soccer ball on a white background, that background will also be displayed. So you'll have to modify the image itself.

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

        Hey Jake.
        It's ".jpg" and how do I modify the picture.
        Do I modify it in paint.
        Oh that won't take way the problem.
        I tried changing the the shape of the bounding rect but it doesn't change how the picture is displayed on the scene.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mlong
          wrote on last edited by
          #4

          You need a transparent background around the soccer ball in your image, rather than a white background. Unfortunately, jpg files do not support transparency. You can convert the file to a format which supports transparency, such as png. I don't think paint will handle this. There are a number of editors available for Windows, though I don't have a good list myself (I've always used GIMP, myself.) But a quick Google search could point you in the direction of some good apps which can do what you need.

          Software Engineer
          My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

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

            Thanks Master mlong
            Trying out your advice.

            ....some time later....

            Master malong, you the man.
            It works like a charm.

            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