[Gtk-sharp-list] Gdk.Pixbuf.FromDrawable broken?

nivels nivels.arevelec at googlemail.com
Fri Nov 20 18:26:51 EST 2009


Hi,
i have little problem with getting a pixbuf from a widget.

So with the attached Code, i'm able to get a Gdk.Pixbuf from a widget, but
when i show it in a Gtk.Image it looks "broken".
I googled a lot in the last few days, but i'm not able to find a solution.

I Uploaded a file that you can see what i mean.

Thank you!

using System;
using Gtk;

namespace getfromdrawablemono
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			Application.Init ();
				
			
			Gtk.Window win = new Gtk.Window("Test");
			Gtk.VBox vbox = new Gtk.VBox(false,10);
			Gtk.HBox hbox = new Gtk.HBox(true,10);
			Gtk.Button btn_click = new Gtk.Button(Gtk.Stock.Add);
			Gtk.Button btn_src = new Gtk.Button(Gtk.Stock.Copy);
			Gtk.Image img_dest = new Gtk.Image();
			
			
			win.Add(vbox);
			vbox.PackStart(btn_click,false,false,2);
			vbox.PackStart(hbox,true,true,2);
			hbox.PackStart(btn_src,false,true,2);
			hbox.PackStart(img_dest,true,true,2);
			win.DefaultHeight = 200;
			win.DefaultWidth = 200;			
			
			win.Destroyed += delegate {
				Application.Quit();
			};
			btn_click.Clicked += delegate(object sender, EventArgs e) {

				int x,y,width,height,dept;
				btn_src.GdkWindow.GetGeometry(out x,out y,out width,out height, out
dept);
				int x2,y2,width2,height2,dept2;
				img_dest.GdkWindow.GetGeometry(out x2,out y2,out width2,out height2, out
dept2);

				Gdk.Pixbuf pb;
				pb =
Gdk.Pixbuf.FromDrawable(btn_src.GdkWindow,btn_src.GdkWindow.Colormap , x , y
,0 ,0,width,height);
				
				img_dest.Pixbuf = pb;

			};
			
			win.ShowAll();
			
			Application.Run ();			
			
			
		}
	}
} http://old.nabble.com/file/p26451912/Bildschirmfoto-2.png
Bildschirmfoto-2.png 
-- 
View this message in context: http://old.nabble.com/Gdk.Pixbuf.FromDrawable-broken--tp26451912p26451912.html
Sent from the Mono - Gtk# mailing list archive at Nabble.com.



More information about the Gtk-sharp-list mailing list