Thema: Delphi Alphablend bei Farben

Einzelnen Beitrag anzeigen

Benutzerbild von Neutral General
Neutral General

Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#9

Re: Alphablend bei Farben

  Alt 23. Feb 2007, 15:34
Zitat von SirThornberry:
Dann ist dein A nicht vom Type Byte
ups

Delphi-Quellcode:
const
  COLOR_GROUND = TColor($00004080);
  COLOR_GROUND_R = Byte(COLOR_GROUND);
  COLOR_GROUND_G = Byte(COLOR_GROUND shr 8);
  COLOR_GROUND_B = Byte(COLOR_GROUND shr 16);

function TTile.GetAlphaColorValue(Current,Max: Word): TColor;
var p: Single;
    r,g,b: Byte;
    i: Byte;
begin
  p:= Current / Max;
  p:= p*255;
  i:= round(p);

  r:= GetRValue(FBColor);
  g:= GetGValue(FBColor);
  b:= GetBValue(FBColor);

  RGB((i*R+(not i)*COLOR_GROUND_R) div 255,
      (i*G+(not i)*COLOR_GROUND_G) div 255,
      (i*B+(not i)*COLOR_GROUND_B) div 255);
end;
So. Das ist im Moment meine Function. Die funktioniert auch, ABER das muss schneller!

Weil:

Delphi-Quellcode:
procedure TForm1.PaintMap;
var x,y: Integer;
    P: PRGBTriple;
begin
    for y:= 0 to High(FMap) do
    begin
      P := FBitmap.ScanLine[y];
      for x:= 0 to High(FMap[y]) do
      begin
        P^.rgbtRed := GetRValue(FMap[y,x].Color); // Der Setter von Color ruft GetAlphaColorValue auf
        P^.rgbtGreen := GetGValue(FMap[y,x].Color);
        P^.rgbtBlue := GetBValue(FMap[y,x].Color);
        inc(P);
      end;
    end;
    Image1.Picture.Bitmap.Assign(FBitmap);
end;
Und wenn ich so ein 1024*768 Bild male dann dauert das (fast) ne halbe Sekunde.. aber ich will das Bild mindestens jede halbe Sekunde malen *g*. Wie kann man das ganze am besten optimieren?

Gruß
Neutral General
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."
  Mit Zitat antworten Zitat