Re: Printing library




Hello,

In case somebody haven't yet implemented this, here are my 2 functions

Lauris

On Sat, 5 Feb 2000, Miguel de Icaza wrote:

> 
> > It would be extremely nice to add 2 convenience functions to gnome-print:
> > 
> > gnome_print_vpath (GnomePrintContext *, ArtVpath *);
> > gnome_print_bpath (GnomePrintContext *, ArtBpath *);
> 
> Sounds like a good idea.  Can you mail me an implementation of this?
> 
> > Probably also:
> > 
> > gnome_print_art_pixbuf (GnomePrintContext *, ArtPixBuf *)
> 
> Yes.  
> 
> Ideally in the future all printing contexts should support alpha
> transparency.
> 
> I am also worried, because I found no references to the alpha channel
> on the public API of Gnome Print.  I will add it shortly.
> 
> Miguel.
> 

#include <libart_lgpl/art_vpath.h>
#include <libart_lgpl/art_bpath.h>
#include <libgnomeprint/gnome-print.h>

void
gnome_print_bpath (GnomePrintContext * gpc, ArtBpath * bpath, gboolean append)
{
	ArtBpath * p;
	gboolean closed;

	g_return_if_fail (gpc != NULL);
	g_return_if_fail (GNOME_IS_PRINT_CONTEXT (gpc));
	g_return_if_fail (bpath != NULL);

	if (bpath->code == ART_END) return;

	g_return_if_fail ((bpath->code == ART_MOVETO) || (bpath->code == ART_MOVETO_OPEN));

	closed = (bpath->code == ART_MOVETO);

	if (!append)
		gnome_print_newpath (gpc);

	gnome_print_moveto (gpc,
		bpath->x3,
		bpath->y3);

	for (p = bpath + 1; p->code != ART_END; p++) {
		switch (p->code) {
		case ART_MOVETO:
		case ART_MOVETO_OPEN:
			if (closed)
				gnome_print_closepath (gpc);

			closed = (p->code == ART_MOVETO);

			gnome_print_moveto (gpc,
				p->x3,
				p->y3);
			break;
		case ART_LINETO:
			gnome_print_lineto (gpc,
				p->x3,
				p->y3);
			break;
		case ART_CURVETO:
			gnome_print_curveto (gpc,
				p->x1,
				p->y1,
				p->x2,
				p->y2,
				p->x3,
				p->y3);
			break;
		default:
			g_log (G_LOG_DOMAIN,
				G_LOG_LEVEL_CRITICAL,
				"Invalid Bpath element");
			return;
			break;
		}
	}

	if (closed)
		gnome_print_closepath (gpc);

}

void
gnome_print_vpath (GnomePrintContext * gpc, ArtVpath * vpath, gboolean append)
{
	ArtVpath * p;
	gboolean closed;

	g_return_if_fail (gpc != NULL);
	g_return_if_fail (GNOME_IS_PRINT_CONTEXT (gpc));
	g_return_if_fail (vpath != NULL);

	if (vpath->code == ART_END) return;

	g_return_if_fail ((vpath->code == ART_MOVETO) || (vpath->code == ART_MOVETO_OPEN));

	closed = (vpath->code == ART_MOVETO);

	if (!append)
		gnome_print_newpath (gpc);

	gnome_print_moveto (gpc,
		vpath->x,
		vpath->y);

	for (p = vpath + 1; p->code != ART_END; p++) {
		switch (p->code) {
		case ART_MOVETO:
		case ART_MOVETO_OPEN:
			if (closed)
				gnome_print_closepath (gpc);

			closed = (p->code == ART_MOVETO);

			gnome_print_moveto (gpc,
				p->x,
				p->y);
			break;
		case ART_LINETO:
			gnome_print_lineto (gpc,
				p->x,
				p->y);
			break;
		default:
			g_log (G_LOG_DOMAIN,
				G_LOG_LEVEL_CRITICAL,
				"Invalid Vpath element");
			return;
			break;
		}
	}

	if (closed)
		gnome_print_closepath (gpc);

}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]