130QQuickImageResponse::QQuickImageResponse()
131 : QObject(*(
new QQuickImageResponsePrivate))
133 qmlobject_connect(
this, QQuickImageResponse, SIGNAL(finished()),
134 this, QQuickImageResponse, SLOT(_q_finished()));
528bool QQuickImageProviderOptions::operator==(
const QQuickImageProviderOptions &other)
const
530 return d->autoTransform == other.d->autoTransform &&
531 d->preserveAspectRatioCrop == other.d->preserveAspectRatioCrop &&
532 d->preserveAspectRatioFit == other.d->preserveAspectRatioFit &&
533 d->targetColorSpace == other.d->targetColorSpace;
603QQuickImageProviderWithOptions::QQuickImageProviderWithOptions(ImageType type, Flags flags)
604 : QQuickAsyncImageProvider()
606 QQuickImageProvider::d->type = type;
607 QQuickImageProvider::d->flags = flags;
608 QQuickImageProvider::d->isProviderWithOptions =
true;
611QImage QQuickImageProviderWithOptions::requestImage(
const QString &id, QSize *size,
const QSize& requestedSize)
613 return requestImage(id, size, requestedSize, QQuickImageProviderOptions());
616QPixmap QQuickImageProviderWithOptions::requestPixmap(
const QString &id, QSize *size,
const QSize& requestedSize)
618 return requestPixmap(id, size, requestedSize, QQuickImageProviderOptions());
621QQuickTextureFactory *QQuickImageProviderWithOptions::requestTexture(
const QString &id, QSize *size,
const QSize &requestedSize)
623 return requestTexture(id, size, requestedSize, QQuickImageProviderOptions());
626QImage QQuickImageProviderWithOptions::requestImage(
const QString &id, QSize *size,
const QSize& requestedSize,
const QQuickImageProviderOptions &options)
629 return QQuickAsyncImageProvider::requestImage(id, size, requestedSize);
632QPixmap QQuickImageProviderWithOptions::requestPixmap(
const QString &id, QSize *size,
const QSize& requestedSize,
const QQuickImageProviderOptions &options)
635 return QQuickAsyncImageProvider::requestPixmap(id, size, requestedSize);
638QQuickTextureFactory *QQuickImageProviderWithOptions::requestTexture(
const QString &id, QSize *size,
const QSize &requestedSize,
const QQuickImageProviderOptions &options)
641 return QQuickAsyncImageProvider::requestTexture(id, size, requestedSize);
666QSize QQuickImageProviderWithOptions::loadSize(
const QSize &originalSize,
const QSize &requestedSize,
const QByteArray &format,
const QQuickImageProviderOptions &options,
667 qreal devicePixelRatio)
670 const bool formatIsScalable = (format ==
"svg" || format ==
"svgz" || format ==
"pdf");
671 const bool noRequestedSize = requestedSize.width() <= 0 && requestedSize.height() <= 0;
672 if ((noRequestedSize && !formatIsScalable) || originalSize.isEmpty())
677 if (noRequestedSize && formatIsScalable)
678 return originalSize * devicePixelRatio;
680 const bool preserveAspectCropOrFit = options.preserveAspectRatioCrop() || options.preserveAspectRatioFit();
682 if (!preserveAspectCropOrFit && formatIsScalable && !requestedSize.isEmpty())
683 return requestedSize;
686 if (requestedSize.width() && (preserveAspectCropOrFit || formatIsScalable ||
687 requestedSize.width() < originalSize.width())) {
688 ratio = qreal(requestedSize.width()) / originalSize.width();
690 if (requestedSize.height() && (preserveAspectCropOrFit || formatIsScalable ||
691 requestedSize.height() < originalSize.height())) {
692 qreal hr = qreal(requestedSize.height()) / originalSize.height();
695 else if (!preserveAspectCropOrFit && (hr < ratio))
697 else if (preserveAspectCropOrFit && (hr > ratio))
701 res.setHeight(qRound(originalSize.height() * ratio));
702 res.setWidth(qRound(originalSize.width() * ratio));