问题
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