
×îÖÕÔËÐеóöµÄͼÈçÏ£º
Ò³Ãæ´úÂ룺Form1.cs
/* * ×÷ÕߣºHJL * Blog:Http://www.cnblogs.com/xt_hjl * »ñÈ¡ÍøÕ¾ËõÂÔͼ³ÌÐò * 2010Äê8ÔÂ×îºóÒ»Ìì * »¶ÓÐ޸ĺʹ«²¥ * ×îºÃÄܱ£Áô¸ÃÐÅÏ¢^_^ * Ò²»¶Ó´ó¼Ò·ÃÎÊÎҵIJ©¿Í * Http://www.cnblogs.com/xt_hjl * */ using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Utility; using System.Threading; using System.Text.RegularExpressions; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.textBox1.Text)) { MessageBox.Show("ÇëÊäÈëÒª½ØͼµÄÍøÖ·£¡"); return; } Regex r = new Regex(@"http://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?"); if (r.IsMatch(this.textBox1.Text)) { if (string.IsNullOrEmpty(this.textBox2.Text)) { MessageBox.Show("ÇëÑ¡ÔñÒª±£´æµÄĿ¼£¡"); return; } if (string.IsNullOrEmpty(this.textBox3.Text)) { MessageBox.Show("ÇëÊäÈëÒª±£´æµÄÎļþÃû£¡"); return; } try { GetWebImage gwi = new GetWebImage(this.textBox1.Text, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, 320, 240); Bitmap bi = gwi.GetBitmap(); bi.Save(this.textBox2.Text.Trim() + "\\" + this.textBox3.Text.Trim()); System.Diagnostics.Process.Start(this.textBox2.Text.Trim()+"\\"+this.textBox3.Text.Trim()); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { MessageBox.Show("ÇëÊäÈëÕýÈ·µÄÍøÖ·£¡"); return; } } private void button2_Click(object sender, EventArgs e) { folderBrowserDialog1.ShowDialog(this); this.textBox2.Text = folderBrowserDialog1.SelectedPath; } } }
ÁíÍ⻹ÔÚÆô¶¯Ê±×öÁËÌرð´¦Àí¡£¡£¡£¡£¿´´úÂ룺Program.cs
/* * ×÷ÕߣºHJL * Blog:Http://www.cnblogs.com/xt_hjl * »ñÈ¡ÍøÕ¾ËõÂÔͼ³ÌÐò * 2010Äê8ÔÂ×îºóÒ»Ìì * »¶ÓÐ޸ĺʹ«²¥ * ×îºÃÄܱ£Áô¸ÃÐÅÏ¢^_^ * Ò²»¶Ó´ó¼Ò·ÃÎÊÎҵIJ©¿Í * Http://www.cnblogs.com/xt_hjl * */ using System; using System.Collections.Generic; using System.Windows.Forms; using Utility; using System.Drawing; using System.Text.RegularExpressions; namespace WindowsFormsApplication1 { static class Program { /// <summary> /// Ó¦ÓóÌÐòµÄÖ÷Èë¿Úµã¡£ ///ex: a.exe www.cnblogs.com c:\\ a.bmp 320 340 on /// </summary> [STAThread] static void Main(string[] args) { if (args.Length == 6) { Regex r = new Regex(@"http://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?"); if (r.IsMatch(args[0])) { try { GetWebImage gwi = new GetWebImage(args[0], 1024, 768, Convert.ToInt32(args[3]), Convert.ToInt32(args[4])); Bitmap bi = gwi.GetBitmap(); bi.Save(args[1] + "\\" + args[2]); if (args[5].Equals("on")) { System.Diagnostics.Process.Start(args[1] + "\\" + args[2]); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { MessageBox.Show("²ÎÊý²»ÕýÈ·£¬È磺http://www.cnblogs.com/xt_hjl c:\\ a.bmp 320 240 on"); } return; } else if (args.Length > 0) { MessageBox.Show("²ÎÊý²»¹»£¬È磺http://www.cnblogs.com/xt_hjl c:\\ a.bmp 320 240 on"); return; } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } } }
/* * ÐÞ¸ÄÕߣºÎâÅô(AlphaWu) * Blog:Http://AlphaWu.CoM * »ñÈ¡ÍøÕ¾ËõÂÔͼ´úÂë * 2006 Ê¥µ®½Ú * C#´úÂë¸ù¾Ý¸ÃÒ³Ãæ¡°http://www.codeproject.com/useritems/website_screenshot.asp¡± * VB.Net´úÂëÐ޸ĶøÀ´ * »¶ÓÐ޸ĺʹ«²¥ * ×îºÃÄܱ£Áô¸ÃÐÅÏ¢^_^ * Ò²»¶Ó´ó¼Ò·ÃÎÊÎҵIJ©¿Í * Http://AlphaWu.Cnblogs.CoM * * Http://AlphaWu.CoM * * */ using System; using System.Drawing; using System.Drawing.Imaging; using System.Windows.Forms; namespace Utility { /// <summary> /// GetImage thumb = new GetImage(url, 1024, 768, 320, 240); //System.Drawing.Bitmap x = thumb.GetBitmap(); //x.Save(Response.OutputStream, ImageFormat.Jpeg); //Response.ContentType = "image/jpeg"; /// </summary> public class GetWebImage { int S_Height; int S_Width; int F_Height; int F_Width; 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; } } /// <summary> /// Initializes a new instance of the <see cref="GetWebImage"/> class. /// </summary> /// <param name="WebSite">The web site.</param> /// <param name="ScreenWidth">Width of the screen.</param> /// <param name="ScreenHeight">Height of the screen.</param> /// <param name="ImageWidth">Width of the image.</param> /// <param name="ImageHeight">Height of the image.</param> public GetWebImage(string WebSite, int ScreenWidth, int ScreenHeight, int ImageWidth, int ImageHeight) { this.WebSite = WebSite; this.ScreenHeight = ScreenHeight; this.ScreenWidth = ScreenWidth; this.ImageHeight = ImageHeight; this.ImageWidth = ImageWidth; } /// <summary> /// Gets the bitmap. /// </summary> /// <returns></returns> 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; } } /// <summary> /// /// </summary> public class WebPageBitmap { WebBrowser MyBrowser; string URL; int Height; int Width; /// <summary> /// Initializes a new instance of the <see cref="WebPageBitmap"/> class. /// </summary> /// <param name="url">The URL.</param> /// <param name="width">The width.</param> /// <param name="height">The height.</param> public WebPageBitmap(string url, int width, int height) { this.URL = url; this.Width = width; this.Height = height; MyBrowser = new WebBrowser(); MyBrowser.ScrollBarsEnabled = false; MyBrowser.Size = new Size(this.Width, this.Height); } /// <summary> /// Gets it. /// </summary> public void GetIt() { MyBrowser.Navigate(this.URL); while (MyBrowser.ReadyState != WebBrowserReadyState.Complete) { Application.DoEvents(); } } /// <summary> /// Draws the bitmap. /// </summary> /// <param name="theight">The theight.</param> /// <param name="twidth">The twidth.</param> /// <returns></returns> public Bitmap DrawBitmap(int theight, int twidth) { Bitmap myBitmap = new Bitmap(this.Width, this.Height); Rectangle DrawRect = new Rectangle(0, 0, this.Width, this.Height); MyBrowser.DrawToBitmap(myBitmap, DrawRect); System.Drawing.Image imgOutput = myBitmap; System.Drawing.Bitmap oThumbNail = new Bitmap(twidth, theight, imgOutput.PixelFormat); Graphics g = Graphics.FromImage(oThumbNail); g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighSpeed; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed; g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBilinear; Rectangle oRectangle = new Rectangle(0, 0, twidth, theight); g.DrawImage(imgOutput, oRectangle); try { return oThumbNail; } catch { return null; } finally { imgOutput.Dispose(); imgOutput = null; MyBrowser.Dispose(); MyBrowser = null; } } } }
ÍƼöÐÅÏ¢
ÈÈÃÅÐÅÏ¢
- nohup: redirecting stderr to stdou....
- ʹÓÃlog_formatΪNginx·þÎñÆ÷ÉèÖøüÏêϸµÄÈÕÖ¾¸ñʽ
- jquery easyUI--dataGrid-Json
- [Ô´´]·ÂGoogle Reader¡¢ÐÂÀË΢²©¡¢ÌÚѶ΢²©µ....
- ÀûÓÃKeepalived+mysql¹¹½¨¸ß¿ÉÓÃMySQLË«Ö÷×Ô¶....
- Nginx+keepalivedʵÏÖ¸ºÔؾùºâºÍË«»úÈȱ¸¸ß¿ÉÓÃ
- jqueryʵÏÖÒ³Ãæ¼ÓÔؽø¶ÈÌõ
- Rolling cURL: PHP²¢·¢×î¼Ñʵ¼ù
- codeigniter ·ÓÉÖÕ¼«ÓÅ»¯(url rewrite)
- linuxÏÂÉèÖÃsshÎÞÃÜÂëµÇ¼
×î½ü¸üÐÂ
- Asp.net MVCÔ´Âë·ÖÎö--Model Validation(Se....
- .Net À¬»ø»ØÊÕ»úÖÆÔÀíºÍËã·¨£¨Ò»£©
- .netʵÌåнâ
- ·ÖÎöASP.NET¶ÁÈ¡XMLÎļþ4ÖÖ·½·¨
- »ñÈ¡ÍøÕ¾ËõÂÔͼ´úÂë
- Asp.net ¸ù¾ÝIPµØÖ·»ñÈ¡¿çÍø¶ÎmacµØÖ·º¯Êý¡¾ËѲء¿
- ¹ýÂËÃô¸Ð¹Ø¼ü×Ö¡£
- Éú³ÉÖ¸¶¨Î»ÊýµÄËæ»ú×Ö·û´®
- ¿Í»§¶Ë»ñÈ¡MACµØÖ·£¬µ½·þÎñÆ÷ÑéÖ¤
- ²½²½ÎªÓª .NETÈý²ã¼Ü¹¹½âÎö ¶þ¡¢Êý¾Ý¿âÉè¼Æ
ÆÀÂÛ