开发者

Create NSBezierPath from bitmap outline

I would like to create a NSBezierPath object which corresponds to the outline of an arbitrary bitmap image.

All my images are png solid开发者_如何学JAVA monochrome shapes with transparent backgrounds. Here is an examplee:

Create NSBezierPath from bitmap outline

I want the bezier path of the outline of the shape. What is the bast way to achieve this?


What you are looking for is a tracing/vectorization algorithm.

DrawKit appears to support bitmap to vector tracing:

  • DKImageShape+Vectorization.m
  • NSImage+Tracing.m

Some other (non-ObjC) open-source projects implementing tracing (for code reference):

  • http://code.google.com/p/vectorizationpackage/ (ActionScript)
  • http://code.google.com/p/linetracer/ (C++)
  • http://code.google.com/p/vector/ (Python)

Anyone who has ever used Illustrator's (or any of its competitors') tracing tools can assure you that tracing is a non-trivial thing, though. But for your simple b&w images (technically graysacle, due to antialiasing, but that's rather neglectable here) just about any algorithm should do the trick. Especially if you don't even need perfect curve fitting, as you noted.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜