SVG to alpha channel QPixmaps?
I have an image in *.svg format. I want to load and convert it into a QPixmap object, where the image is opaque where the svg vector lines dictate color, and transparent everwhere else.
I'm currently doing this:
Code:
renderer.load("images/my-logo.svg");
QPixmap image
(renderer.
defaultSize());
renderer.render(&painter);
logoLabel->setPixmap(image);
It puts the svg image into the QLabel, but with an opaque background.
How can I make it with a transparent background?
Re: SVG to alpha channel QPixmaps?
I am not sure if the svg renderer can handle that.
Are you sure the pixmap is not transparent?
Have you tried saving it and opening it in a viewer or something?
Re: SVG to alpha channel QPixmaps?
Try:
Code:
image.fill(Qt::transparent);
Re: SVG to alpha channel QPixmaps?
Quote:
Originally Posted by
jpn
Try:
Code:
image.fill(Qt::transparent);
Are you sure the renderer won't overwrite all the pixels in the pixmap?
Re: SVG to alpha channel QPixmaps?
Quote:
Originally Posted by
marcel
Are you sure the renderer won't overwrite all the pixels in the pixmap?
Yes, I tested it. :)
Re: SVG to alpha channel QPixmaps?
Quote:
Originally Posted by
jpn
Try:
Code:
image.fill(Qt::transparent);
Works like magic! Thanks!