Re: [Mono-list] About the thumbnail creator

2004-06-17 Thread Denis Gervalle
Replace wc.LoadUrl(args[0]); by wc.LoadUrl(url); and maybe, it will 
works better when the url is not provided as the first argument. 
Checking that url is not null before proceding may also be useful when 
you forget to provide an Url.

Denis Gervalle
SOFTEC sa
http://www.softec.st
Benoit Caccinolo wrote:
Hi all,
Did anyone try the code to generate web page thumbnails given by Miguel
de Icaza on his blog
(http://primates.ximian.com/~miguel/archive/2004/Jun-14.html)
The resulting shot has the good size but it is empty. I'm using Mono
Beta2 from the sources on a Debian. 

An idea ? 

___
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list


[Mono-list] About the thumbnail creator

2004-06-16 Thread Benoit Caccinolo
Hi all,

Did anyone try the code to generate web page thumbnails given by Miguel
de Icaza on his blog
(http://primates.ximian.com/~miguel/archive/2004/Jun-14.html)

The resulting shot has the good size but it is empty. I'm using Mono
Beta2 from the sources on a Debian. 

An idea ? 

-- 
Benoit C.

___
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] About the thumbnail creator

2004-06-16 Thread Benoit Caccinolo
When I launch it a window appears but nothing is displayed in it. Few
seconds after the program quits and my shot.png has the good size but is
empty. 

The problem is the same with any other web page, even local one.

On Wed, 2004-06-16 at 16:57, Denis Gervalle wrote:
 Benoit Caccinolo wrote:
  On Wed, 2004-06-16 at 14:34, Denis Gervalle wrote:
  
 Replace wc.LoadUrl(args[0]); by wc.LoadUrl(url); and maybe, it will 
 works better when the url is not provided as the first argument. 
 Checking that url is not null before proceding may also be useful when 
 you forget to provide an Url.
  
  
  It is modified but the problem is the same :(
  
 
 Benoit,
 
 What Url are you trying ?
 For example, I have notice that it works well for http://www.go-mono.com
 but not for http://www.softec.st.
 This is probably due to some redirection in the way.
 Here is my command line that works:
 mono progname.exe -width 240 -height 160 http://www.go-mono.com
 
 Denis Gervalle
 SOFTEC sa
 http://www.softec.st


___
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] About the thumbnail creator

2004-06-16 Thread Todd Berman
I think the issue is mozilla not getting enough time to render. I would 
try putting a Thread.Sleep (3000) or something as the first line of code 
in the NetStop handler.

--Todd
Benoit Caccinolo wrote:
When I launch it a window appears but nothing is displayed in it. Few
seconds after the program quits and my shot.png has the good size but is
empty. 

The problem is the same with any other web page, even local one.
On Wed, 2004-06-16 at 16:57, Denis Gervalle wrote:
Benoit Caccinolo wrote:
On Wed, 2004-06-16 at 14:34, Denis Gervalle wrote:

Replace wc.LoadUrl(args[0]); by wc.LoadUrl(url); and maybe, it will 
works better when the url is not provided as the first argument. 
Checking that url is not null before proceding may also be useful when 
you forget to provide an Url.

It is modified but the problem is the same :(
Benoit,
What Url are you trying ?
For example, I have notice that it works well for http://www.go-mono.com
but not for http://www.softec.st.
This is probably due to some redirection in the way.
Here is my command line that works:
mono progname.exe -width 240 -height 160 http://www.go-mono.com
Denis Gervalle
SOFTEC sa
http://www.softec.st

___
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list
___
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] About the thumbnail creator

2004-06-16 Thread Benoit Caccinolo
On Wed, 2004-06-16 at 18:20, Todd Berman wrote:
 I think the issue is mozilla not getting enough time to render. I would 
 try putting a Thread.Sleep (3000) or something as the first line of code 
 in the NetStop handler.

The problem is surely a problem of time. But with a Thread.Sleep in the
MakeShot method the problem is not solved cause the sleep stops the
rendering too :)

My solution is too put a button to launch the MakeShot method. It is
less elegant but it works.

Thx

Here is the code.

using System;
using Gtk;
using Gecko;

class Thumbnail { 
static WebControl wc;
static string output = shot.png;
static string url;
static int width = -1;
static int height = -1;

static void Main (string [] args)
{
for (int i = 0; i  args.Length; i++){
switch (args [i]){
case -width:
try {
i++;
width = Int32.Parse (args [i]);
} catch {
Console.WriteLine (-width requires an numeric 
argument);
}
break;
case -height:
try {
i++;
height = Int32.Parse (args [i]);
} catch {
Console.WriteLine (-height requires an 
numeric argument);
}
break;
case -help:
case -h:
Help ();
break;

default:
if (url == null)
url = args [i];
else if (output == null)
output = args [i];
else
Help ();
break;
}
}

Application.Init();
Window w = new Window (test);
VBox vbox = new VBox ();
Button bt = new Button (Take a Shot);
bt.Clicked += new EventHandler (btn_click);
vbox.PackStart (bt);

wc = new WebControl ();
wc.LoadUrl (url);
//wc.NetStop += MakeShot;
//wc.Show ();
wc.SetSizeRequest (800, 600);
vbox.PackStart (wc);
w.Add (vbox);
w.ShowAll ();
Application.Run();

System.Threading.Thread.Sleep (1500);
}

static void Help ()
{
Console.WriteLine (Usage is: shot [-width N] [-height N] url
[shot]);
Environment.Exit (0);
}

 static void btn_click (object obj, EventArgs args)
 {
  Console.WriteLine (Button Clicked);
  MakeShot();
 }
 
static void MakeShot()
{   
System.Console.Write(Taking a new shot);  

Gdk.Window win = wc.GdkWindow;
int iwidth = wc.Allocation.Width;
int iheight = wc.Allocation.Height;
Gdk.Pixbuf p = new Gdk.Pixbuf (Gdk.Colorspace.Rgb, false, 8, iwidth,
iheight);
Gdk.Pixbuf scaled;

p = p.GetFromDrawable (win, win.Colormap, 0, 0, 0, 0, iwidth,
iheight);
if (width == -1){
if (height == -1)
scaled = p;
else
scaled = p.ScaleSimple (height * iwidth / iheight, 
height,
Gdk.InterpType.Hyper);
} else {
if (height == -1)
scaled = p.ScaleSimple (width, width * iheight / 
iwidth,
Gdk.InterpType.Hyper);
else
scaled = p.ScaleSimple (width, height, 
Gdk.InterpType.Hyper);
}

scaled.Savev (output, png, null, null);  
}

}



___
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] About the thumbnail creator

2004-06-16 Thread Todd Berman
heh, the or something was important ;)
The proper way to do it, is to write a new event handle, and bind that 
to NetStop. Inside that event handler, you set a Gtk.Timeout for 3 
seconds later, and then in the Gtk.Function the Gtk.Timeout calls, you 
take your sshot.

--TOdd
Benoit Caccinolo wrote:
On Wed, 2004-06-16 at 18:20, Todd Berman wrote:
I think the issue is mozilla not getting enough time to render. I would 
try putting a Thread.Sleep (3000) or something as the first line of code 
in the NetStop handler.

The problem is surely a problem of time. But with a Thread.Sleep in the
MakeShot method the problem is not solved cause the sleep stops the
rendering too :)
My solution is too put a button to launch the MakeShot method. It is
less elegant but it works.
Thx
Here is the code.
using System;
using Gtk;
using Gecko;
class Thumbnail { 
	static WebControl wc;
	static string output = shot.png;
	static string url;
	static int width = -1;
	static int height = -1;
	
	static void Main (string [] args)
	{
		for (int i = 0; i  args.Length; i++){
			switch (args [i]){
			case -width:
try {
	i++;
	width = Int32.Parse (args [i]);
} catch {
	Console.WriteLine (-width requires an numeric argument);
}
break;
			case -height:
try {
	i++;
	height = Int32.Parse (args [i]);
} catch {
	Console.WriteLine (-height requires an numeric argument);
}
break;
			case -help:
			case -h:
Help ();
break;

			default:
if (url == null)
	url = args [i];
else if (output == null)
	output = args [i];
else
	Help ();
break;
			}
		}

Application.Init();
Window w = new Window (test);
VBox vbox = new VBox ();
Button bt = new Button (Take a Shot);
bt.Clicked += new EventHandler (btn_click);
vbox.PackStart (bt);
wc = new WebControl ();
wc.LoadUrl (url);
//wc.NetStop += MakeShot;
//wc.Show ();
wc.SetSizeRequest (800, 600);
vbox.PackStart (wc);
w.Add (vbox);
w.ShowAll ();
Application.Run();

System.Threading.Thread.Sleep (1500);
}
	static void Help ()
	{
		Console.WriteLine (Usage is: shot [-width N] [-height N] url
[shot]);
		Environment.Exit (0);
	}
	
	 static void btn_click (object obj, EventArgs args)
 {
  Console.WriteLine (Button Clicked);
  MakeShot();
 }
 
	static void MakeShot()
	{		
		System.Console.Write(Taking a new shot);	
		
		Gdk.Window win = wc.GdkWindow;
		int iwidth = wc.Allocation.Width;
		int iheight = wc.Allocation.Height;
		Gdk.Pixbuf p = new Gdk.Pixbuf (Gdk.Colorspace.Rgb, false, 8, iwidth,
iheight);
		Gdk.Pixbuf scaled;
		
		p = p.GetFromDrawable (win, win.Colormap, 0, 0, 0, 0, iwidth,
iheight);
		if (width == -1){
			if (height == -1)
scaled = p;
			else
scaled = p.ScaleSimple (height * iwidth / iheight, height,
Gdk.InterpType.Hyper);
		} else {
			if (height == -1)
scaled = p.ScaleSimple (width, width * iheight / iwidth,
Gdk.InterpType.Hyper);
			else
scaled = p.ScaleSimple (width, height, Gdk.InterpType.Hyper);
		}
		
		scaled.Savev (output, png, null, null);  
	}
	
}


___
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list
___
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list