Painting into QImage with several layer vs one QImage (problem)
-
Hello
I followed Scrible example (painting into QImage) and it working fine when my brush is transparent. It works expected.
Problem arise when I create another QImage (transparent) and paint into it and then draw both Qimage-s into widget. The "transparent behavior" is different then painting into one QImage, even if this one QImage is transparent.I wonder where can be problem?
Here is code how I draw two images.
void Little_Painter::paintEvent(QPaintEvent *event) { QPainter painter(this); QRect dRect = event->rect(); painter.drawImage(dRect, m_image, dRect); painter.drawImage(dRect, m_imageDraw, dRect); // m_imageDraw is transparent QImage }
void Little_Painter::drawLineTo(const QPoint &endPoint) { QPainter painter(&m_imageDraw); // painting into m_imageDraw looks strange with very small transparency //QPainter painter(&m_image); // painting into m_image is ok painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); QRect area; m_painterManager.draw(DrawManagerArgs(&painter, &endPoint, &area, &m_lastPoint, &m_measurePoint)); update(area); undo_redo_system::setSActive(UndoRedoSpecialActiveArgs(&m_lastPoint)); m_lastPoint = endPoint; }
Little_Painter::Little_Painter(QWidget *parent) : QWidget(parent) , m_image(parent->size(), QImage::Format_RGBA8888_Premultiplied) , m_imageDraw(parent->size(), QImage::Format_RGBA8888_Premultiplied) // ....
Look at the pictures:
- top brush is how brush texture looks like and second two "round paintings" are transparent brush (left set on 2% and right on 1% transparency) and I painted around until I get it non-transparent in the middle.
-
- first picture is painting into
QImage m_imageDraw
- first picture is painting into
-
- picture is painting into
QImage m_image
withoutm_imageDraw
- picture is painting into
-
picuture: (this looks interesting but it is not intention)
-
second picture