Jiaozi Posted June 3, 2008 Share Posted June 3, 2008 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 ? Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted June 3, 2008 Share Posted June 3, 2008 I honestly don't see any value trying to convert bitmap/raster images into a vector format. Just save it as a PNG. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
harold Posted June 3, 2008 Share Posted June 3, 2008 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. Quote I would write plugins, if I knew what kind of plugins were needed.. Link to comment Share on other sites More sharing options...
Jiaozi Posted June 4, 2008 Author Share Posted June 4, 2008 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. Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted June 4, 2008 Share Posted June 4, 2008 WPF allows you to use a bitmap source as well. You are not restricted to vectors. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
Jiaozi Posted June 4, 2008 Author Share Posted June 4, 2008 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. Quote Link to comment Share on other sites More sharing options...
harold Posted June 4, 2008 Share Posted June 4, 2008 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) Quote I would write plugins, if I knew what kind of plugins were needed.. Link to comment Share on other sites More sharing options...
Jiaozi Posted June 4, 2008 Author Share Posted June 4, 2008 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) Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted June 4, 2008 Share Posted June 4, 2008 If you're coding a game and performance is a concern, you should probably use Direct3D and DDS textures. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
J6628426 Posted August 18, 2008 Share Posted August 18, 2008 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...? Quote Link to comment Share on other sites More sharing options...
barkbark00 Posted August 18, 2008 Share Posted August 18, 2008 There has been talk, but no one has produced anything. If you can do it, I would love to see it... Quote  Take responsibility for your own intelligence. 😉 -Rick Brewster Link to comment Share on other sites More sharing options...
harold Posted August 18, 2008 Share Posted August 18, 2008 One could just use svg2png and load the png right Quote I would write plugins, if I knew what kind of plugins were needed.. Link to comment Share on other sites More sharing options...
barkbark00 Posted August 18, 2008 Share Posted August 18, 2008 Is that a pdn plugin? Quote  Take responsibility for your own intelligence. 😉 -Rick Brewster Link to comment Share on other sites More sharing options...
harold Posted August 18, 2008 Share Posted August 18, 2008 no.. http://directory.fsf.org/project/svg2png/ but maybe librsvg is better, not sure http://ftp.gnome.org/pub/GNOME/sources/librsvg/ Quote I would write plugins, if I knew what kind of plugins were needed.. Link to comment Share on other sites More sharing options...
Andrew D Posted August 19, 2008 Share Posted August 19, 2008 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? Quote Link to comment Share on other sites More sharing options...
harold Posted August 19, 2008 Share Posted August 19, 2008 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 Quote I would write plugins, if I knew what kind of plugins were needed.. Link to comment Share on other sites More sharing options...
Simon Brown Posted August 19, 2008 Share Posted August 19, 2008 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. Quote Link to comment Share on other sites More sharing options...
harold Posted August 19, 2008 Share Posted August 19, 2008 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 Quote I would write plugins, if I knew what kind of plugins were needed.. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.