Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Text;
// You need to add System. Drawing and System. Windows. Forms references.
Using System. Drawing;
Using System. Drawing. Drawing2D;
Using System. Drawing. Imaging;
Using System. Windows. Forms;
Namespace PageNumber
{
Class Program
{
[STAThread]
Static void Main (string [] args)
{
String url = "http://www.531.hk /";
GetImage thumb = new GetImage (url, 1024,768,102 4, 768 );
System. Drawing. Bitmap x = thumb. GetBitmap ();
String FileName = DateTime. Now. ToString ("yyyyMMddhhmmss ");
X. Save (@ "C:" + FileName + ". jpg ");
Console. WriteLine (@ "C:" + FileName + ". jpg saved successfully .");
Console. ReadKey ();
}
Public class GetImage
{
Private int S_Height;
Private int S_Width;
Private int F_Height;
Private int F_Width;
Private string MyURL;
Public int ScreenHeight
{
Get {return S_Height ;}
Set {S_Height = value ;}
}
Public int ScreenWidth
{
Get {return S_Width ;}
Set {S_Width = value ;}
}
Public int ImageHeight
{
Get {return F_Height ;}
Set {F_Height = value ;}
}
Public int ImageWidth
{
Get {return F_Width ;}
Set {F_Width = value ;}
}
Public string WebSite
{
Get {return MyURL ;}
Set {MyURL = value ;}
}
Public GetImage (string WebSite, int ScreenWidth, int ScreenHeight, int ImageWidth, int ImageHeight)
{
This. WebSite = WebSite;
This. ScreenWidth = ScreenWidth;
This. ScreenHeight = ScreenHeight;
This. ImageHeight = ImageHeight;
This. ImageWidth = ImageWidth;
}
Public Bitmap GetBitmap ()
{
WebPageBitmap Shot = new WebPageBitmap (this. WebSite, this. ScreenWidth, this. ScreenHeight );
Shot. GetIt ();
Bitmap Pic = Shot. DrawBitmap (this. ImageHeight, this. ImageWidth );
Return Pic;
}
}
Class WebPageBitmap
{
WebBrowser MyBrowser;
String URL;
Int Height;
Int Width;
Public WebPageBitmap (string url, int width, int height)
{
This. Height = height;
This. Width = width;
This. URL = url;
MyBrowser = new WebBrowser ();
MyBrowser. ScrollBarsEnabled = false;
MyBrowser. Size = new Size (this. Width, this. Height)