Пример #1
0
/**
 * Initialise image content handlers
 *
 * \return NSERROR_OK on success, appropriate error otherwise.
 */
nserror image_init(void)
{
	nserror error = NSERROR_OK;

#ifdef WITH_BMP
	error = nsbmp_init();
	if (error != NSERROR_OK)
		return error;
#endif

#ifdef WITH_GIF
	error = nsgif_init();
	if (error != NSERROR_OK)
		return error;
#endif

#ifdef WITH_BMP
	error = nsico_init();
	if (error != NSERROR_OK)
		return error;
#endif

#ifdef WITH_JPEG
	error = nsjpeg_init();
	if (error != NSERROR_OK)
		return error;
#endif

#ifdef WITH_PNG
	error = nspng_init();
	if (error != NSERROR_OK)
		return error;
#endif

#ifdef WITH_NSSPRITE
	error = nssprite_init();
	if (error != NSERROR_OK)
		return error;
#endif

	/* Prefer rsvg over libsvgtiny for svgs */
#ifdef WITH_NS_SVG
	error = svg_init();
	if (error != NSERROR_OK)
		return error;
#endif
#ifdef WITH_RSVG
	error = nsrsvg_init();
	if (error != NSERROR_OK)
		return error;
#endif

#ifdef WITH_WEBP
	error = nswebp_init();
	if (error != NSERROR_OK)
		return error;
#endif

	return error;
}
Пример #2
0
// generate a svg			
void Layer::save_svg(const char *filename) {
 FILE *file;
  
 file = fopen(filename, "w");
 svg_init(file);
 svg_comment("slice in for height=%f", height);
  
 
 for(std::vector<line*>::iterator it = segments->begin(); it != segments->end(); it++) {
   line *l = *it;
   svg_line(l->p1.x, l->p1.y, l->p2.x, l->p2.y);
 }

  svg_footer();
  fclose(file);



}
Пример #3
0
int main(int argc, char *argv[])
{
	struct rooted_tree *tree;
	struct parameters params;
	int align_leaves;
	int with_scale_bar;
	enum display_status status; 
	void (*node_destroyer)(struct rnode *) = NULL;

	params = get_params(argc, argv);

	if (params.svg) {
		set_svg_parameters(params);
		if(! svg_init()) {
			fprintf (stderr, "%s\n", get_last_error_message());
			exit(EXIT_FAILURE);
		}
		node_destroyer = destroy_svg_node_data;
	}

	while (NULL != (tree = parse_tree())) {
		align_leaves = is_cladogram(tree);
		/* show scale bar IFF tree is NOT a cladogram. Since
		 * is_cladogram() takes some time to run, we just look
		 * up  'align_leaves' which has the same value. */
		with_scale_bar = !align_leaves;
		/* User can also suppress scale bar */
		if (params.no_scale_bar) with_scale_bar = FALSE;

		if (params.svg) {
			svg_header(leaf_count(tree), with_scale_bar);
			svg_run_params_comment(argc, argv);
			status = display_svg_tree(tree,
					align_leaves, with_scale_bar,
					params.branch_length_unit);
			switch(status) {
				case DISPLAY_OK:
					break;
					assert(0);
				case DISPLAY_MEM_ERROR:
					perror(NULL);
					exit(EXIT_FAILURE);
				/* The following two should never happen */
				case DISPLAY_UNKNOWN_STYLE:
				default:
					assert(0);
			}
			svg_footer();
		} else {
			prettify_labels(tree);
			status = display_tree(tree, params.width,
					align_leaves,
					params.inner_label_pos,
					with_scale_bar,
					params.branch_length_unit,
					params.scale_zero_at_root);
			switch(status) {
				case DISPLAY_OK:
					break;
					assert(0);
				case DISPLAY_MEM_ERROR:
					perror(NULL);
					exit(EXIT_FAILURE);
				/* The following two should never happen */
				case DISPLAY_UNKNOWN_STYLE:
				default:
					assert(0);
			}
		}
		destroy_tree_cb(tree, node_destroyer);
	}

	return 0;
}