Gamma校正
提示:这里可以添加技术概要
核心源码
var
Form1: TForm1;
Bmp: TBitmap;
implementation
uses math;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
p: PByteArray;
x, y: Integer;
r, g, b: byte;
begin
for y := 0 to Bmp.Height - 1 do
begin
p := Bmp.scanline[y];
for x := 0 to Bmp.Width - 1 do
begin
b := p[x * 3];
g := p[x * 3 + 1];
r := p[x * 3 + 2];
p[x * 3 + 2] := Min(255, round(255 * Power((r / 256), 0.45)));
p[x * 3 + 1] := Min(255, round(255 * Power((g / 256), 0.45)));
p[x * 3] := Min(255, round(255 * Power((b / 256), 0.45)));
end
end;
Image2.Picture.Bitmap.assign(bmp);
end;<