Einzelnen Beitrag anzeigen

Delphi.Narium

Registriert seit: 27. Nov 2017
2.415 Beiträge
 
Delphi 7 Professional
 
#2

AW: Farbtabelle eines TBitmap bearbeiten?

  Alt 16. Jun 2020, 15:02
Eventuell mal hier schauen: https://www.delphipraxis.net/10914-b...umwandeln.html

Die Palette in Bitmaps gilt (soweit ich mich erinnere) nur für 256-Farben-Bitmaps. (http://www.libertybasicuniversity.co...100/format.htm)

Keine Ahnung, ob dashier entsprechend Deinen Wünschen funktionieren könnte (irgendwo aus meinem Fundus):
Delphi-Quellcode:
procedure BitmapGrayscale(ABitmap: Graphics.TBitmap);
type
  PPixelRec = ^TPixelRec;
  TPixelRec = packed record
    B : Byte;
    G : Byte;
    R : Byte;
  end;

var
  X : Integer;
  Y : Integer;
  Gray : Byte;
  Pixel : PPixelRec;
begin
  for Y := 0 to ABitmap.Height - 1 do begin
    Pixel := ABitmap.ScanLine[Y];
    for X := 0 to ABitmap.Width - 1 do begin
      Gray := Round((0.299 * Pixel.R) + (0.587 * Pixel.G) + (0.114 * Pixel.B));
      Pixel.R := Gray;
      Pixel.G := Gray;
      Pixel.B := Gray;
      Inc(Pixel);
    end;
  end;
end;
Oder bei der "Konkurenz": https://www.swissdelphicenter.ch/en/showcode.php?id=437
  Mit Zitat antworten Zitat