bool SvgScreen::fileToImage (CompString &path, CompSize &size, int &stride, void *&data) { CompString fileName = path; bool status = false; int len = fileName.length (); if (len < 4 || fileName.substr (len - 4, 4) != ".svg") fileName += ".svg"; status = readSvgToImage (fileName.c_str (), size, data); if (status) { stride = size.width () * 4; return true; } status = screen->fileToImage (path, size, stride, data); return status; }
void SvgWindow::setSvg (CompString &data, decor_point_t p[2]) { RsvgHandle *svg = NULL; GError *error = NULL; if (!gWindow) return; svg = rsvg_handle_new_from_data ((guint8 *) data.c_str (), data.length (), &error); if (source) { rsvg_handle_free (source->svg); source->svg = svg; } else { source = new SvgSource; if (source) source->svg = svg; } if (source && source->svg) { source->p1 = p[0]; source->p2 = p[1]; source->svg = svg; gWindow->glDrawSetEnabled (this, true); rsvg_handle_get_dimensions (svg, &source->dimension); updateSvgContext (); } else { if (svg) rsvg_handle_free (svg); if (source) { delete source; source = NULL; } if (context) { finiTexture (context->texture[0]); delete context; context = NULL; } gWindow->glDrawSetEnabled (this, false); } }
CompString PngScreen::fileNameWithExtension (CompString &path) { unsigned int len = path.length (); if (len > 4 && path.substr (len - 4, 4) == ".png") return path; return path + ".png"; }