Autor Beitrag
ardely
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 66



BeitragVerfasst: Do 11.10.07 15:32 
Wie kann ich den Untergrund meines Bitmap transparent machen.
Ich habe so was ausprobiert geht aber nicht, sehr vielen Dank für ihren Vorschlag.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
ImaDes := TBitmap.Create; 
ImaDes.Height := 19 ;
ImaDes.Width := 50;

// versuche mit diesem Befehl das untergrund Transparent zu bekommen, 
ImaDes.Canvas.Brush.Style := bsclear; 

ImaDes.Canvas.Font.Color := clblack;
ImaDes.Canvas.Font.Style := [];
ImaDes.Canvas.Font.Size  := iSize;

ImaDes.Canvas.TextOut(0,0,'Mein Text');


Grüss,
_frank_
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 343
Erhaltene Danke: 1

Win XP
Delphi 3 Prof / Turbo Delphi Explorer
BeitragVerfasst: Do 11.10.07 15:55 
was willst du genau transparent machen? der Text verdeckt bei mir das Bild nicht...
möchtest du das hier erzeugte Bitmap transparent über etwas anderes drüberlegen?

Gruß Frank

_________________
EB FE (die wahrscheinlich kürzeste Endlosschleife der Welt :) )
BA 01 00 00 00 52 EB 09 BB 4D 11 86 7C FF D3 EB 0D E8 F2 FF FF FF 63 68 61 72 6D 61 70 00 C3
ardely Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 66



BeitragVerfasst: Do 11.10.07 16:18 
Hallo,
Ja ich wollte nur der Text sichtbar machen und das Untergrund des bitmap (ImaDes) soll transparent sein. Dann später wird dises (ImaDes) bitmap auf ein andres Hautbild hingelegt und der text soll nur sichtbar sein über das Bild.
Grüss.
_frank_
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 343
Erhaltene Danke: 1

Win XP
Delphi 3 Prof / Turbo Delphi Explorer
BeitragVerfasst: Do 11.10.07 16:26 
warum malst nicht gleich den Text auf das Hauptbild? Wegen der Transparenz des Gesamten Bitmaps gibts u.a. ein Property Transparent(Color):

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
var bmp:TBitmap;
begin
  bmp:=TBitmap.create;
  bmp.width:=100;
  bmp.height:=20;
  bmp.Canvas.TextOut(0,0,'Test');
  bmp.TransparentColor:=bmp.Canvas.Pixels[0,0];
  bmp.Transparent:=true;
  canvas.Draw(0,0,bmp);
  bmp.free;
end;


HTH Frank

_________________
EB FE (die wahrscheinlich kürzeste Endlosschleife der Welt :) )
BA 01 00 00 00 52 EB 09 BB 4D 11 86 7C FF D3 EB 0D E8 F2 FF FF FF 63 68 61 72 6D 61 70 00 C3
ardely Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 66



BeitragVerfasst: Do 11.10.07 16:36 
Ich wollte mein frage irgendwie einfach stellen, eigentlich das Bild wird in einem
richedit hinzugefügt.
Ich probiere sofort deinen Code aus. Danke, und sage dir bescheid wie es geht.
ardely Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 66



BeitragVerfasst: Do 11.10.07 16:57 
Sorry, es geht noch nicht, der Untergrund ist noch immer Weiß.
Danke für deinen schnellen Vorschlag, was kannst du mir noch raten!
Grüsse.
_frank_
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 343
Erhaltene Danke: 1

Win XP
Delphi 3 Prof / Turbo Delphi Explorer
BeitragVerfasst: Do 11.10.07 17:30 
in meinem code geh ich davon aus, dass das Pixel in der linken oberen Ecke (0,0) die transparent zumachende Farbe enthält...
wie gesagt, das einfachste wäre den Text direkt auf das ZielCanvas zu malen.
bei mir funktioniert das ohne Probleme:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
procedure TForm1.Button4Click(Sender: TObject);
var bmp:TBitmap;
    c:TCanvas;
begin
  bmp:=TBitmap.create;
  bmp.width:=100;
  bmp.height:=20;
  bmp.canvas.pen.color:=clred;
  bmp.Canvas.Pen.width:=2;
  bmp.Canvas.Brush.Style:=bsClear;
  bmp.Canvas.TextOut(1,1,'Test');
  bmp.TransparentColor:=bmp.Canvas.Pixels[0,0];
  bmp.Transparent:=true;
  c:=TCanvas.Create;
  c.Handle:=GetDC(richedit1.Handle);
  c.Draw(4,4,bmp);
  c.free;
  bmp.free;
end;

_________________
EB FE (die wahrscheinlich kürzeste Endlosschleife der Welt :) )
BA 01 00 00 00 52 EB 09 BB 4D 11 86 7C FF D3 EB 0D E8 F2 FF FF FF 63 68 61 72 6D 61 70 00 C3
ardely Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 66



BeitragVerfasst: Do 11.10.07 17:49 
Ja, du hast recht aber ich habe kein ZielCanvas (Richedit), danke für deine mühe aber in meinen fall der Code funktioniert nicht!
Ich bin noch am suchen.... Schönen Abend noch..
_frank_
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 343
Erhaltene Danke: 1

Win XP
Delphi 3 Prof / Turbo Delphi Explorer
BeitragVerfasst: Do 11.10.07 17:58 
user profile iconardely hat folgendes geschrieben:
Ja, du hast recht aber ich habe kein ZielCanvas (Richedit),

ich hatte auch keins, daher hab ich mir eins geholt...siehe oben, oder versteh ich dich falsch?
user profile iconardely hat folgendes geschrieben:
danke für deine mühe aber in meinen fall der Code funktioniert nicht!

vielleicht solltest du da deinen speziellen Fall genauer erläutern. Wenn wir den kennen, können wir auch gezielter testen :)

Gruß Frank

_________________
EB FE (die wahrscheinlich kürzeste Endlosschleife der Welt :) )
BA 01 00 00 00 52 EB 09 BB 4D 11 86 7C FF D3 EB 0D E8 F2 FF FF FF 63 68 61 72 6D 61 70 00 C3
ardely Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 66



BeitragVerfasst: Do 11.10.07 18:33 
Hier ein Bild um mich besser aus zu drücken!
der Untergrund der Richedit ist grün,
ausblenden Delphi-Quelltext
1:
  RichEdit1.Color := clGreen;					


beim drücken button1 ist das Bild 'Test' in einem weissen Rahmen
im richedit. Das Bild 'Test' soll aber den Untergrund haben wie der Richedit
also nicht weiss sondert transparent...
Danke.
Einloggen, um Attachments anzusehen!
_frank_
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 343
Erhaltene Danke: 1

Win XP
Delphi 3 Prof / Turbo Delphi Explorer
BeitragVerfasst: Do 11.10.07 19:26 
mal als vergleich mein screenshot....irgendwas machst in deinem Code anders...genau der code von vorhin...mit einem hellblauen Richedit :)

Gruß Frank
Einloggen, um Attachments anzusehen!
_________________
EB FE (die wahrscheinlich kürzeste Endlosschleife der Welt :) )
BA 01 00 00 00 52 EB 09 BB 4D 11 86 7C FF D3 EB 0D E8 F2 FF FF FF 63 68 61 72 6D 61 70 00 C3
ardely Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 66



BeitragVerfasst: Do 11.10.07 19:37 
Habe wieder alles neu gemacht und habe noch immer das selbe problem (Delphi 2005) Hier das Komplette Source-Code.
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:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls;

type
  TForm1 = class(TForm)
    RichEdit1: TRichEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Déclarations privées }
  public
    { Déclarations publiques }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);

 var bmp:TBitmap;
    c:TCanvas;
begin
  bmp:=TBitmap.create;
  bmp.width:=100;
  bmp.height:=20;
  bmp.canvas.pen.color:=clred;
  bmp.Canvas.Pen.width:=2;
  bmp.Canvas.Brush.Style:=bsClear;
  bmp.Canvas.TextOut(1,1,'Test');
  bmp.TransparentColor:=bmp.Canvas.Pixels[0,0];
  bmp.Transparent:=true;
  c:=TCanvas.Create;
  c.Handle:=GetDC(richedit1.Handle);
  c.Draw(4,4,bmp);
  c.free;
  bmp.free;
end;

end.


Grüss
ardely Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 66



BeitragVerfasst: Fr 12.10.07 18:52 
Hallo, ich habe versucht den selben Code mit Delphi 7 aber immer den selben problem!
Habt Ihr noch eine test Lösung dass ich ausprobieren kann!
Vielen dank für Ihre Vorschlage. Danke
_frank_
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 343
Erhaltene Danke: 1

Win XP
Delphi 3 Prof / Turbo Delphi Explorer
BeitragVerfasst: Fr 12.10.07 22:43 
ich hab das jetzt auch mal in delphi 7 probiert. bei mir ist das bitmap transparent, wie unter D3 auch...machst du noch irgendetwas anders?
kann mir sonst nicht vorstellen, woran es liegen sollte...du hast ein normales Richedit und die Farbe im OI gesetzt?

Gruß Frank
Einloggen, um Attachments anzusehen!
_________________
EB FE (die wahrscheinlich kürzeste Endlosschleife der Welt :) )
BA 01 00 00 00 52 EB 09 BB 4D 11 86 7C FF D3 EB 0D E8 F2 FF FF FF 63 68 61 72 6D 61 70 00 C3