...
unit Winapi.Windows;
...
function Clamp(Value: Integer; Min, Max: Integer): Byte;
inline;
begin
Result := Value;
if Result < Min
then
Result := Min;
if Result > Max
then
Result := Max;
end;
procedure AdjustLuminance(Bmp: TBitmap; Offset: SmallInt);
var
// Bmp: TBitmap;
Pixel: PRGBQuad;
X, Y: Integer;
begin
Bmp.PixelFormat := pf32Bit;
for Y := ClientRect.Top
to ClientRect.Bottom
do
begin
// Pointer auf 1. Pixel in der Zeile holen
Pixel := Bmp.Scanline[Y];
System.Inc(Pixel, ClientRect.Left);
for X := ClientRect.Left
to ClientRect.Right
do
begin
Pixel^.rgbRed := Clamp(Pixel^.rgbRed + Offset, 0, 255);
Pixel^.rgbGreen := Clamp(Pixel^.rgbGreen + Offset, 0, 255);
Pixel^.rgbBlue := Clamp(Pixel^.rgbBlue + Offset, 0, 255);
// ein Pixel nach rechts gehen
System.Inc(Pixel);
end;
end;
end;
procedure UnderMouseEffect;
var
tmpBitmap: TBitmap;
begin
tmpBitmap := TBitmap.Create;
tmpBitmap.Width := ClientRect.Width;
tmpBitmap.Height := ClientRect.Height;
tmpBitmap.Canvas.Brush.Style := bsDiagCross;
tmpBitmap.Canvas.Brush.Color := clWhite;
tmpBitmap.Canvas.FillRect(TRect.Create(0, 0, tmpBitmap.Width,
tmpBitmap.Height));
// tmpBitmap.SaveToFile('xxx.bmp');
DrawTransparentBitmap(tmpBitmap, aBitmap.Canvas, ClientRect, $07);
// aBitmap.Canvas.Brush.Color := clYellow;
// aBitmap.Canvas.FillRect(aRect);
// SetStretchBltMode(aBitmap.Canvas.Handle, COLORONCOLOR);
// StretchBlt(aBitmap.Canvas.Handle, ClientRect.Left, ClientRect.Top,
// ClientRect.Width, ClientRect.Height, tmpBitmap.Canvas.Handle, 0, 0,
// tmpBitmap.Width, tmpBitmap.Height, SRCCOPY);
// aBitmap.Canvas.CopyMode := cmWhiteness;
// aBitmap.Canvas.CopyRect(ClientRect, tmpBitmap.Canvas,
// tmpBitmap.Canvas.ClipRect);
tmpBitmap.Free;
end;
procedure MouseDownEffect;
var
tmpBitmap: TBitmap;
begin
tmpBitmap := TBitmap.Create;
tmpBitmap.Width := ClientRect.Width;
tmpBitmap.Height := ClientRect.Height;
tmpBitmap.Canvas.Brush.Style := bsDiagCross;
tmpBitmap.Canvas.Brush.Color := clWhite;
tmpBitmap.Canvas.FillRect(TRect.Create(0, 0, tmpBitmap.Width,
tmpBitmap.Height));
// tmpBitmap.SaveToFile('xxx.bmp');
DrawTransparentBitmap(tmpBitmap, aBitmap.Canvas, ClientRect, $10);
// aBitmap.Canvas.Brush.Color := clYellow;
// aBitmap.Canvas.FillRect(aRect);
// SetStretchBltMode(aBitmap.Canvas.Handle, COLORONCOLOR);
// StretchBlt(aBitmap.Canvas.Handle, ClientRect.Left, ClientRect.Top,
// ClientRect.Width, ClientRect.Height, tmpBitmap.Canvas.Handle, 0, 0,
// tmpBitmap.Width, tmpBitmap.Height, SRCCOPY);
// aBitmap.Canvas.CopyMode := cmWhiteness;
// aBitmap.Canvas.CopyRect(ClientRect, tmpBitmap.Canvas,
// tmpBitmap.Canvas.ClipRect);
tmpBitmap.Free;
end;
procedure UnderMouseEffectLumi;
begin
AdjustLuminance(aBitmap, -2);
// Abdunkeln
end;
procedure MouseDownEffectLumi;
begin
AdjustLuminance(aBitmap, -5);
// Abdunkeln
end;