Delphi 图像灰度化处理


本文整理自网络,侵删。

 
Type
pRGBTripleArray = ^TRGBTripleArray;
TRGBTripleArray = array [0 .. 65535] of TRGBTriple;
Ttemplate=record
end;

procedure TForm1.Button5Click(Sender: TObject);
var
   Gray,x,y:Integer;
   p:pRGBTripleArray;
   BM:TBitmap;
begin
  BM:=TBitmap.Create;
  BM.Assign(Image1.Picture.Graphic);
  Image1.Picture.Assign(BM);
  BM.free;

   for y:=1 to Image1.Picture.Height -1 do
   begin
   p:=Image1.Picture.Bitmap.ScanLine[Y];
   for x:=1 to Image1.Picture.Width-1 do
   begin
   //采用YUV与RGB颜色空间变换的公式,即Y=0.3R+0.59G+0.11B
   Gray:=Round(p[x].rgbtRed*0.3+p[x].rgbtGreen*0.59+p[x].rgbtBlue*0.11);
   p[x].rgbtRed :=Byte(Gray);
   p[x].rgbtGreen:=Byte(Gray);
   p[X].rgbtBlue :=Byte(Gray);
   end;
   end;
   Image1.Invalidate;

end;

相关阅读 >>

Delphi 比较两个位图是否相同

Delphi tnethttpclient上传文件

Delphi 程序窗体最大化、组件居中显示代码

Delphi android下拉刷新

Delphi net.httpclient正则批量获取网页代码中的数值

Delphi取得trichedit的光标当前位置

Delphi 去字符串长度函数 strlen,length

Delphi 按esc快捷键退出程序的简单方法

Delphi 分割字符串 extractstrings

Delphi 数组复制利用copymemory 最为完美

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...