Thursday, April 28, 2011

How can i convert simple shape bitmap to vector ( geometry)

I would to know if it's possible to convert a simple bitmap to a geometry object

From stackoverflow
  • Yes, you can using tracing. Potrace is an open source bitmap-to-vector tracer library.

    However, bitmap tracing is imperfect; for high-quality vector image, line tracer is generally only used to do the initial tracing, which would later be hand-tweaked. Inkscape, an open source vector image editor, provides built-in support for tracing (internally using potrace).

    Bgnt44 : source bitmap will be simple shape and black and white, i just need all the conversion to be automatic : people load a bitmap and i store a geomtry object , the goal is to extrude these shape to a 3d cone
    Lie Ryan : simple black and white image can be easily traced using potrace (in fact, they're the ONLY thing that can be traced, color images need to be somehow converted to black-and-white before you can trace them).
    Bgnt44 : it seam that Inkscape can convert colored bitmap to vectors ... is there any way to doing that in command line
  • Here is some example of bitmap source,

    Can this be convert to only one geometry object ( i only need the white part, don't care bout black...

    alt text

    alt text

    Lie Ryan : Yes, you can do that with Potrace. Download Inkscape, and try playing with its "Path > Trace Bitmap" tool (hint: use "brightness cutoff" mode and check the "invert bitmap") to get the stars. You can do the same thing with Potrace (since Inkscape uses Potrace internally) to do it programmatically if you want to.
    Lie Ryan : Here's what I did in less than 3 minutes http://www.mediafire.com/file/mtnwielez0d/stars.svg
    Bgnt44 : i've try it (command line), very simple to convert bmp to svg, but i don't know which format use to get xaml data ...
    Lie Ryan : You will need an SVG to XAML converters. Though I've never personally used it, there are SVG to XAML converters.
  • Hi,

    I've found a way to do what i want ...

    I take each pixel of a bitmap and make a solidbrushcolored polygon with it ( but only if the pixel is not black to get better look);

    But because of performance issue i've choose to rezize it to 32 x 32 !

    To give a light effect i've use a emmitive material but the result is quite bad with colored bitmap

    But it looks a bit pixellized .. and i'm afraid of using so much polygon to just one bitmap ... any idea to get better result or more effective???

    alt text

0 comments:

Post a Comment