Autor Beitrag
en!gma
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 378

win xp
delphi 7.0
BeitragVerfasst: Sa 30.04.05 00:13 
hiho...
also mal kurz meine idee,
ich öffne per colordialog halt die farbauswahl.
wenn ich dann eine farbe ausgewählt habe, habe ich ein kleines rechteck auf der form, und zwar mit der farbe, die ich ausgewählt habe.
dann soll da noch ein schieberegler sein, mit dem ich die transparenz von dem kleinen rechteck bestimmen kann.
also wenn ich die transparenz auf 100 setze, soll das rechteck verschwinden, auf 0 soll es komplett zu sehen sein.

also meine 2 fragen:

1. wie kriege ich dieses rechteck überhaupt hin?
2. wie mach ich das am besten mit dem schieberegler?

thx schonma ;D

mfg

en!gma


Moderiert von user profile iconTino: Topic aus Sonstiges verschoben am Sa 30.04.2005 um 17:50
en!gma Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 378

win xp
delphi 7.0
BeitragVerfasst: Sa 30.04.05 12:08 
so wie ich son farbdingen hinkrieg, weiss ich jetzt schonmal.

hab das hier irgendwo in nem post gefunden:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.Button1Click(Sender: TObject);
begin
     random;
     Image1.Canvas.Brush.Color:=rgb(random(256),random(256),random(256));
     Image1.Canvas.FillRect(Image1.ClientRect);
end;


jex fehlt nur noch das mit der transparenz.
irgendwer ne idee?
fvolk
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 203

Win XP (Home & Pro)
Delphi 2005 Pers
BeitragVerfasst: Sa 30.04.05 12:55 
Die Transparenz erzeugst du von Hand, indem du den Pixel, welchen du in der Farbe A zeichnen willst, mit der Hintergrundfarbe B im richtigen Verhältnis mischst.

Wenn der Hintergrund einfarbig ist, musst du die Pixel natürlich nicht einzeln zeichnen, sondern einfach die Gesamtfarbe berechnen (alle Pixel habe dann sinnigerweise die gleiche Farbe - wer hätte es gedacht 8) ).

z.B.

50% Transparenz: A:2 + B:2 (natürlich immer für alle drei Farbangaben)
75% Transparenz: A*0,75 + B*0,75
u.s.w.

P.S. Die Quellcodezeile 3 in deinem vorhergehenden Posting muss Randomize; lauten.

_________________
Nichts auf der Welt ist so gerecht verteilt wie der Verstand. Denn jedermann ist überzeugt, dass er genug davon habe.
(René Descartes)
en!gma Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 378

win xp
delphi 7.0
BeitragVerfasst: Sa 30.04.05 13:00 
hab grad das hier von MarinPB
gefunden
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
procedure Blending2(bmpBottom, bmpTop: TBitmap; Opacity: Byte; bmpResult: TBitmap);
// bmpBottom: Background Picurte
// bmpTop   : Foreground Picture
// opacity  : 1..100 (Shining Intensity of Background)

type
  PixArray = Array [1..3] of Byte;
var
  Temp: TBitmap;
  p1, p2: ^PixArray;
  x, y: Integer;
  f1, f2 : Double;
begin
  //bmpBottom.PixelFormat := pf24bit;
  //bmpTop.PixelFormat := pf24bit;
  //bmpResult.PixelFormat := pf24bit;

  Temp := TBitmap.Create;
  try
    Temp.Assign(bmpBottom);
    Temp.PixelFormat := pf24bit;

    if Opacity > 100 then Opacity := 100;

    f1 := Opacity / 100;
    f2 := Abs(1 - f1);

    for y := 0 to temp.Height - 1 do
    begin
      p1 := bmpTop.ScanLine[y];
      p2 := bmpBottom.ScanLine[y];

      for x:=0 to temp.Width - 1 do
      begin
        p2^[1] := Trunc((p1^[1] * f1) + (p2^[1] * f2));
        p2^[2] := Trunc((p1^[2] * f1) + (p2^[2] * f2));
        p2^[3] := Trunc((p1^[3] * f1) + (p2^[3] * f2));

        Inc(p1);
        Inc(p2);
      end;
    end;

    bmpResult.Assign(Temp);
    bmpResult.Modified := True;
  finally
    Temp.Free;
  end;
end;


kann ich das dafür brauchen?
aber das is jex für 2 bilder,also um 2 übereinanderzulegen.
wie kann ich das umbauen, damit es nur für 1 bild und den hintergrund funktioniert?
fvolk
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 203

Win XP (Home & Pro)
Delphi 2005 Pers
BeitragVerfasst: Sa 30.04.05 18:28 
:evil: Dieser Code macht doch ziemlich genau das, was ich vorgeschlagen habe! bmpBottom wäre dein Hintergrund, bmpTop deine Graphik (also die ausgewählte Farbe).

_________________
Nichts auf der Welt ist so gerecht verteilt wie der Verstand. Denn jedermann ist überzeugt, dass er genug davon habe.
(René Descartes)