一个将图像的某个区域之外的区域变暗的函数
2009-11-26 13:40
453 查看
过程名: DarkBmp
作者: 不得闲
日期: 2009.02.04
参数: bmp: TBitmap;var DarkRect: TRect;const DarkValue: Integer;const HighValue: Integer = 0
DarkRect指定不变暗的区域
DarkValue: 指定暗化的数量值
HighValue: 指定矩形区域增亮化的数量值
功能: 将图像的某个区域之外的区域变暗的函数
返回值: 无
作者: 不得闲
日期: 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]<DarkValue 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]<DarkValue 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]<DarkValue 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]<DarkValue 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语言编写的一个删除二值图像中不连通小区域的函数
- 统计函数耗费时间,简单的图像运算,定义感兴趣区域 第二章
- TensorFlow从图像提取区域的函数
- bmp格式图像的读写函数(对一个开源代码的封装)
- 一张图像表示成NxN的矩阵,图像中每个像素是4个字节,写一个函数把图像旋转90度。 你能原地进行操作吗?(即不开辟额外的存储空间)
- wpf 透明效果 需要DwmApi.dll文件,然后定义一个函数去画Aero区域,从而实现整个窗口的Aero化。
- 在matlab图像处理中太有用了,regionprops用来度量图像区域属性的函数。
- bmp格式图像的读写函数(对一个开源代码的封装)
- 创建带有可供点击区域的图像地图。其中的每个区域都是一个超级链接
- OpenCV_复制一个或多个ROI图像区域
- 采用微分方程几何解法画函数图像(一个修正)
- MATLAB一个figure中显示多幅图像,并缩小空白区域
- 【一天一个canvas】图像切割函数clip(十三)
- 使用Matlab中regionprops函数获取图像连通区域
- 使用floodfill()函数颜色填充一个联通的区域
- bmp格式图像的读写函数(对一个开源代码的封装)
- 一个图像目标区域提取的问题
- 怎么使点击一个popupwindow窗口之外的区域popupwindow消失呢?
- 怎么使点击一个popupwindow窗口之外的区域popupwindow消失呢?