gpt4 book ai didi

ios - 如何在 Swift 中使用 'compression_encode_buffer'?

转载 作者:搜寻专家 更新时间:2023-11-01 07:17:30 25 4
gpt4 key购买 nike

我正在使用 Swift 的压缩库将图像压缩为 NSData。这是代码:

var imageCompressed:NSData
compression_encode_buffer( imageCompressed ,800000 , imageSelected , size , NULL , COMPRESSION_LZMA )

我收到以下错误消息:

Cannot convert value of type NSData to expected argument type UnsafeMutablePointer

最佳答案

我想你想要的是这样的(imageSelectedimageCompressed 被假定为 Swift 3 Data 对象):

imageSelected.withUnsafeBytes {(fromBytes: UnsafePointer<UInt8>) -> Void in
imageCompressed.withUnsafeMutableBytes {(toBytes: UnsafeMutablePointer<UInt8>) -> Void in
compression_encode_buffer(toBytes, toSize, fromBytes, fromSize, nil, COMPRESSION_LZMA)
}
}

关于ios - 如何在 Swift 中使用 'compression_encode_buffer'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41303902/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com