Autor Beitrag
Hagbard
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 142

Win XP Home / Pro
D7.1 Architekt
BeitragVerfasst: Mi 05.05.04 08:52 
Hallo,
ich hab ein riesen Problem, in 2 Wochen soll meine Software fertig sein und es habert schon an so kleinen Dingen :-(

Also zum Problem:

Im Constructor meiner Klasse (..Abgeleitet von TPanel..) , speichere Ich mir mit
ausblenden Quelltext
1:
2:
    FParCtrl := AOwner;
    FParentCanvas := AOwner.Canvas;

den Parent und dessen Canvas in 2 Variablen (Zeiger?) -- AOwner ist vom Typ TForm.
Nun kann sich durch andere Funktionen, der Canvas der Form ändern (z.B. Bild drauf liegen, etc.)

In meiner Problemfunktion, (siehe unten) erstelle Ich mir nun 2 TRect´s, einen für das was unter meinem Object (also dem Panel liegt) und einen für das Befüllen in mein Panel. Nun will Ich in bmpBottom (TBitmap) das Abbild von dem was sich unter meinem Panel befindet speichern. (um dann mit der Blending Funktion eine Transparenz zu erzeugen).

Jedoch kommt in meinem bmpBottom immer nur ein graues Bild an, obwohl der Canvas meiner Form (FParentCanvas) ein Bild enthällt.

Sieht da einer von Euch einen Fehler? Ich weiß mir nicht mehr zu helfen, und diese Funktion ist Wichtig in meiner Software :-(

ausblenden volle Höhe 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:
    try
      // rect: to cut from parent.canvas
      rectSource.Left := self.left;
      rectSource.Top := self.top;
      rectSource.Right := self.left + self.Width;
      rectSource.Bottom := self.top + self.Height;

      // rect: to fill in panel.canvas
      rectDest.Left := 0;
      rectDest.Top := 0;
      rectDest.Right := self.Width;
      rectDest.Bottom := self.Height;

      // bitmap (part of screenshot of parent)
      bmpBottom := TBitmap.Create;
      bmpBottom.Width := self.Width;
      bmpBottom.Height := self.Height;

      // copy part of parent.canvas in TmpPicture
      bmpBottom.Canvas.CopyRect(rectDest, FParentCanvas, rectSource);

      temp := TBitmap.Create;
      bmpBottom.SaveToFile('c:\hjgdjgf.bmp');

      Blending(bmpBottom, imgPanel.Picture.Bitmap , 50, temp);

      // Return Value (Bitmap)
      imgPanel.picture.Bitmap := temp;

    finally
//      bmpBottom.Free;
    end;


Bin für jeden Tip sehr dankbar ....

Viele Grüße,
Christian
Stauch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 140

Win 2000, Win XP
D4
BeitragVerfasst: Mi 05.05.04 10:15 
Hi,
also ich vermute ganz stark, das die Variable FParentCanvas nicht aktualisiert wird, wenn sich das Canvas-Objekt der Form ändert, d.h., Du kopierst einfach immer wieder den Anfangszustand der Form.

Klappen sollte es (wieder ungetestet)

ausblenden Delphi-Quelltext
1:
bmpBottom.Canvas.CopyRect(rectDest, AOwner.canvas, rectSource);					


Viel Spaß!

_________________
Geht das? Und wenn ja, warum nicht?
Manfred
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 90



BeitragVerfasst: Do 06.05.04 22:41 
Hi!
Ich habe einmal die Erfahrung gemacht, dass allein die Eigenschaften Height und Width einer TBitmap nicht ohne weiteres zur Änderung der Bildauflösung führen. Soll heißen, dass zwar die Komponente irgendwie wohl die neuen Werte angenommen hat, tatsächlich die Pixelzahl nicht zur Verfügung steht. Ich habe folgenden Ausweg gefunden:
ausblenden Quelltext
1:
2:
3:
4:
   bmpBottom.Height := self.Height ;
   bmpBottom.Picture.Bitmap.Height := self.Height ;
   bmpBottom.Width := self.Width ;
   bmpBottom.Picture.Bitmap.Width := self.Width ;

Den Grund für dieses Verghalten kenne ich nicht, zumal ich selbst Gegenbeispiele erlebt habe, wo auf Picture nicht zugegriffen werden musste.
Vielleicht kennt jemand den Grund?

_________________
Computer können schneller rechnen als wir, deshalb machen sie auch mehr Fehler
Hagbard Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 142

Win XP Home / Pro
D7.1 Architekt
BeitragVerfasst: Fr 07.05.04 09:40 
Das Problem hat sich erledigt.
Ich habe mir einfach noch ein "Main" Panel auf die Form gelegt und dort ein TImage rein und benutze nur dessen Canvas.

Das funtzt jetzt wunderbar....

Viele Grüße,
Christian