孤独的猫

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

procedure GrayToColor(Bmp:TBitmap);

var

i,j,uG:integer;

begin

Bmp.PixelFormat:=pf24Bit;

for j:=0 to Bmp.Height-1 do

begin

p:=Bmp.Scanline[j];

for i:=0 to Bmp.Width-1 do

begin

uG:=p[3*i];

if (0<uG) and (uG<63) then

begin

p[3*i+2]:=0;

p[3*i+1]:=254-4*uG;

p[3*i]:=255;

end;

if (64<=uG) and (uG<127) then

begin

p[3*i+2]:=0;

p[3*i+1]:=4*uG-254;

p[3*i]:=510-4*uG;

end;

if (128<=uG) and (uG<191) then

begin

p[3*i+2]:=4*uG-510;

p[3*i+1]:=255;

p[3*i]:=0;

end;

if (192<=uG) and (uG<=255) then

begin

p[3*i+2]:=255;

p[3*i+1]:=1022-4*uG;

p[3*i]:=0;

end;

end;

end;

end;

posted on 2008-09-10 17:47  孤独的猫  阅读(462)  评论(0编辑  收藏  举报