function InvertBmp(SourceBitmap: TBitmap): TBitmap;
var
iFor, iFor2: LongInt;
TempBitmap: TBitmap;
bRed, bGreen, bBlue: Byte;
PixelColor: LongInt;
begin
TempBitmap := TBitmap.Create;
TempBitmap.Width := SourceBitmap.Width;
TempBitmap.Height := SourceBitmap.Height;
for iFor := 0 to SourceBitmap.Width -1 do
begin
for iFor2 := 0 to SourceBitmap.Height -1 do
begin
PixelColor := ColorToRGB(SourceBitmap.Canvas.Pixels[iFor, iFor2]);
bRed := PixelColor;
bGreen := PixelColor shr 8;
bBlue := PixelColor shr 16;
bRed := 255 -bRed;
bGreen := 255 -bGreen;
bBlue := 255 -bBlue;
TempBitmap.Canvas.Pixels[iFor, iFor2] := (bRed shl 8 +bGreen) shl 8 +bBlue;
end;
end;
Result := TempBitmap;
end;
Beispiel :
procedure TForm1.Button1Click(Sender: TObject);
begin
Image1.Picture.Bitmap.Assign(InvertBmp(Image1.Picture.Bitmap));
end;
Keine Kommentare:
Kommentar veröffentlichen