Image/ByteArray to SVG conversion?
I am wondering if it is possible to开发者_JS百科 get a url to some image on google, say a square (jpg/png/gif), and process it into an SVG. Is this possible?
Right now I'm getting ByteArray data in Actionscript by making a URLRequest('image/on/google'), with dataFormat="binary". I don't think Actionscript could handle/do it, but maybe it could. I'm also good with Ruby, so perhaps is this possible with Ruby?
If so, any sample code/libraries to get started?
I guess another way to ask it is, how do I convert a Bitmap to a set of Vector Paths like Adobe Illustrator does?
There is no default support - You'll have to write your own raster-to-vector conversion algorithm, preferably at the server side as it can be CPU heavy. A quick search for raster to vector / jpg to svg revealed only tools and algorithms, not APIs.
You need to vectorise it, which is often called 'tracing'. Desktop illustrating programs like Adobe Illustrator can do this, by clicking around in the UI obviously.
There are free libraries and tools like potrace and Autotrace which do take (grayscale) bitmaps and generate SVG.
Commercial tools like Vector Magic can do colour images too.
Have a look at Sakri's bitmap to polygon code: http://www.sakri.net/blog/2009/06/12/an-approach-to-triangulating-polygons-with-holes/
精彩评论