Autor Beitrag
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 11.11.10 09:28 
Hallo,

ich benutze für die Anzeige einer Animation die AlphaBlend Funktion aus der API. Das funktioniert auch gut, nur leider ist der Hintergrund der temporären Bitmap zu sehen, wenn ich überblende.

Die transparente Farbe der Bitmap wird dabei leider nicht benutzt. Ich vermute diese muss ich manuell mit einem Alphawert versehen. Bevor ich da aber wild herumprobiere (vor allem sind laut Doku viele der Alpha-Möglichkeiten noch gar nicht implementiert) frage ich dann doch einmal lieber nach:
Wie mache ich das am besten?

Kleiner Codeschnippsel:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
var
  AnimationTemp: TBitmap;
  Blend: TBlendFunction;
begin
  AnimationTemp := TBitmap.Create;
  try
    AnimationTemp.SetSize(5050);
    AnimationTemp.Canvas.Ellipse(551010);
//    AnimationTemp.Transparent := True;
//    AnimationTemp.TransparentColor := clWhite;
//    AnimationTemp.TransparentMode := tmAuto;
    Blend.BlendOp := AC_SRC_OVER;
    Blend.BlendFlags := 0;
    Blend.SourceConstantAlpha := 100;
    Blend.AlphaFormat := 0// hier gibt es auch AC_SRC_ALPHA, aber dann kommt nichts mehr an
    AlphaBlend(TargetCanvas.Handle, 1001005050,
      AnimationTemp.Canvas.Handle, 005050, Blend);
  finally
    AnimationTemp.Free;
  end;
Man sieht auf einem dunklen Hintergrund deutlich ein weißes (Brush.Color eben) halbtransparentes Rechteck um die Zeichnung herum. Und dieses möchte ich ausblenden.

Vielen Dank schonmal,
schönen Gruß,
Sebastian
turboPASCAL
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 193
Erhaltene Danke: 1

Win XP / Vischda
D6 PE / D2005 PE
BeitragVerfasst: Do 11.11.10 17:28 
Hi,

Zitat:
Ich vermute diese muss ich manuell mit einem Alphawert versehen.

Ja.

Arbeitest du mit TBitmap(s) oder TBitmap32 aus der GR32-Units ?
Dann sollte es einfacher gehen den Alphachannel zu setzen.

_________________
Nein, ich bin nicht der turboPASCAL aus der DP, ich seh nur so aus... :P
jaenicke Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 11.11.10 17:39 
Ich benutze derzeit normale TBitmaps und mir wäre es auch am liebsten, wenn es dabei bliebe.

Da die GR32 unter der MPL nutzbar ist, kann ich aber auch die benutzen, wenn es damit geht. Ich habe mich nur noch nicht damit beschäftigt wie das mit dem Alphachannel funktioniert.

Vorstellen tue ich es mir so, dass ich mit Scanline durchgehe und den Alphawert (bei pf32Bit dann wahrscheinlich das vierte Byte) auf voll transparent setze, wenn ich die Hintergrundfarbe finde.
bummi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1248
Erhaltene Danke: 187

XP - Server 2008R2
D2 - Delphi XE
BeitragVerfasst: Do 11.11.10 18:35 
Du musst zusätzlich die RGB Bytes Anteilig zum Alphawert reduzieren, frag mich nicht warum das so ist....

_________________
Das Problem liegt üblicherweise zwischen den Ohren H₂♂
DRY DRY KISS
jaenicke Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 11.11.10 18:50 
Ich habe in der Doku schon eine entsprechende Tabelle gesehen, aber irgendwie kommt da nix Sinnvolles raus bei mir. :gruebel:

Naja, ich schau zu Hause weiter.
bummi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1248
Erhaltene Danke: 187

XP - Server 2008R2
D2 - Delphi XE
BeitragVerfasst: Do 11.11.10 18:54 
Ich kann Dir GDI+ ans Herz legen, keine Installation, 3 units in den Pfad nehmen und alles geht wunderbar.
www.progdigy.com/

_________________
Das Problem liegt üblicherweise zwischen den Ohren H₂♂
DRY DRY KISS
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Do 11.11.10 19:00 
user profile iconbummi hat folgendes geschrieben Zum zitierten Posting springen:
Du musst zusätzlich die RGB Bytes Anteilig zum Alphawert reduzieren, frag mich nicht warum das so ist....

msdn.microsoft.com/e...3393%28VS.85%29.aspx

Steht doch alles da?

Ich hab die in meinem Coverflow verwendet, (allerdings nicht Per-Pixel). Die Funktion kann wesentlich mehr als dokumentiert ist, muss mal was zum Testen zusammenbauen.

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
bummi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1248
Erhaltene Danke: 187

XP - Server 2008R2
D2 - Delphi XE
BeitragVerfasst: Do 11.11.10 19:08 
@Martok

ich meinte warum dies so zu sein hat, eigentlich sollte der Alphakanal als Informationsträger eigentlich ausreichen.

_________________
Das Problem liegt üblicherweise zwischen den Ohren H₂♂
DRY DRY KISS
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Do 11.11.10 19:28 
Das war auch eher an user profile iconjaenicke mit dir als Quelle ;)

Beispielprogramm mit kommentiertem Source+Exe im Anhang...
Einloggen, um Attachments anzusehen!
_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."

Für diesen Beitrag haben gedankt: BenBE, Dude566, jaenicke
jaenicke Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 11.11.10 21:46 
Super, vielen Dank, jetzt funktioniert es auch bei mir wunderbar. ;-)

Kaum macht man es richtig funktioniert es. :mrgreen:
Dude566
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1592
Erhaltene Danke: 79

W8, W7 (Chrome, FF, IE)
Delphi XE2 Pro, Eclipse Juno, VS2012
BeitragVerfasst: Do 11.11.10 22:00 
user profile iconMartok hat folgendes geschrieben Zum zitierten Posting springen:

Beispielprogramm mit kommentiertem Source+Exe im Anhang...


Danke, habe zwar noch keine Ahnung wie und ob ich das jemals verwenden kann, aber was neues zum Lernen.

_________________
Es gibt 10 Gruppen von Menschen: diejenigen, die das Binärsystem verstehen, und die anderen.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Fr 12.11.10 02:57 
@Martok: Irgendwas stimmt bei Dir in dem Programm noch nicht:

AlphaBlend
Einloggen, um Attachments anzusehen!
_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Fr 12.11.10 03:21 
Ach hör auf zu Winen :lol:

Wieder typisch dieses Linuxfrickelkram. Mit dem Weltmarktführer wäre das nicht passiert 8)

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
jaenicke Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Fr 12.11.10 06:31 
user profile iconBenBE hat folgendes geschrieben Zum zitierten Posting springen:
@Martok: Irgendwas stimmt bei Dir in dem Programm noch nicht:
Na, dann kannst du dich ja direkt mal an die Wine/Linux Sourcen machen. Denn das Programm macht hier alles richtig, unter Windows läuft es ja. ;-)

// EDIT:
Wobei, mal nen Auszug aus deinem Systemlog: "Grafischer Windows-Klickibunti-Kram entdeckt, ignoriere..." :mrgreen: