示例#1
0
文件: svg.c 项目: arczi84/NetSurf-68k
static void svg_destroy(struct content *c)
{
	svg_content *svg = (svg_content *) c;

	if (svg->diagram != NULL)
		svgtiny_free(svg->diagram);
}
示例#2
0
void ofxSVG::load(string path){
	path = ofToDataPath(path);

	if(path.compare("") == 0){
		ofLogError("ofxSVG") << "load(): path does not exist: \"" << path << "\"";
		return;
	}

	ofBuffer buffer = ofBufferFromFile(path);
	size_t size = buffer.size();

	struct svgtiny_diagram * diagram = svgtiny_create();
	svgtiny_code code = svgtiny_parse(diagram, buffer.getText().c_str(), size, path.c_str(), 0, 0);

	if(code != svgtiny_OK){
		string msg;
		switch(code){
		 case svgtiny_OUT_OF_MEMORY:
			 msg = "svgtiny_OUT_OF_MEMORY";
			 break;

		 case svgtiny_LIBXML_ERROR:
			 msg = "svgtiny_LIBXML_ERROR";
			 break;

		 case svgtiny_NOT_SVG:
			 msg = "svgtiny_NOT_SVG";
			 break;

		 case svgtiny_SVG_ERROR:
			 msg = "svgtiny_SVG_ERROR: line " + ofToString(diagram->error_line) + ": " + diagram->error_message;
			 break;

		 default:
			 msg = "unknown svgtiny_code " + ofToString(code);
			 break;
		}
		ofLogError("ofxSVG") << "load(): couldn't parse \"" << path << "\": " << msg;
	}

	setupDiagram(diagram);

	svgtiny_free(diagram);
}
示例#3
0
文件: Svg.cpp 项目: cviejo/mPD
//--------------------------------------------------------------
void Svg::loadData(string aFormat, string aData){

	string dummy = "smth";

	// string xml = "<svg><path fill=\"#FF00FF\" stroke=\"#00FF00\" stroke-width=\"0.172\" d=\"" + aData + "\"/></svg>";
	string xml = "<svg><path " + aFormat + " d=\"" + aData + "\"/></svg>";
	// string xml = "<svg><path " + aFormat + " stroke-width=\"1\" d=\"" + aData + "\"/></svg>";

	// struct svgtiny_diagram * diagram = svgtiny_create();
	auto diagram = svgtiny_create();

	auto code = svgtiny_parse(diagram, xml.c_str(), xml.size(), dummy.c_str(), 0, 0);

	if (code == svgtiny_OK){

		setupDiagram(diagram);

		svgtiny_free(diagram);

		// ofLogVerbose() << "loaded";
	}
}