亮度调整主要是R.G.B各分量的调整,同时增加(减小)相同的幅度,注意不要越界!
一个例子用scanilne实现!
procedure TMainForm.AddbrightClick(Sender: TObject);
var
p: PByteArray;
x, y: Integer;
Bmp: TBitmap;
begin
Bmp := TBitmap.Create;
Bmp.Assign(ChildForm.Image1.Picture.Bitmap);
Bmp.PixelFormat := pf24Bit;
ChildForm.DoubleBuffered := True;
for y := 0 to Bmp.Height - 1 do
begin
p := Bmp.scanline[y];
for x := 0 to (Bmp.Width - 1) do
begin
if (p[x * 3] < 245) and (p[x * 3 + 1] < 245) and (p[x * 3 + 2] <
245) then
begin
p[x * 3] := p[x * 3] + 10;
// R,G,B element increase the same number
p[x * 3 + 1] := p[x * 3 + 1] + 10;
p[x * 3 + 2] := p[x * 3 + 2] + 10;
end;
end;
end;
ChildForm.Image1.Picture.Bitmap.Assign(Bmp);
bmp.free;
end;
end;