海纳百川,有容乃大
善于总结,积累软财富
posts - 159,  comments - 432,  trackbacks - 63
【标题】ASP.NET 如何实现抓屏功能

【问题描述】
           在ASP.NET中实现抓屏的功能。
           
            条件:1、页面中有一个div,在div中嵌入了其它网站的JS接口,显示出一张地图。
                        2、利用抓屏的功能,把div中的显示的一张地图,通过抓屏保存成.gif 或.jpg文件,并保存到服务
                                 器上。
                        3、不需要在客户段安置任何软件。


各位大侠帮帮忙,多谢了!


【关键自】ASP.NET 实现抓屏 |  ASP.NET 实现拷屏
         
posted on 2007-03-31 10:02 海纳百川 阅读(615) 评论(6)  编辑 收藏 所属分类: WEB开发/.NET

FeedBack:
2007-03-31 12:22 | zxy [未注册用户]
这个问题~~估计纯页面方式做不到,要用到ActiveX控件才能实现。
  回复  引用    
2007-03-31 19:52 | aspnetx      
是不是前段时间比较火的那个srceen shot还是什么来着?
名字忘记了
  回复  引用  查看    
2007-03-31 19:54 | aspnetx      
我晕啊,有人发广告也是发关于长春的新闻
怎么我们长春在这种新闻上这么出名啊?
  回复  引用  查看    
2007-04-02 12:01 | 海纳百川      
利用win Form 很容易实现的,但对于Web Form怎么实现呢?

win Form 实现抓屏(拷屏)的代码:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

using System.Drawing.Imaging;

namespace 捕获屏幕
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.SaveFileDialog saveFileDialog1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();

//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}

/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(96, 192);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "截取屏幕";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// saveFileDialog1
//
this.saveFileDialog1.Filter = "JPG文件|*.Jpg";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "C#捕获当前屏幕!";
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}

//声明一个API函数
[ System.Runtime.InteropServices.DllImportAttribute ( "gdi32.dll" ) ]
private static extern bool BitBlt
(
IntPtr hdcDest , // 目标 DC的句柄
int nXDest ,
int nYDest ,
int nWidth ,
int nHeight ,
IntPtr hdcSrc , // 源DC的句柄
int nXSrc ,
int nYSrc ,
System.Int32 dwRop // 光栅的处理数值
);

private void button1_Click(object sender, System.EventArgs e)
{
//获得当前屏幕的大小
Rectangle rect = new Rectangle ( ) ;
//获得当前屏幕的大小,通过名字空间"System.Windows.Forms"中的"Screen"类的GetWorkingArea()方法
rect = Screen.GetWorkingArea ( this ) ;
//创建一个以当前屏幕为模板的图象--获得当前屏幕的graphic对象
Graphics g1 = this.CreateGraphics ( ) ;
//创建以屏幕大小为标准的位图
Image MyImage = new Bitmap ( rect.Width , rect.Height , g1 ) ;
Graphics g2 = Graphics.FromImage ( MyImage ) ;
//得到屏幕的DC
IntPtr dc1 = g1.GetHdc ( ) ;
//得到Bitmap的DC
IntPtr dc2 = g2.GetHdc ( ) ;
//调用此API函数,实现屏幕捕获
BitBlt ( dc2 , 0 , 0 , rect.Width , rect.Height , dc1 , 0 , 0 , 13369376 ) ;
//释放掉屏幕的DC
g1.ReleaseHdc ( dc1 ) ;
//释放掉Bitmap的DC
g2.ReleaseHdc ( dc2 ) ;
//以JPG文件格式来保存
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
MyImage.Save( @saveFileDialog1.FileName,ImageFormat.Jpeg);
}

}
}
}

  回复  引用  查看    
2007-04-02 18:02 | 随风流月      
貌似要用到 MSHTML...
  回复  引用  查看    
2007-04-03 13:47 | 一起疯 [未注册用户]
actove x
  回复  引用    

标题  
姓名  
主页
Email (博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      


相关链接:
 

与我联系

搜索

 

留言簿(14)

我参与的团队

我的标签

随笔分类(171)

随笔档案(158)

文章分类(2)

Internet 资源

技术网站

友情链接

最新随笔

积分与排名

  • 积分 - 204042
  • 排名 - 166

最新评论

阅读排行榜

评论排行榜

Draging,what do you see!
首页原创.NET区 div1
.NET新手区 div2
精华区 div3
专家区 div4
读书心得区 div5
百度主题实验室
百度主题推广 div7