Extract path information from an black&white bitmap image

不打扰是莪最后的温柔 提交于 2019-12-04 14:05:54

问题


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.

Edit:

What I want to achieve:

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];

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


回答1:


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



来源:https://stackoverflow.com/questions/22654401/extract-path-information-from-an-blackwhite-bitmap-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!