Z
zrj
Unregistered / Unconfirmed
GUEST, unregistred user!
{-----------------------------------------------------------------------------
过程名称 :TBitmapProcess.Convert8BitBmpToGrayBmp
作者 :
日期 :09-五月-2003
参数描述 :None
返回值 :Boolean
函数功能 :转化256色图为灰度图;
-----------------------------------------------------------------------------}
function TBitmapProcess.Convert8BitBmpToGrayBmp: Boolean;
var
pal: array[0..255] of TPaletteEntry;
bMap : array[0..255] of Byte;
Rvalue, Gvalue, Bvalue: byte;
Gray: Double; //灰度
SourceBmp: TBitmap;
i, j :integer;
P ByteArray;
begin
Result := False;
SourceBmp := Self.FCurbmp;
GetPaletteEntries(SourceBmp.Palette, 0, 256, pal);
for j:= 0 to 255 do
begin
Rvalue := Pal[j].peRed;
Gvalue := pal[j].peGreen;
Bvalue := pal[j].peBlue;
Gray := 0.299 * Rvalue + 0.587 * Gvalue + 0.114 * Bvalue;
bMap[j]:= Round(Gray);
Pal[j].peRed := j;
Pal[j].peGreen := j;
Pal[j].peBlue := j;
end;
for i := 0 to Self.FBitmapHeight - 1 do
begin
p := SourceBmp.ScanLine;
for j := 0 to Self.FBitmapWidth - 1 do
begin
P[j] := bMap[P[j]];
end;
end;
SetPaletteEntries(SourceBmp.Palette, 0, 256, pal);
Result := True;
end;
调用得过程如下;
begin
。。。
BitmapProcess.Convert8BitBmpToGrayBmp;
Self.Image1.Picture.Bitmap := BitmapProcess.Curbmp;
end;
转化结果不正确,至少显示不正确,我应该如何处理,修改系统调色板,或者是文件头?
请高手帮忙看看!
我看论坛都是24位图得例子,我是256色图,各位看看,这个问题困扰我很久了,谢谢!
过程名称 :TBitmapProcess.Convert8BitBmpToGrayBmp
作者 :
日期 :09-五月-2003
参数描述 :None
返回值 :Boolean
函数功能 :转化256色图为灰度图;
-----------------------------------------------------------------------------}
function TBitmapProcess.Convert8BitBmpToGrayBmp: Boolean;
var
pal: array[0..255] of TPaletteEntry;
bMap : array[0..255] of Byte;
Rvalue, Gvalue, Bvalue: byte;
Gray: Double; //灰度
SourceBmp: TBitmap;
i, j :integer;
P ByteArray;
begin
Result := False;
SourceBmp := Self.FCurbmp;
GetPaletteEntries(SourceBmp.Palette, 0, 256, pal);
for j:= 0 to 255 do
begin
Rvalue := Pal[j].peRed;
Gvalue := pal[j].peGreen;
Bvalue := pal[j].peBlue;
Gray := 0.299 * Rvalue + 0.587 * Gvalue + 0.114 * Bvalue;
bMap[j]:= Round(Gray);
Pal[j].peRed := j;
Pal[j].peGreen := j;
Pal[j].peBlue := j;
end;
for i := 0 to Self.FBitmapHeight - 1 do
begin
p := SourceBmp.ScanLine;
for j := 0 to Self.FBitmapWidth - 1 do
begin
P[j] := bMap[P[j]];
end;
end;
SetPaletteEntries(SourceBmp.Palette, 0, 256, pal);
Result := True;
end;
调用得过程如下;
begin
。。。
BitmapProcess.Convert8BitBmpToGrayBmp;
Self.Image1.Picture.Bitmap := BitmapProcess.Curbmp;
end;
转化结果不正确,至少显示不正确,我应该如何处理,修改系统调色板,或者是文件头?
请高手帮忙看看!
我看论坛都是24位图得例子,我是256色图,各位看看,这个问题困扰我很久了,谢谢!