Autor Beitrag
Mahjong
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 67



BeitragVerfasst: Sa 11.06.05 13:57 
Also ich habe mir überlegt, das es schön wäre, ein Form zu haben, das die Form eines Bildes hat, sprich mit allen Ecken,kanten,rundungen usw. , geht so etwas, und wenn ja wie ?

Moderiert von user profile iconTino: Titel geändert.
der_zaehe
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 317

WinXP SP2
D6 Pers, D2005 Prof, VS2005
BeitragVerfasst: Sa 11.06.05 14:14 
das geht.
du musst erst mal die eigenschaft "BorderStyle" deines formulars auf "bsNone" setzen. dann packst du dir ein bild auf dein formular, das die größe des formulars haben sollte.
jetzt wichtig! dein bild muss folgende eigenschaften haben:
aussen, da wo es später transparent sein soll, muss es eine ganz bestimmte farbe haben, welche ist egal, aber es muss überall die gleiche farbe sein. (z.B. RGB 255,0,0)
dann setzt du die formulareigenschaft "TransparentColor" auf TRUE und stellst als "TransparentColorValue" die farbe ein, die danach transparent sein soll, die farbe die dein Bild aussen hat.

fertig!

_________________
[inspirationslos]


Zuletzt bearbeitet von der_zaehe am Sa 11.06.05 14:40, insgesamt 1-mal bearbeitet
root_at_localhost
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 191



BeitragVerfasst: Sa 11.06.05 14:21 
Gibt's da eigentlich auch nen Weg mit Delphi 4 (da hatte TForm noch kein TransparentColor)
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Sa 11.06.05 14:30 
user profile iconroot_at_localhost hat folgendes geschrieben:
Gibt's da eigentlich auch nen Weg mit Delphi 4 (da hatte TForm noch kein TransparentColor)

Falls du die Sources einer Delphiversion hast, bei der es TransparentColor gibt, kannst du ja schauen, wie es dort gemacht wird und es auf Delphi4 übertragen.
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: Sa 11.06.05 14:49 
Prinzipiell geht das mit 'regions'. Schau mal in der Windows-Hilfe nach. Eine 'Region' beschreibt den Umriss eines WinControls! Der kann jede beliebige Form haben:
Eine Region kann auf diverse Art und Weise erzeugt werden: Ich mache das, indem ich die Hintergrundbitmap Zeile für Zeile analysiere und die Bereiche, die ich sehen will, sukkzessive als 1-pixel hohe Rechtecke zu der Region hinzufüge. Das geht ganz einfach über einen WinAPI-Aufruf. Welche das sind, überlasse ich Dir als Übung.

Du machst Folgendes (pseudocode):
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
For i:=0 To BackGroundBitmap.Height - 1 do begin
  InRegion := False;
  For j:= 0 to  BackGroundBitmap.width - 1 do
    if BackGroundBitmap.pixels[j,i] = clMyTransparentcolor Then
      If InRegion Then begin
        AddRegion (i,jleft,j-1);
        InRegion := False;
        End
      else begin
        InRegion := True;
        jLeft := j;
        end;
   
  If InRegion Then 
    AddRegion (i,jleft, BackGroundBitmap.width - 1);
  End

Die Prozedur AddRegion (i,j0,j1) fügt das Rechteck Rect (j0,i-1, j1, i) in die Region ein. Wie gesagt: Da reicht ein Call. Noch ein Tipp: Du musst unterscheiden, ob die Region leer ist oder nicht (also, ob Du AddRegion zum 1.Mal aufrufst, oder nicht).

Der vollständige, lauffähige, kommentierte und getestete Code ist übrigens kostenpflichtig :mrgreen:
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Sa 11.06.05 15:40 
user profile iconalzaimar hat folgendes geschrieben:
Der vollständige, lauffähige, kommentierte und getestete Code ist übrigens kostenpflichtig :mrgreen:
benutzt dann aber hoffentlich scanline statt pixels :roll:

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: So 12.06.05 06:10 
Was, meinst Du, bedeutet das Wort "Pseudocode"? Eine veranschaulichende Implementierung, ohne auf sprachspezifische und optimierende Eigenheiten Rücksicht zu nehmen.
Weiterhin solltest Du das Wort "Übung" in meinem Text entdeckt haben, verbunden mit dem Verb "überlassen". Das impliziert was?
root_at_localhost
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 191



BeitragVerfasst: So 12.06.05 13:19 
Danke für die Hilfe, mit dem Schlüsselword Regions und dem Tipp Scanline zu verwenden wars nicht schwierig...