mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-21 13:48:08 +00:00
fix(ImageProvider): set size on request
This commit is contained in:
parent
568907207a
commit
3a0dbaf967
1 changed files with 10 additions and 2 deletions
|
|
@ -247,7 +247,7 @@ ImageProvider::ImageProvider () : QQuickImageProvider(
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
QImage ImageProvider::requestImage (const QString &id, QSize *, const QSize &) {
|
||||
QImage ImageProvider::requestImage (const QString &id, QSize *size, const QSize &requestedSize) {
|
||||
const QString path = QStringLiteral(":/assets/images/%1").arg(id);
|
||||
qInfo() << QStringLiteral("Image `%1` requested.").arg(path);
|
||||
|
||||
|
|
@ -281,7 +281,13 @@ QImage ImageProvider::requestImage (const QString &id, QSize *, const QSize &) {
|
|||
|
||||
// 3. Create en empty image.
|
||||
const QRectF viewBox = renderer.viewBoxF();
|
||||
QImage image(static_cast<int>(viewBox.width()), static_cast<int>(viewBox.height()), QImage::Format_ARGB32);
|
||||
const int width = requestedSize.width();
|
||||
const int height = requestedSize.height();
|
||||
QImage image(
|
||||
width > 0 ? width : static_cast<int>(viewBox.width()),
|
||||
height > 0 ? height : static_cast<int>(viewBox.height()),
|
||||
QImage::Format_ARGB32
|
||||
);
|
||||
if (Q_UNLIKELY(image.isNull())) {
|
||||
qWarning() << QStringLiteral("Unable to create image of size `(%1, %2)` from path: `%3`.")
|
||||
.arg(viewBox.width()).arg(viewBox.height()).arg(path);
|
||||
|
|
@ -289,6 +295,8 @@ QImage ImageProvider::requestImage (const QString &id, QSize *, const QSize &) {
|
|||
}
|
||||
image.fill(0x00000000);
|
||||
|
||||
*size = image.size();
|
||||
|
||||
// 4. Paint!
|
||||
QPainter painter(&image);
|
||||
renderer.render(&painter);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue