Thema: Delphi Abgerundete Ecken

Einzelnen Beitrag anzeigen

Moony

Registriert seit: 29. Jul 2003
Ort: Essen
454 Beiträge
 
Delphi 2010 Professional
 
#10

Re: Abgerundete Ecken

  Alt 5. Mai 2008, 09:36
Hallo,

ich habe das jetzt so gemacht:

Delphi-Quellcode:
procedure DoItRound;
var bmp_mask,
      bmp_tmp : TBitmap;

const cl_trans_tmp = clWhite;
      cl_trans = clFuchsia;
begin
  bmp_mask := TBitmap.create;
  bmp_tmp := TBitmap.create;
  try
     //load bitmap
     bmp_tmp.Assign(Form1.image1.picture.bitmap);
     //resize mask
     bmp_mask.width := bmp_tmp.width;
     bmp_mask.height := bmp_tmp.height;
     //create the mask;
     bmp_mask.canvas.brush.color := cl_trans;
     bmp_mask.canvas.Pen.color := cl_trans;
     bmp_mask.Canvas.FillRect(rect(0,0,bmp_mask.width,bmp_mask.height));
     bmp_mask.canvas.brush.color := cl_trans_tmp;
     bmp_mask.canvas.Pen.color := cl_trans_tmp;
     bmp_mask.canvas.RoundRect(0,0,bmp_mask.width,bmp_mask.height, 10,10);
     bmp_mask.TransparentColor := cl_trans_tmp;
     bmp_mask.Transparent := true;

     //merging the mask with original bitmap
     bmp_tmp.Canvas.Draw(0,0,bmp_mask);
     bmp_tmp.TransparentColor := cl_trans;
     bmp_tmp.Transparent := true;

     //Draw masked bitmap
     Form1.Image2.canvas.draw(0,0,bmp_tmp);
  finally
     //free Objects
     bmp_tmp.free;
     bmp_mask.free;
  end;
end;
Leider wird hier nur das Bild reingezeichnet ohne jegliche runde Ecken.
Zeichne ich das Ganze anstatt auf das Image2 auf mein Canvas der Form1, dann funktioniert das.

In meinem Programm zeichne ich aber auf das Canvas eines Imageobjektes und nicht auf das Canvas der Form.

Gruß, Moony
Ich weiß, daß ich nichts weiß! Sokrates
  Mit Zitat antworten Zitat