130QQuickImageResponse::QQuickImageResponse()
131 : QObject(*(
new QQuickImageResponsePrivate))
133 qmlobject_connect(
this, QQuickImageResponse, SIGNAL(finished()),
134 this, QQuickImageResponse, SLOT(_q_finished()));
527bool QQuickImageProviderOptions::operator==(
const QQuickImageProviderOptions &other)
const
529 return d->autoTransform == other.d->autoTransform &&
530 d->preserveAspectRatioCrop == other.d->preserveAspectRatioCrop &&
531 d->preserveAspectRatioFit == other.d->preserveAspectRatioFit &&
532 d->targetColorSpace == other.d->targetColorSpace;
602QQuickImageProviderWithOptions::QQuickImageProviderWithOptions(ImageType type, Flags flags)
603 : QQuickAsyncImageProvider()
605 QQuickImageProvider::d->type = type;
606 QQuickImageProvider::d->flags = flags;
607 QQuickImageProvider::d->isProviderWithOptions =
true;
610QImage QQuickImageProviderWithOptions::requestImage(
const QString &id, QSize *size,
const QSize& requestedSize)
612 return requestImage(id, size, requestedSize, QQuickImageProviderOptions());
615QPixmap QQuickImageProviderWithOptions::requestPixmap(
const QString &id, QSize *size,
const QSize& requestedSize)
617 return requestPixmap(id, size, requestedSize, QQuickImageProviderOptions());
620QQuickTextureFactory *QQuickImageProviderWithOptions::requestTexture(
const QString &id, QSize *size,
const QSize &requestedSize)
622 return requestTexture(id, size, requestedSize, QQuickImageProviderOptions());
625QImage QQuickImageProviderWithOptions::requestImage(
const QString &id, QSize *size,
const QSize& requestedSize,
const QQuickImageProviderOptions &options)
628 return QQuickAsyncImageProvider::requestImage(id, size, requestedSize);
631QPixmap QQuickImageProviderWithOptions::requestPixmap(
const QString &id, QSize *size,
const QSize& requestedSize,
const QQuickImageProviderOptions &options)
634 return QQuickAsyncImageProvider::requestPixmap(id, size, requestedSize);
637QQuickTextureFactory *QQuickImageProviderWithOptions::requestTexture(
const QString &id, QSize *size,
const QSize &requestedSize,
const QQuickImageProviderOptions &options)
640 return QQuickAsyncImageProvider::requestTexture(id, size, requestedSize);
665QSize QQuickImageProviderWithOptions::loadSize(
const QSize &originalSize,
const QSize &requestedSize,
const QByteArray &format,
const QQuickImageProviderOptions &options,
666 qreal devicePixelRatio)
669 const bool formatIsScalable = (format ==
"svg" || format ==
"svgz" || format ==
"pdf");
670 const bool noRequestedSize = requestedSize.width() <= 0 && requestedSize.height() <= 0;
671 if ((noRequestedSize && !formatIsScalable) || originalSize.isEmpty())
676 if (noRequestedSize && formatIsScalable)
677 return originalSize * devicePixelRatio;
679 const bool preserveAspectCropOrFit = options.preserveAspectRatioCrop() || options.preserveAspectRatioFit();
681 if (!preserveAspectCropOrFit && formatIsScalable && !requestedSize.isEmpty())
682 return requestedSize;
685 if (requestedSize.width() && (preserveAspectCropOrFit || formatIsScalable ||
686 requestedSize.width() < originalSize.width())) {
687 ratio = qreal(requestedSize.width()) / originalSize.width();
689 if (requestedSize.height() && (preserveAspectCropOrFit || formatIsScalable ||
690 requestedSize.height() < originalSize.height())) {
691 qreal hr = qreal(requestedSize.height()) / originalSize.height();
694 else if (!preserveAspectCropOrFit && (hr < ratio))
696 else if (preserveAspectCropOrFit && (hr > ratio))
700 res.setHeight(qRound(originalSize.height() * ratio));
701 res.setWidth(qRound(originalSize.width() * ratio));