Page 1 of 1

SVG generation problems

Posted: 2011-08-05T04:23:12-07:00
by sniceper

First, sorry for my english mistakes.

Well, i'm trying to generate some SVG images. Here is the interesting part of the code:

Code: Select all

    Image kod( Geometry(formatX+4*sizeP, formatY+4*sizeP), Color("white"));
    Image logo_image("/home/logos/" + logo);
    list<Drawable> ToDraw;                                                                                                          
    for (int i=0;i<tailleY;i++)
        for (int j=0;j<tailleX;j++)
            if (matrix[i][j])
    if (secubit[0]) ToDraw.push_back(DrawableRectangle(2*sizeP-((sizeP/2)-1)+2*sizeP,   2*sizeP-((sizeP/2)-1)+2*sizeP,   2*sizeP-((sizeP/2)+1)+2*sizeP,   2*sizeP-((sizeP/2)+1)+2*sizeP));
    if (secubit[1]) ToDraw.push_back(DrawableRectangle(3*sizeP-((sizeP/2)-1)+2*sizeP,   2*sizeP-((sizeP/2)-1)+2*sizeP,   3*sizeP-((sizeP/2)+1)+2*sizeP,   2*sizeP-((sizeP/2)+1)+2*sizeP));
    if (secubit[2]) ToDraw.push_back(DrawableRectangle(4*sizeP-((sizeP/2)-1)+2*sizeP,   2*sizeP-((sizeP/2)-1)+2*sizeP,   4*sizeP-((sizeP/2)+1)+2*sizeP,   2*sizeP-((sizeP/2)+1)+2*sizeP));
        Geometry new_size(formatX-10*sizeP,formatY-10*sizeP);

      kod.write( "generated/" + ID +".svg");                                                                                                         

      return 0;
The code is supposed to Draw several Blue circles and three yellow squares around a logo (the image is a .svg). The generated file shows black circles (instead of blue) and the central logo is absent...
In order to fix it, i wrote two "kod.display()" to see the appearance of the file during the process. The command displays a correct image, with blue circles and the central logo... So it seems that the saving is the root of the problem.

I tried to save in JPG instead of SVG, it works too. So my question is: Why doesn't it want to save the colors and the logo when I generate a .SVG?

Thank you very much,

Re: SVG generation problems

Posted: 2011-08-06T20:59:32-07:00
by Imaginatorium
I hesitate to respond, since I am new to ImageMagick, but I think the answer is simple.

ImageMagick (and all the wrappers like Magick++) is a *bitmap graphics* package. It allows you to draw vectors, but only in bitmap form -- in other words, once you draw a circle it is converted to a lot of pixel values, and you cannot (directly) get back to the original vector specification. So it is not possible to save in a vector graphics format.

You need an SVG editing package (about which I know nothing, sorry)...

Re: SVG generation problems

Posted: 2011-08-07T23:58:48-07:00
by anthony
A word about Vector Image formats

Re: SVG generation problems

Posted: 2011-08-09T01:08:29-07:00
by sniceper
Arg.. So I need another library to do what I want. I'll try any other library written in the webpage you sent me.

Thank you very much for replying,