使用 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.
更多推荐
从黑白位图图像中提取路径信息
发布评论