1 Attachment(s)
Image/Pixmap after scaling parcelled into 4 pieces.
Hi all, I have a board desk and using some image as background, it's saved in svg file and I render it from there to a pixmap/image. Then I scale it to size of QGraphicsView on renderEvent. But a problem is that pixmap/image is parcelled after the scaling.
There is a screenshot of the problem as attachment.
I would love to have the background in one piece not parcelled, what am I doing wrong?
Here's the renderEvent implementation:
Code:
qDebug("Resize event ... ");
qDebug("Width: %d, Height: %d", sz.width(), sz.height());
if ( m_renderer
->elementExists
( QString ( "background" ) ) ) { qDebug ( "Rendering" );
} else {
qDebug ( "No background found" );
}
qDebug("Width: %d, Height: %d", hint.width(), hint.height());
QBrush br
( bg.
scaled(hint, Qt
::IgnoreAspectRatio, Qt
::SmoothTransformation) );
m_scene->setBackgroundBrush ( br );
}
Re: Image/Pixmap after scaling parcelled into 4 pieces.
Wow, what's about reimp the paint method of your view and print the images directly? the painters drawPixmap method will scale the image on its own.
Re: Image/Pixmap after scaling parcelled into 4 pieces.
I'm not sure how to do that and if it would help. Problem is in setting setBackgroundBrush, if I put a image to scene as scene->addPixmap(...) image is ok. So problem is somewhere in scene painting with brush.
Added after 23 minutes:
Finally I solved that by reimplementing drawBackground of the view as you suggested.
Code:
void kMancalaBoard
::drawBackground(QPainter *painter,
const QRectF &rect
) { if ( m_renderer
->elementExists
( QString ( "background" ) ) ) { qDebug ( "Rendering" );
m_renderer
->render
( painter,
QString ( "background" ), rect
);
} else {
qDebug ( "No background found" );
}
}