Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   Delphi [DelphiX] Zeichnen mit Transparenz (https://www.delphipraxis.net/73212-%5Bdelphix%5D-zeichnen-mit-transparenz.html)

3_of_8 13. Jul 2006 18:07


[DelphiX] Zeichnen mit Transparenz
 
Morgen.

Ich lade aus einer Targa-Datei Images für eine TDXImageList.

TGAs besitzen bekanntermaßen einen Alphakanal, den ich auch fleißig nutze.

Wie muss ich die Targas da rein speichern bzw. rauszeichnen, damit die Transparenz auch angewandt wird?

(TTarga, die ich verwende ist von TPicture abgeleitet, hat also alle Propertys/Methoden davon)

Corpsman 13. Jul 2006 19:43

Re: [DelphiX] Zeichnen mit Transparenz
 
Ist nur ne Vermutung, aber hast du das Property Transparent auf true gesetzt ?

Und geschaut ob die Transparent color stimmt ?

3_of_8 13. Jul 2006 21:27

Re: [DelphiX] Zeichnen mit Transparenz
 
Transparent ist true und da ich einen Alphakanal habe, brauche ich doch gar keine TransparentColor.

dizzy 13. Jul 2006 21:36

Re: [DelphiX] Zeichnen mit Transparenz
 
Wenn du DirectDraw verwendest, kommst du nicht dran, da DD keine Alphakanäle unterstützt. Der einzige Weg wäre über Direct3D.

3_of_8 13. Jul 2006 22:13

Re: [DelphiX] Zeichnen mit Transparenz
 
OK, wie könnt ich es dann lösen?

dizzy 14. Jul 2006 04:26

Re: [DelphiX] Zeichnen mit Transparenz
 
Genau bildfüllende Polygone mit Texturen. Die Textuern in D3D können nämlich mit Alphakanälen arbeiten. Zudem wird es damit erheblich einfacher die Zeichenreihenfolge zu managen: Einfach die Z-Koordinaten dafür hernehmen.
Wie das codemäßig im Detail aussehen müsste, kann ich dir mangels Erfahrung mit D3D leider nicht liefern. Das sollte aber mit Hilfe von Tuts recht gut machbar sein.
Ich selbst bin nämlich auch schon mal sehr verzweifelt auf der Suche nach Alpha in DirectDraw gewesen, und bin nach der Erkenntnis, dass das nix wird, dann dort bei dem Projekt bis dato einfach stehen geblieben (war auch nix wirklich wichtiges - nur ne Spielerei).

3_of_8 14. Jul 2006 13:03

Re: [DelphiX] Zeichnen mit Transparenz
 
Ich will kein D3D verwenden, ich denke mal das würde einiges an Overhead mitbringen.

Ich kann natürlich zur Not auch statt Transparenz einfach clFuchsia verwenden, aber ich müsste dazu wissen, wie ich das dann mit DelphiX löse. Ich denke mal, irgendwie wird Transparenz mit Direct Draw schon gehen, oder?

pacman1986 14. Jul 2006 13:26

Re: [DelphiX] Zeichnen mit Transparenz
 
ja an sich ein bitmap wo eine hintergrundfarbe da ist dann musst du noch transparent color setzen und transparent auf true.
edit:
wenn ich ein beispiel uppen soll sag bescheid

3_of_8 14. Jul 2006 15:11

Re: [DelphiX] Zeichnen mit Transparenz
 
Ich probiers mal aus...

ijcro 23. Jul 2006 21:15

Re: [DelphiX] Zeichnen mit Transparenz
 
Hello!

Hardware accelerated unDelphiX ver. 1.7a support alphachannel internaly. You have to load image into DXImageList as DIB 32 (with alhachannel) and it will be work (TARGA has to convert to DIB32). You can download source from unDelphiX home, with all samples and demos (all-in-one pack).

Sorry, I don't understand well, but simple note for D3D: Hardware accelerated unDelphiX run on D3D interface and it contain some magics for compatibility to up. I had to find solution for general base of using, sorry. I know that unDelphiX isn't perfect, but I work myself.

Flogo 28. Jul 2006 09:54

Re: [DelphiX] Zeichnen mit Transparenz
 
Hi ijcro,
could you give a quick explanation on how to get the alphachannel in the DIB? I tried it with Photoshop (new file -> background = transparent -> a few lines with the brush -> save as -> dib) but it just didnt save the alphachannel.
Well maybe it did, but there was no transparence while drawing on the DXDraw surface.
Is it possible to use the Sprite/ImageSprite classes just as before by changing the Image from a "foo.bmp" to a "foo.dib" or do you have to change something else?

[edit]

I just tried to load the image with this TDIB component and called
Delphi-Quellcode:
  DXDraw.Surface.LoadFromDIB(DIB.AlphaChannel);
I saw the Alphachannel, so it must have been saved. But there is still no sign of the Alphachannel when I draw the picture as a Sprite..

[/edit]

ijcro 8. Sep 2006 15:07

Re: [DelphiX] Zeichnen mit Transparenz
 
Helper exists and with it you can put DIB8 into alphachanel (or get out), please see into source in DIB units.

Flogo 9. Sep 2006 09:39

Re: [DelphiX] Zeichnen mit Transparenz
 
Do I have to Draw the DIB manualy or can I just go on drawing the ImageSprite with the DXSpriteEngine?

ijcro 10. Sep 2006 14:23

Re: [DelphiX] Zeichnen mit Transparenz
 
Aha, you is using DXSpriteEngine yet...
Whe you is using "new look" of DXSpriteEngine, you can use HW acceleration a picture with alpha channel, stored in DXImageList. When you prepare picture in other program in way joint DIB24 R8G8B8 and DIB8 A8 with function DIB32.AssignAlphaChannel(DIB8), no more. Please see to function HasAlphaChannel and property AlphaChannel in TDIB class too.

ijcro 14. Sep 2006 10:54

Re: [DelphiX] Zeichnen mit Transparenz
 
Eh sorry, my English is worst than ever

:gruebel:

SirThornberry 14. Sep 2006 11:49

Re: [DelphiX] Zeichnen mit Transparenz
 
Zitat:

Zitat von ijcro
Eh sorry, my English is worst than ever

:gruebel:

Wo liegt dein jetziges Problem? ein Bitmap mit 32bit zu erzeugen wo der 4te Kanal der Alphakanal ist? wenn dem so ist könnt ich dir ein Programm zukommen lassen

ijcro 14. Sep 2006 19:16

Re: [DelphiX] Zeichnen mit Transparenz
 
Well, you can send there code for test...


Alle Zeitangaben in WEZ +1. Es ist jetzt 10:11 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