当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > 快速对图片进行滤光处理

ASP.NET
深入理解__doPostBack 客户端调用服务端事件
asp.net(c#)利用构造器链的代码
asp.net Repeater绑定时使用函数
asp.net下linkbutton的前后台使用方法
ASP.NET编程中经常用到的27个函数集
asp.net高效替换大容量字符实现代码
asp.net(c#) ubb处理类
ASP.NET中的跳转 200, 301, 302转向实现代码
C#中的委托和事件学习(续)
asp.net网站安全从小做起与防范小结
asp.net 网页编码自动识别代码
asp.net HttpWebRequest自动识别网页编码
asp.net中调用winrar实现压缩解压缩的代码
dz asp.net论坛中函数--根据Url获得源文件内容
.NET 扩展实现代码
用Jquery访问WebService并返回Json的代码
asp.net(c#)判断远程图片是否存在
asp.net保存远程图片的代码
Asp.Net类库中发送电子邮件的代码
ASP.NET表单验证方法详解

ASP.NET 中的 快速对图片进行滤光处理


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 182 ::
收藏到网摘: n/a


想快速地对指定图片或区域进行滤光处理,常见的方法取出图片数据,逐像素与指定滤光色进行AND运算,很麻烦。还见过网上流传的有用Point或GetPixel取点运算的,其低速可想而知。
其实利用BitBlt的位运算,可高速完成这种操作,下面这个函数比数组运算方法可快10倍,比Point或GetPixel估计会快上千倍。
Private Type RECT Left As Long Top As Long Right As Long Bottom As LongEnd TypePrivate Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As LongPrivate Declare Function CreateSolidBrush Lib "gdi32.dll" (ByVal crColor As Long) As LongPrivate Declare Function FillRect Lib "user32.dll" (ByVal hdc As Long, lpRect As RECT, ByVal hBrush As Long) As LongPrivate Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Public Sub FilterRGB(dHdc As Long, X As Long, y As Long, w As Long, h As Long, Optional tc As Long = &HFFFF00) Dim tmphdc As MemHdc, rc As RECT, hBrush As Long tmphdc = NewMyHdc(dHdc, w, h) '建立一个内存位图 rc.Right = w rc.Bottom = h hBrush = CreateSolidBrush(tc) FillRect tmphdc.hdc, rc, hBrush '用滤光色填充图片,产生一个纯色图片 DeleteObject hBrush BitBlt dHdc, X, y, w, h, tmphdc.hdc, 0, 0, vbSrcAnd '绘入目标,并与目标进行And运算,达到滤光效果 tmphdc = DelMyHdc(tmphdc)End Sub

本篇中的公用函数NewMyHdc、DelMyHdc及相关结构与API声明,可在以下文章中找到http://blog.csdn.net/homezj/archive/2005/04/14/348001.aspx