ios - iOS Core Graphics如何将CGImage的中间行作为vImage_Buffer?
问题描述
我试图只处理一部分(不是完整的)CGImage。我有下面的代码,从 0 开始并获取整个图像缓冲区。我需要知道如何获取指向中间行的指针,所以我可以将它作为参数传入。
如何仅获得 CGImage 的中心字节行?
extension CGImage {
func processImage() -> UInt {
guard let imgProvider: CGDataProvider = self.dataProvider,
let imgBitmapData: CFData = imgProvider.data else {
return 0
}
let topLeftPixelPointer = UnsafeMutableRawPointer(mutating: CFDataGetBytePtr(imgBitmapData))
var imgBuffer = vImage_Buffer(data: topLeftPixelPointer,
height: vImagePixelCount(height),
width: vImagePixelCount(width),
rowBytes: bytesPerRow)
let specificAddressWithinBuffer = /*??*/ // I'm not sure how to set this to point to a specific row
var sliceOfBuffer = vImage_Buffer(data: /**/,
height: vImagePixelCount(height),
width: vImagePixelCount(width),
rowBytes: bytesPerRow)
}
}
解决方案
推荐阅读
- docker - Docker --device 与 docker run 中的 -v
- python - AttributeError: 'NoneType' 对象没有属性 'lower'。对于 django-comments-dab 应用程序
- spring-cloud-dataflow - 在 Spring CLoud Dataflow Dashboard 的任务执行屏幕中单击查看日志按钮时出错
- mysql - 无法访问 AWS lightsail 上的 MYSQL 数据库
- java - 如何正确使用 Matcher 检索字符串的前 30 个字符?
- javascript - Xstate 无法设置未定义的属性“_sessionid”
- bash - Bash:提取出现多次的两个字符之间的文本
- python-3.x - 从 SFTP 服务器读取 json 文件时,我以字节格式获取数据,其中包含单引号和双引号。如何在 python 中转换为 str
- flutter - 带有嵌套小部件的 Flutter 表单验证
- azure-active-directory - Sharepoint Online OAuth 2.0 新 O365 租户的无效令牌类型