本页内容

C

Qul::SharedImage Struct

struct Qul::SharedImage

对图像数据的共享引用。更多内容...

Header: #include <qul/image.h>
Since: Qt Quick Ultralite 1.5

公共函数

SharedImage()
SharedImage(const Qul::SharedImage &other)
~SharedImage()
Qul::Image *image() const
(since Qt Quick Ultralite 2.12) bool maybeTexture(Qul::PlatformInterface::Texture &texture, int textureIndex = 0) const
(since Qt Quick Ultralite 2.2) Qul::PlatformInterface::Texture texture(int textureIndex = 0) const
(since Qt Quick Ultralite 2.2) int textureCount() const
operator bool() const
Qul::SharedImage &operator=(const Qul::SharedImage &other)

详细说明

该结构体用于将包含图像数据的内存缓冲区传递给 QUL 元素以进行绘制。诸如 `Image.source ` 之类的属性类型为 `Property<SharedImage>`。

最常用的SharedImage值由编译器为编译时可用的图像资源构建,并指向静态内存区域。

您可以使用 `Image ` 在堆上分配新的图像数据,或导入您单独准备好的图像数据。`Image ` 会隐式转换为 `SharedImage`。

注意: 对于编译器生成的 SharedImage 值,image()函数 可能会返回NULL。请使用operator bool() 来确定一个 SharedImage 是否引用了图像数据。

另请参阅 Image 。

成员函数文档

SharedImage::SharedImage()

构建一个空图像引用。

SharedImage::SharedImage(const Qul::SharedImage &other)

复制构造函数

[noexcept] SharedImage::~SharedImage()

析构函数

Qul::Image *SharedImage::image() const

如果可用,获取关联的Image 。

如果该SharedImage 是从Image 创建的,则此方法返回指向该图像的指针。

注意:在内部 ,Qt Quick Ultralite 可能会创建不关联Image 的SharedImage 实例。在这种情况下,该函数将返回NULL。

[since Qt Quick Ultralite 2.12] bool SharedImage::maybeTexture(Qul::PlatformInterface::Texture &texture, int textureIndex = 0) const

返回位于textureIndex 处的纹理。

有效的索引范围为 0 到textureCount() - 1。

如果资源缓存中没有足够的内存来加载资源缓存类型为OnDemand 的纹理,则此函数返回false 。

如果纹理加载成功,该函数返回true ,并且纹理数据存储在texture 中。

该函数于Qt Quick Ultralite 2.12 版本中引入。

另请参阅 SharedImage::textureCount 。

[since Qt Quick Ultralite 2.2] Qul::PlatformInterface::Texture SharedImage::texture(int textureIndex = 0) const

返回位于textureIndex 处的纹理。

有效的索引范围为 0 到textureCount() - 1。

注意: 如果纹理数量为零,该函数 将引发错误。

如果资源缓存中没有足够的内存来加载资源缓存类型为OnDemand 的纹理,此函数也会触发错误。

该函数在Qt Quick Ultralite 2.2 中引入。

另请参阅 SharedImage::textureCount 。

[since Qt Quick Ultralite 2.2] int SharedImage::textureCount() const

返回与SharedImage 关联的纹理数量。

如果启用了图像拆分优化,纹理数量可能会大于 1。要禁用图像拆分优化,请将 `MCU.Config.Experimental.resourceSplitImageOptimization ` 设置为 `false`。

此函数首次出现在Qt Quick Ultralite 2.2 中。

另请参阅 SharedImage::texture 。

SharedImage::operator bool() const

如果SharedImage 引用了某些图像数据,则返回true。

Qul::SharedImage &SharedImage::operator=(const Qul::SharedImage &other)

从以下位置复制任务other

在某些 Qt 许可证下可用。
了解更多信息。