[Gtk-sharp-list] Gnome.Print

Larry Ewing lewing@ximian.com
Mon, 05 Apr 2004 08:36:07 -0500

Content-Type: text/plain
Content-Transfer-Encoding: 7bit

I forgot to attach the new file, here it is.


On Mon, 2004-04-05 at 08:31 -0500, Larry Ewing wrote:
> I was playing with the Gnome.Print bindings a while a ago and ran into
> the problem that it was impossible to print images.  After a looking
> into it a little I've come up with a couple of possible patches and I'm
> wondering where to proceed from here.
> The first patch changes the generators signature so that it is possible
> to use the *image functions.  The second one adds a Print.Pixbuf method
> and imports the *image functions with a different signature since
> Pixbuf.Pixels is a pointer type.  I guess I'm wondering where to go from
> here.
> --Larry

Content-Disposition: attachment; filename=Print.custom
Content-Type: text/plain; name=Print.custom; charset=iso-8859-15
Content-Transfer-Encoding: 7bit

// Pixbuf.custom - Gdk Pixbuf class customizations
// Authors: 
//	Larry Ewing <lewing@ximian.com
// (C) 2004 Novell, Inc. (Larry Ewing)
// This code is inserted after the automatically generated code

	static extern unsafe int gnome_print_rgbimage(IntPtr pc, byte * data, int width, int height, int rowstride);

	static extern unsafe int gnome_print_rgbaimage(IntPtr pc, byte * data, int width, int height, int rowstride);

	public static int Pixbuf (Gnome.PrintContext pc, Gdk.Pixbuf image) {
		int raw_ret = 0;

		if (image.NChannels == 4)
			raw_ret = gnome_print_rgbaimage(pc.Handle, image.Pixels, image.Width, image.Height, image.Rowstride);
			raw_ret = gnome_print_rgbimage(pc.Handle, image.Pixels, image.Width, image.Height, image.Rowstride);

		int ret = raw_ret;
		return ret;