图片资产的参考数据

时间:2019-02-03 10:41:06

标签: ios swift uiimage assets cgimage

我了解到我可以在解码之前从URL引用图像数据以缩小图像的尺寸,从而节省了设备上的大量内存:

Availability is limited to us-east-1.
Hyperledger Fabric is the only supported blockchain framework.
The maximum number of networks per AWS account is 1.
The maximum number of networks that an AWS account can be a member of is 1.
The maximum number of members per network is 5.
The maximum number of peer nodes per member is 1.
Peer nodes are limited to the bc.t3.small instance type.

现在,我试图找出是否还可以从资产的图像,但我没有找到任何解决办法呢。 由于无法初始化图像作为NSDataAsset引用它的数据,我不知道是否有另一种可能性。

我已经尝试加载从资产图像​​并将其经由转换成数据 func downsample(imageAt imageURL: URL, to pointSize: CGSize, scale: CGFloat) -> UIImage { let imageSourceOptions = [kCGImageSourceShouldCache: false] as CFDictionary let imageSource = CGImageSourceCreateWithURL(imageURL as CFURL, imageSourceOptions)! let maxDimensionInPixels = max(pointSize.width, pointSize.height) * scale let downsampleOptions = [kCGImageSourceCreateThumbnailFromImageAlways: true, kCGImageSourceShouldCacheImmediately: true, kCGImageSourceCreateThumbnailWithTransform: true, kCGImageSourceThumbnailMaxPixelSize: maxDimensionInPixels] as CFDictionary let downsampledImage = CGImageSourceCreateThumbnailAtIndex(imageSource, 0, downsampleOptions)! return UIImage(cgImage: downsampledImage) } ,但我了解到,整个图像被加载到存储器中的第一。所以这并没有给我任何的优势。

0 个答案:

没有答案
相关问题