Hi all,
I have a couple of issues/questions about the osg plugin for svg file format.

1.
I got win32 prebuilt versions of the library librsvg, and all required 
dependencies (glib, gdk-pixbuf, cairo, libcroco, fontconfig, libpng, freetype, 
gettext-runtime, libxml2, expat, pango), from this website:
http://ftp.acc.umu.se/pub/gnome/binaries/win32.
And rebuilt the osgdb_svg.dll plugin (in OSG 3.0.1).
When I try to read an svg image in my application, I have a crash in the yellow 
line in following function inside ReaderWriterSVG.cpp:

        osg::Image* createImage(RsvgHandle *handle, unsigned int width, 
unsigned int height) const
        {
                RsvgDimensionData dimensionData;
                rsvg_handle_get_dimensions( handle, &dimensionData);
                // If image resollution < 128, cairo produces some artifacts.
                // I don't know why, but we check the size...
                if (width < 128) width = 128;
                if (height < 128) height = 128;
                width = osg::Image::computeNearestPowerOfTwo(width);
                height = osg::Image::computeNearestPowerOfTwo(height);
                osg::Image *image = new osg::Image();
                image->allocateImage(width, height, 1, GL_RGBA, 
GL_UNSIGNED_BYTE);
                image->setPixelFormat(GL_BGRA);

                cairo_surface_t *cairo_surface = 
cairo_image_surface_create_for_data(image->data(),
                                        CAIRO_FORMAT_ARGB32, width, height, 
image->getRowSizeInBytes());
                cairo_t *cr = cairo_create(cairo_surface);
                cairo_scale(cr,((float)width)/dimensionData.width, 
((float)height)/dimensionData.height);
                rsvg_handle_render_cairo(handle, cr);

                cairo_destroy(cr);
                free(cairo_surface);

                image->flipVertical();
                return image;
        }

It looks like a memory corruption. Any idea about what might be wrong?
Could anyone of you build and use the svg plugin successfully? If yes, where 
did you get the librsvg library? What version? What versions for required 
dependencies?

2.
I looked into ReaderWriterSVG.cpp, and saw that the plugin can read an svg as 
an image. Since the svg is a vector file format, isn't there a way in OSG to 
directly construct a scene graph from that file, returning for example the root 
node of that scene graph? Also, I saw that there is no 'writeImage' 
implementation. Is there any way to write an svg file, starting from a scene 
graph (i.e. passing the root node of such a graph)? Or can it only manage the 
svg files as raster images?

Thanks
Gianluca

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to