如何使用 ciContext.writePNGRepresentation(of: , to:, format:,colorSpace:, options:) API 在 macOS 中导出 16 位 PNG?

问题描述 投票:0回答:1

是否可以使用此 API 导出 16 位图像?

ciContext.writePNGRepresentation(of: , to:, format:,colorSpace:, options:)

我可以使用 HEIF10 API 导出 10 位 HEIF 文件

ciContext.writeHEIF10Representation(of:, to:, colorSpace:, options:)

这些是正在使用的参数

 let options = [kCGImageDestinationLossyCompressionQuality as CIImageRepresentationOption: 1.0 as CGFloat]
 let colorSpace = CGColorSpace(name: CGColorSpace.sRGB)!
 let imgFormat = CIFormat.RGBA8

我尝试使用 CIFormat.RGBA16 但这似乎对 HEIF 导出没有影响,HEIF 导出似乎始终是 10 位 - 正如预期的那样。

swift png core-image
1个回答
0
投票

您可以通过将

CIFormat.RGBA16
传递给
writePNGRepresentation(...)
来导出 16 位 PNG。

HEIF 不支持 16 位导出,仅支持 8 位和 10 位。对于 8 位,使用

writeHEIFRepresentation(...)
方法并传递
.RGBA8
.BGRA8
作为格式。对于 10 位,请使用特定的
writeHEIF10Representation(...)
方法。

© www.soinside.com 2019 - 2024. All rights reserved.