QSvgRenderer rendering on QImage leads to transparent color bleeding into result image
-
@hexaden I don't see any conversion in this code. The image data is simply copied into a buffer (bits) and later restored from there.
-
@jsulm There is a lot of code between things, but that what I meant: uchar buffer is made from a first QImage, and then much later second QImage is made from that buffer, and I asked if that might cause problems.
@hexaden said in QSvgRenderer rendering on QImage leads to transparent color bleeding into result image:
and I asked if that might cause problems
No, unless the buffered data is changed before second image is created from this buffer. You also have to be careful: "The buffer must remain valid throughout the life of the QImage and all copies that have not been modified or otherwise detached from the original buffer.", see https://doc.qt.io/qt-6/qimage.html#QImage-3
-
@jsulm restored QImage is very local, and buffer lives in outer scope for much longer time. I will double check if that buffer is ever modified, but I'm pretty sure it is not ever touched for writing (there is no public interface for it to be changed).
-
@jsulm restored QImage is very local, and buffer lives in outer scope for much longer time. I will double check if that buffer is ever modified, but I'm pretty sure it is not ever touched for writing (there is no public interface for it to be changed).
-
@JoeCFD it's of different color but it doesn't matter.
<?xml version="1.0" encoding="utf-8"?> <!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 51 51" enable-background="new 0 0 51 51" xml:space="preserve"> <path id="SymbolPreviewStroke" fill="#24D900" transform="rotate(0,26,26)" d="M25.5,13.6L19,32h13L25.5,13.6z M25.5,18.1l4.4,12.4h-8.8L25.5,18.1z"/> </svg> -
It is a green triangle. I replaced one of my icons with yours and can not see any border.
Ubuntu 22.04 and Qt 5.15.3QFile file(filename); file.open( QIODevice::ReadOnly ); QString str( QString::fromUtf8( file.readAll() ) ); QSvgRenderer svgRenderer( str.toUtf8() ); QPixmap * pixmap = new QPixmap( QSize( image_width, image_height ) ); pixmap->fill( Qt::transparent ); QPainter pixPainter( pixmap ); svgRenderer.render(&pixPainter); -
It is a green triangle. I replaced one of my icons with yours and can not see any border.
Ubuntu 22.04 and Qt 5.15.3QFile file(filename); file.open( QIODevice::ReadOnly ); QString str( QString::fromUtf8( file.readAll() ) ); QSvgRenderer svgRenderer( str.toUtf8() ); QPixmap * pixmap = new QPixmap( QSize( image_width, image_height ) ); pixmap->fill( Qt::transparent ); QPainter pixPainter( pixmap ); svgRenderer.render(&pixPainter); -
So, I just tested things, turns out the problem is indeed in QImage reconstruction (at least I think so). QPixmap/QImage is painted just fine, without any issues, before deconstruction into array, and it is painted with color bleeding after reconstruction (in non-isolated example, with all program code inbetween).
-
H hexaden has marked this topic as solved on