既然楼上的方法你不满意,给你个函数试试!其实你要是想要256最好的效果,还是用JPEG吧!
function CreateGreyScaleBmp(Source: TBitmap): TBitmap;
var
Table: array[Byte] of TRGBQuad;
I: Integer;
begin
Result := TBitmap.Create;
with Result do
begin
PixelFormat := pf8Bit;
Width := Source.Width;
Height := Source.Height;
for I := Low(Table) to High(Table) do
with Table do
begin
rgbRed := I;
rgbGreen := I;
rgbBlue := I;
rgbReserved := 0;
end;
if SetDIBColorTable(Canvas.Handle, Low(Table), High(Table), Table) = 0 then
RaiseLastWin32Error;
Canvas.Draw(0, 0, Source);
end;
end;