C#實現(xiàn)的滾動網(wǎng)頁截圖功能示例
更新時間:2017年07月03日 09:03:46 作者:a771948524
這篇文章主要介紹了C#實現(xiàn)的滾動網(wǎng)頁截圖功能,結(jié)合具體實例形式分析了C#圖形操作的相關(guān)技巧,需要的朋友可以參考下
本文實例講述了C#實現(xiàn)的滾動網(wǎng)頁截圖功能。分享給大家供大家參考,具體如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private int _currentWidth = 1024;
private Bitmap _currentBitmap = null;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (webBrowser1.Document == null)
return;
try
{
int width = _currentWidth;
int height = webBrowser1.Document.Body.ScrollRectangle.Height;
webBrowser1.Width = width;
webBrowser1.Height = height;
_currentBitmap = new Bitmap(width, height);
webBrowser1.Stop();
webBrowser1.DrawToBitmap(_currentBitmap, new Rectangle(0, 0, width, height));
pictureBox1.Image = _currentBitmap;
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "遇到錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
更多關(guān)于C#相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《C#圖片操作技巧匯總》、《C#常見控件用法教程》、《WinForm控件用法總結(jié)》、《C#數(shù)據(jù)結(jié)構(gòu)與算法教程》、《C#面向?qū)ο蟪绦蛟O(shè)計入門教程》及《C#程序設(shè)計之線程使用技巧總結(jié)》
希望本文所述對大家C#程序設(shè)計有所幫助。
相關(guān)文章
混合語言編程—C#使用原生的Directx和OpenGL繪圖的方法
本文要說的是混合C#和C/C++語言編程,在C#的Winform和WPF下使用原生的Direct和OpenGL進行繪圖2013-09-09
C#設(shè)計模式之Builder生成器模式解決帶老婆配置電腦問題實例
這篇文章主要介紹了C#設(shè)計模式之Builder生成器模式解決帶老婆配置電腦問題,簡單介紹了生成器模式的概念、功能并結(jié)合具體實例形式分析了C#生成器模式解決配電腦問題的步驟與相關(guān)操作技巧,需要的朋友可以參考下2017-09-09

