Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   Delphi Pixelmanipulation (https://www.delphipraxis.net/30125-pixelmanipulation.html)

Phantom1 18. Sep 2005 08:44

Re: Pixelmanipulation
 
Zitat:

Zitat von Gothicware
Delphi-Quellcode:
procedure _SemiOpaque(src:Tbitmap; Color:TColor);
var x,y:Integer;
    p:PInteger;
begin
  src.PixelFormat:=pf32bit;
  p:= src.Scanline[Pred(src.Height)];
  for y:=1 to src.Height do
  for x:=1 to src.Width do
    begin
      if ((x+0 mod 2) = 0) and ((y mod 2) = 0) then p^:= Color;
      if ((x+1 mod 2) = 0) and ((y mod 2) <> 0) then p^:= Color;
      Inc(p);
    end;
end;

Du weißt aber schon das die Bedingung (x+0 mod 2)=0 immer False ergibt, wenn x>0? Denn das Mod bindet mehr als das + zeichen.

Hier mal eine Variante von mir, ist dank Scanline auch recht schnell:
Delphi-Quellcode:
// Alpha 127 ist Halbtransparent
procedure TAnimation.DrawAlpha(Src, Dest: TBitmap; x, y: Integer; Alpha: Byte);
var
  s, d: PRGBQuad;
  Rect: TRect;
  x1, y1: Integer;
begin
  src.PixelFormat:=pf32bit;
  dest.PixelFormat:=pf32bit;
  if (x>=Dest.Width) or (x+Pred(Src.Width)<0) or
     (y>=Dest.Height) or (y+Pred(Src.Height)<0) then exit;
  with Rect do begin
    Left:=Max(x, 0);
    Top:=Max(y, 0);
    Right:=Min(x+Pred(Src.Width), Pred(Dest.Width));
    Bottom:=Min(y+Pred(Src.Height), Pred(Dest.Height));
  end;
  for y1:=Rect.Top to Rect.Bottom do begin
    d:=Dest.ScanLine[y1]; Inc(d, Rect.Left);
    s:=Src.ScanLine[y1-y]; Inc(s, Rect.Left-x);
    for x1:=Rect.Left to Rect.Right do begin
      d^.rgbRed:=(d^.rgbRed * Alpha + s^.rgbRed * not Alpha) shr 8;
      d^.rgbGreen:=(d^.rgbGreen * Alpha + s^.rgbGreen * not Alpha) shr 8;
      d^.rgbBlue:=(d^.rgbBlue * Alpha + s^.rgbBlue * not Alpha) shr 8;
      Inc(s);
      Inc(d);
    end;
  end;
end;

Gothicware 18. Sep 2005 15:30

Re: Pixelmanipulation
 
Danke, ist mir noch nicht aufgefallen, denn bei mir hats 100% unter Delphi 4 funktioniert.
Aber nach dem leitsatz vergangener Tage(schon ein paar Jahre her),
Punktrechnung geht vor Strichrechnung, sei den eine Klammer sagt was anderes.
sollte ich's ändern.

Wenn du noch mehr zum Thema Pixelmanipulation hast, würde ich mich freun was für meine GW_ImagePlus Unit zubekommen.
(Per PM bitte, danke.)

SirThornberry 18. Sep 2005 15:33

Re: Pixelmanipulation
 
oh, wenn ich das hier alles lese graut es mir. Für sowas gibt es doch die Funktion Alphablend in der unit Windows.

Gothicware 18. Sep 2005 20:23

Re: Pixelmanipulation
 
Meins war ja auch nur gedacht da @fkerber immer Abwechselnd ein Pixel von zwei Bildern nimmt. Was grade bei niedriger Farbauflösung die Bessere Methode sein kann. Ausserdem hat man bei der API keine 100% Gewalt darüber was gemacht wird. Aber AlphaBlend ist sicherlich die einfachere Lösung.


Alle Zeitangaben in WEZ +1. Es ist jetzt 06:21 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz