long Gray;
BYTE *ptr;
Graphics::TBitmap *tmpBitmap = new Graphics::TBitmap;
tmpBitmap->Assign((TPersistent *)Image1->Picture->Graphic);
tmpBitmap->PixelFormat = pf24bit;
for (int y = 0; y < tmpBitmap->Height; y++)
{
ptr = (BYTE *)tmpBitmap->ScanLine[y];
for (int x = 0; x < tmpBitmap->Width *3; x+=3)
{
Gray = 299*ptr[x+2]+587*ptr[x+1]+114*ptr[x];
ptr[x]= Gray/1000;
ptr[x+1] = Gray/1000;
ptr[x+2] = Gray/1000;
}
Image1->Picture->Graphic = tmpBitmap;
//delete tmpBitmap;
BYTE *ptr;
Graphics::TBitmap *tmpBitmap = new Graphics::TBitmap;
tmpBitmap->Assign((TPersistent *)Image1->Picture->Graphic);
tmpBitmap->PixelFormat = pf24bit;
for (int y = 0; y < tmpBitmap->Height; y++)
{
ptr = (BYTE *)tmpBitmap->ScanLine[y];
for (int x = 0; x < tmpBitmap->Width *3; x+=3)
{
Gray = 299*ptr[x+2]+587*ptr[x+1]+114*ptr[x];
ptr[x]= Gray/1000;
ptr[x+1] = Gray/1000;
ptr[x+2] = Gray/1000;
}
Image1->Picture->Graphic = tmpBitmap;
//delete tmpBitmap;
解决方案 »
- 高分求2000年以前东南大学的毕业证书样本
- 关于分页显示问题
- 请大侠们看看这段代码,能告诉我问题在哪里吗?
- 关于DBEXPRESS的问题,怎么用DBEXPRESS调用ORACLE里的存储过程?在线等!!
- 我在MIDAS服务器里创建了方法,为什么远程不能访问
- 100分求思路
- 小弟想学学Delphi,请问初学用哪个版本的可以,没有一点编程基础可以嘛,到哪下载
- 我在Core Lab下载了ODAC3.6,听说只有30天的期限,
- 救命啊!TDateTimePicker的问题
- dbgrideh数据导出的问题
- 一个简单的问题:关于注册表&系统2K
- 提问:怎样在TStringgrid的某个单元格中画一个位图或者一个图标!
var bmp:TBitmap;Ptr:PByteArray;x,y:integer;gray:integer;
begin
bmp:=tbitmap.Create;
bmp.Assign(image1.Picture.Graphic);
bmp.PixelFormat:=pf24bit;
for y:=0 to bmp.Height-1 do
begin
ptr:=bmp.ScanLine[y];
x:=0;
while x<bmp.Width-1 do
begin
Gray:=299*ptr[x+2]+587*ptr[x+1]+114*ptr[x];
ptr[x]:=Gray div 1000;
ptr[x+1]:=Gray div 1000;
ptr[x+2]:=Gray div 1000;
x:=x+3;;
end;
end;
image2.Picture.Assign(bmp);
bmp.Free
end;