刚刚写的一个将图像的某个区域之外的区域变暗的函数
2009-02-04 17:28
381 查看
{------------------------------------------------------------------------------- 过程名: DarkBmp 作者: 不得闲 日期: 2009.02.04 参数: bmp: TBitmap;var DarkRect: TRect;const DarkValue: Integer;const HighValue: Integer = 0 DarkRect指定不变暗的区域 DarkValue: 指定暗化的数量值 HighValue: 指定矩形区域增亮化的数量值 功能: 将图像的某个区域之外的区域变暗的函数 返回值: 无 -------------------------------------------------------------------------------} procedure DarkBmp(bmp: TBitmap;var DarkRect: TRect;const DarkValue: Integer;const HighValue: Integer = 0); var i,j : integer; pB : PByteArray; BmpFormatXs: Integer; w,h:Integer; begin i := Integer(bmp.PixelFormat); if i < 4 then i := 4 else if i = 4 then inc(i) else if i > 7 then i := 7; BmpFormatXs := i - 3; w:= DarkRect.Right - DarkRect.Left; h:= DarkRect.Bottom - DarkRect.Top; if DarkRect.Right > bmp.Width then begin DarkRect.Left:=bmp.Width - w; DarkRect.Right:=bmp.Width; end; if (DarkRect.Bottom > bmp.Height) then begin DarkRect.Top:= bmp.Height - h; DarkRect.Bottom:=bmp.Height; end; if DarkRect.Left <0 then begin DarkRect.Left:=0; DarkRect.Right:=w; end; if DarkRect.Top <0 then begin DarkRect.Top:=0; DarkRect.Bottom:=h; end; for i := 0 to DarkRect.Top - 1 do begin pb:=bmp.ScanLine[i]; for j:=0 to BmpFormatXs*bmp.Width - 1 do if pb[j]then pb[j]:=0 else dec(pb[j],DarkValue); end; for i := DarkRect.Top to bmp.Height - 1 do begin pb:=bmp.ScanLine[i]; for j:=0 to BmpFormatXs*DarkRect.Left - 1 do if pb[j]then pb[j]:=0 else dec(pb[j],DarkValue); end; for i := DarkRect.Bottom to bmp.Height - 1 do begin pb:=bmp.ScanLine[i]; for j:= BmpFormatXs*DarkRect.Left to BmpFormatXs*bmp.Width - 1 do if pb[j]then pb[j]:=0 else dec(pb[j],DarkValue); end; for i := DarkRect.Top to DarkRect.Bottom - 1 do begin pb:=bmp.ScanLine[i]; for j:= BmpFormatXs*DarkRect.Right to BmpFormatXs*bmp.Width - 1 do if pb[j]then pb[j]:=0 else dec(pb[j],DarkValue) end; if HighValue <> 0 then for i := DarkRect.Top to DarkRect.Bottom - 1 do begin pb:=bmp.ScanLine[i]; for j:= BmpFormatXs*DarkRect.Left to BmpFormatXs*DarkRect.Right - 1 do if pb[j]>(255-DarkValue) then pb[j]:=255 else inc(pb[j],HighValue); end; end; 使用方法: procedure TForm1.Button1Click(Sender: TObject); var bmp: TBitmap; r: TRect; begin bmp := TBitmap.Create; bmp.Assign(Image1.Picture.Bitmap); r := Rect(0,0,50,50); DarkBmp(bmp,r,40,10); Image2.Picture.Bitmap := bmp; end; |
相关文章推荐
- 一个将图像的某个区域之外的区域变暗的函数
- C语言编写的一个删除二值图像中不连通小区域的函数
- MATLAB一个figure中显示多幅图像,并缩小空白区域
- 如何在opencv对图像中一个区域涂色呢?
- bmp格式图像的读写函数(对一个开源代码的封装)
- 【OpenCV学习笔记】【编程实例】三(将一个图像中的指定区域拷贝到另一个图像的指定区域
- 一个非常好用的数学函数图像生成工具
- 线性混合实现函数 指定区域线性图像混合 addWeighted函数 感兴趣区域RO 实现自定义区域的线性混合
- 刚刚接触到一个STL的函数make_pair()
- 目标检测之显著区域检测---国外的一个图像显著区域检测代码及其效果图 saliency region detection
- 国外的一个图像显著区域检测代码及其效果图 saliency region detection
- 如何将图片中的一个任意四边形区域的图像转化为矩形【附源码】
- ch4_3_5利用radon函数和iradon函数构造一个简单图像的投影并重建图像.m
- 采用微分方程几何解法画函数图像(一个修正)
- 一张图像表示成NxN的矩阵,图像中每个像素是4个字节,写一个函数把图像旋转90度。 你能原地进行操作吗?(即不开辟额外的存储空间)
- matlab用来度量图像区域属性的函数——regionprops
- 刚刚在看52单片机和GPS通信程序的时候,看到了一个函数,absacc.h,貌似从来没有遇到过,百度了一下,结合自己的理解,整理如下: http://blog.sina.com.cn/s/blog_4
- 请教一个EasyTouch的问题,如何实现摇杆和之外的触模区域独立
- 【一天一个canvas】图像切割函数clip(十三)
- wpf 透明效果 需要DwmApi.dll文件,然后定义一个函数去画Aero区域,从而实现整个窗口的Aero化。