从黑白位图图像中提取路径信息 [英] Extract path information from an black&white bitmap image

查看:301
本文介绍了从黑白位图图像中提取路径信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 Quartz 2D 绘制形状以描绘如下图像并不容易。是否可以从黑白位图图像中提取 CGPathRef 信息?白色部分实际上是透明的。

It is not easy to draw a shape with Quartz 2D to depict an image as following. Is it possible to extract a CGPathRef information from a black&white bitmap image? The white part is actually transparent.

编辑

我想要实现的目标:

我想设置 SKSpriteNode physicsBody 相同形状的图像 bottle.png

I want to set the physicsBody of a SKSpriteNode with the same shape of the image bottle.png

SKSpriteNode * myBottle = [SKSpriteNode spriteNodeWithImageNamed:@"bottle"];
.
.
.
myBottle.physicsBody = [SKPhysicsBody bodyWithEdgeChainFromPath:path];

她的路径 CGPathRef ,我想让它与图像具有相同的形状 bottle.png

Her path is a CGPathRef, I wanna to make it have the same shape with the image bottle.png

推荐答案

Google potrace
这是执行此操作的几个开源库之一。
它还可以轻松链接到其他人。

Google potrace It's one of several open source libraries that do this. It also handily links to others.

这篇关于从黑白位图图像中提取路径信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆