本文介绍了用开罗加载svg的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用Cairo库加载SVG文件,并对其进行一些转换.然后我想用glTexture显示我的svg.

I want to load a SVG file with the Cairo library, do apply some transformations to it.Then I want to display my svg with a glTexture.

但是我只是找到创建svg文件而不加载svg的函数.

But I just find functions which create svg file and not load svg.

推荐答案

Cairo本身无法读取SVG文件.您需要类似 librsvg 之类的东西,才能将SVG渲染到开罗表面.

Cairo itself cannot read SVG files. You need something like librsvg to render SVGs to a Cairo surface.

快速浏览他们的 API文档,看来您需要rsvg_handle_new_from_file()加载文件,然后使用rsvg_handle_render_cairo()rsvg_handle_get_pixbuf()之类的东西将SVG绘制到Cairo上下文中/将SVG转换为GdkPixbuf.

From a quick look at their API documentation, it looks like you need rsvg_handle_new_from_file() to load a file and something like rsvg_handle_render_cairo() or rsvg_handle_get_pixbuf() to draw the SVG to a Cairo context / to turn the SVG into a GdkPixbuf.

这篇关于用开罗加载svg的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 08:00