![]() |
Re: Simple Grafikfunktionen
Also ich habe folgende verwendet von Wikipedia:
C = αA + (1 − α)B Die funzt auch eigentlich gut, muss das nur noch etwas optimieren, denke ich poste n Screenie wenn ichs richtig hinbekommen habe ;-) |
Re: Simple Grafikfunktionen
Das ist genau die, die ich auch verwende, nur dass ich das Alpha (nach außen) auf ein byte, also auf 0..255 anstatt auf 0..1 abbilde.
|
Re: Simple Grafikfunktionen
Ja, wusste ich :D
Ok, das hab ich etwas verplant ^^ |
Re: Simple Grafikfunktionen
Also, ich habe mir jetzt eine Funktion zusammengebastelt, aber es funzt irgendwie net richtig!
Delphi-Quellcode:
Also erstmal is das Problem, dass die Prozedur ziemlicih langsam ist...kann man sie irgendwie beschleunigen? Also ich kann ja nicht mit Rectangle zeichnen, weil ich ja immer die PixelFarbe herausbekommen muss!
function GetBlendedColor(Color1, Color2: TColor; Alpha: Integer): TColor;
var r1, g1, b1, r2, g2, b2, r, g, b: Integer; begin r1 := GetRValue(Color1); g1 := GetGValue(Color1); b1 := GetBValue(Color1); r2 := GetRValue(Color2); g2 := GetGValue(Color2); b2 := GetBValue(Color2); r := Alpha * r1 + (1 - Alpha) * r2; g := Alpha * g1 + (1 - Alpha) * g2; b := Alpha * b1 + (1 - Alpha) * b2; Result := RGB(r, g, b); end; procedure InnerGlow(Color: TColor; Size, Alpha: Integer; Rect: TRect; Canvas: TCanvas); var CurAlpha: Extended; CurAlphaRounded, i, x, y: Integer; PixelColor: TColor; begin CurAlpha := 0; for i := 1 to Size do begin CurAlpha := Alpha / Size * i; CurAlphaRounded := Round(CurAlpha); for x := Rect.Left + i - 1 to Rect.Right - i + 1 do begin y := Rect.Top + i - 1; PixelColor := GetPixel(Canvas.Handle, x, y); Canvas.Pixels[x, y] := GetBlendedColor(Color, PixelColor, CurAlphaRounded); y := Rect.Bottom - i + 1; PixelColor := GetPixel(Canvas.Handle, x, y); Canvas.Pixels[x, y] := GetBlendedColor(Color, PixelColor, CurAlphaRounded); end; for y := Rect.Top + i to Rect.Bottom - i do begin x := Rect.Top + i - 1; PixelColor := GetPixel(Canvas.Handle, x, y); Canvas.Pixels[x, y] := GetBlendedColor(Color, PixelColor, CurAlphaRounded); x := Rect.Bottom - i + 1; PixelColor := GetPixel(Canvas.Handle, x, y); Canvas.Pixels[x, y] := GetBlendedColor(Color, PixelColor, CurAlphaRounded); end; end; end; Außerdem funktioniert das alles auch irgendwie noch nicht so richtig! Wenn die Fläche Quadratisch is gehts, sonst malt er das einfach nicht richtig!!! Wisst ihr woran das liegen koennte? `Danke soweit schonmal! |
Re: Simple Grafikfunktionen
Hallo,
anstatt mit GetPixels würd ich mit Scanline arbeiten. Oder gleich mit GDI+. |
Re: Simple Grafikfunktionen
Ok, danke da informier ich mich dann morgen drüber, weil das is mir heute zu spät ;-)
Danke für die Hilfe :) |
Alle Zeitangaben in WEZ +1. Es ist jetzt 20:13 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz