Jump to content

SVG file format


Jiaozi

Recommended Posts

I were wondering how to convert a raster image to a SVG file. I play a bit with http://vectormagic.com/ that is the best converter I know and think to this "algorithm" :

  • [*:15cfkgt3]Use Magic Wand to grab some area. Convert the selected boundary to
SVG path and fill with a color.
[*:15cfkgt3]Iterate through the surface as long as all the pixels of the surface has not been covered by the magic wand.

A bit rough, isn't it ? No circle or rectangle tag, this is just a raster-image converter.

Is it a too naive algorithm ? While simulating it, I see that my selection with magic wand isn't as smooth as vectormagic. This is what make me feel as a bad algorithm. Am I right ?

Link to comment
Share on other sites

For pictures that do not contain large area's of roughly the came colour, the SVG file could end up bigger than the bitmap.

IMO there is nothing to gain from converting to SVG anyway, trying to smooth the curves would destroy some detail, depending on the tolerance JPG pictures (and other noisy images) may end up being encoded as width*height squares, gradients are hard to detect, and because you can never guess the correct curve from a raster image it won't be very scalable anyway.

Unless perhaps you use a very complex algorithm that takes a lot of time - and it still probably won't look the way you'd vectorize the picture yourself in most cases.

An SVG importer may come in handy though..

edit: I just tried that vectormagic thing on a multi-coloured font - complete disaster, but a nice try anyway. It can clearly be seen that it does not use the algorithm you described, the bitmap importer of Inkscape however looks like it does.

I would write plugins, if I knew what kind of plugins were needed.. :(

Link to comment
Share on other sites

Here is why it may be useful: I'm a developer but not a designer. Silverlight and WPF use vectorized image, so converting a raster image to svg is the first step before converting to XAML.

I don't want to pay a designer for a little game I wrote as freeware and I don't know anybody who may draw for me. So the easiest way for me is to convert png image scanned or found.

Link to comment
Share on other sites

Yeah yeah I know that... but the game I want to code is Carcasonne. I'll need to display hundred of tiles so to decrease the memory, I wanted to use Xaml primitives. Moreover, that is the GPU that draws the primitives so I see clearly two advantages compared to holding hundred of png files.

Link to comment
Share on other sites

How many hundreds will you be needing?

My guess is that it if it's just a moderately high number, there would be no trouble with memory. Of course it's always nice to use less.. But is it really crucial?

I know that game, unless you're going to substantially increase the number of tiles in the computer version there shouldn't be a problem at all, you could even sub-tile the tiles, or have base-tiles (grass, city part, combinations in various shapes) + several detail sprites (clumps of grass etc) on top (basically sub-tiling with a separate background)

I would write plugins, if I knew what kind of plugins were needed.. :(

Link to comment
Share on other sites

Hum good idea Harold ! I didn't think about subclassing my tiles. This will really increase my possibilities :)

Thank you, I will do that way

Yes I will increase the number (I consider implementing the different extensions) and provide zooming feature (to see the table in its entirety)

Link to comment
Share on other sites

  • 2 months later...

I tell you what. I've come across many times when I really wanted / needed to load a .SVG into Paint.NET.

I'm working on a file plugin to load .SVG files.

Unless somebody out there is beating me to it...?

Link to comment
Share on other sites

There has been talk, but no one has produced anything. If you can do it, I would love to see it... :D

 

Take responsibility for your own intelligence. 😉 -Rick Brewster

Link to comment
Share on other sites

If you're coding a game and performance is a concern, you should probably use Direct3D and DDS textures.

Sorry for off-topic, but one thing I've never understood about games is how textures affect performance. I mean, the texture is just covering a model, so why does it improve your performance if you have texture settings lower?

Link to comment
Share on other sites

1) less memory is needed to store them (leading to less paging etc)

2) less GPU bandwidth is used on textures (leading to faster transfers of vertices etc)

3) better locality of reference in the pixelshader when using the texture (since it's smaller) so better use of GPU texture caches

there are probably more reasons

For 1 less mipmap, the ram usage for that texture is approximately divided by 4

I would write plugins, if I knew what kind of plugins were needed.. :(

Link to comment
Share on other sites

If you're coding a game and performance is a concern, you should probably use Direct3D and DDS textures.

Sorry for off-topic, but one thing I've never understood about games is how textures affect performance. I mean, the texture is just covering a model, so why does it improve your performance if you have texture settings lower?

Remember that the texture must be loaded from memory, transformed to the shape of the object and sent to the screen each time a new frame is rendered.

KaHuc.png
Link to comment
Share on other sites

Usually not..

usually, the texture will already be in the GPU's dedicated ram during rendering (if it exists and is big enough)

the texture will not be transformed:

the vertices* will be transformed (or not, depending on the vertex shader, when it exists), and a pixel shader (or fragment shader, the GL equivalent) will sample from the texture (which is probably where the GPU's texture samplers come in)

The number of pixels send to the screen per second only depends on the size of the viewport and FPS

*: someone may decide to transform per-pixel instead, but I've never heard of anyone who did

I would write plugins, if I knew what kind of plugins were needed.. :(

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...