Einzelnen Beitrag anzeigen

Benutzerbild von DGL-luke
DGL-luke

Registriert seit: 1. Apr 2005
Ort: Bad Tölz
4.149 Beiträge
 
Delphi 2006 Professional
 
#2

Re: Bild: Umwandlung in Blaustufen (nicht Graustufen)

  Alt 2. Mai 2007, 13:28
Hallo, das ist ganz einfach:

Delphi-Quellcode:
for X := 0 to Image.Width - 1 do
  for Y := 0 to Image.Height - 1 do
  begin
    PxlColor := ColorToRGB((Image as TBitmap).Canvas.Pixels[X, Y]);
    C := Round((((PxlColor shr 16) + ((PxlColor shr 8) and $00FF) + (PxlColor and $0000FF)) div 3)) div 2 + 96;
   (Image as TBitmap).Canvas.Pixels[X, Y] := RGB(0, 0, C); //da spielt die musik
  end;
Ich würd das ganze aber mit Scanline machen:

Delphi-Quellcode:
var
  lineptr: PColor;

lineptr := (Image as TBitmap).ScanLine[0]; //erstes bildpixel
for Y := 0 to Image.Height - 1 do
begin
  for X := 0 to Image.Width - 1 do
  begin
    PxlColor := ColorToRGB(TColor(lineptr^));
    C := Round((((PxlColor shr 16) + ((PxlColor shr 8) and $00FF) + (PxlColor and $0000FF)) div 3)) div 2 + 96;
    lineptr^ := RGB(0, 0, C); //da spielt die musik
    Inc(lineptr); //nächstes bildpixel
  end;
end;
Ich hoffe das funktioniert so, hab das ausm Gedächtnics getippt, eventuell muss man da noch ein bisschen rumcasten.
Lukas Erlacher
Suche Grafiktablett. Spenden/Gebrauchtangebote willkommen.
Gotteskrieger gesucht!
For it is the chief characteristic of the religion of science that it works. - Isaac Asimov, Foundation I, Buch 1
  Mit Zitat antworten Zitat