unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,Gdipapi,Gdipobj, ExtCtrls, jpeg;
type
TForm1 =
class(TForm)
Image1: TImage;
PaintBox1: TPaintBox;
procedure FormCreate(Sender: TObject);
procedure PaintBox1Paint(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
Procedure AddSprechblase(graphics:TGPGraphics;Base:TGPPointF;SizeRect:TGPRectF;PenColor,BrushColor:TGPColor;Caption:String='
';AngleWidth:Integer=20;TextHeight:Integer=10; FontName:String='
Arial');
var
Path : TGPGraphicsPath;
Pen : TGPPen;
Brush : TGPSolidBrush;
StringFormat:TGPStringFormat;
FontFamily : TGPFontFamily;
Font : TGPFont;
begin
Path:=TGPGraphicsPath.Create;
Pen := TGPPen.Create(PenColor);
Brush := TGPSolidBrush.Create(BrushColor);
StringFormat:= TGPStringFormat.Create;
FontFamily := TGPFontFamily.Create(FontName);
Font := TGPFont.Create(FontFamily, TextHeight, FontStyleRegular, UnitPixel);
if Base.Y > SizeRect.Y
then Path.AddArc(SizeRect, 90 + AngleWidth, 360 - 2 * AngleWidth)
else Path.AddArc(SizeRect, - 90 + AngleWidth, 360.0 - 2 * AngleWidth);
Path.AddLine(Base,Base);
path.CloseAllFigures;
graphics.FillPath(brush, path);
graphics.DrawPath(pen, path);
if Length(Caption) > 0
then
begin
Brush.SetColor(PenColor);
stringFormat.SetAlignment(StringAlignmentCenter);
stringFormat.SetLineAlignment(StringAlignmentCenter);
graphics.DrawString(Caption,-1,Font,Sizerect,stringformat,Brush)
end;
Path.Free;
Pen.Free;
Brush.Free;
StringFormat.Free;
FontFamily.Free;
Font.Free;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Paintbox1.BringToFront;
end;
procedure TForm1.PaintBox1Paint(Sender: TObject);
var
graphics:TGPGraphics;
begin
graphics:=TGPGraphics.Create(Paintbox1.Canvas.Handle);
graphics.SetSmoothingMode(SmoothingModeHighQuality);
graphics.SetTextRenderingHint(TextRenderingHintAntiAlias);
AddSprechblase(graphics,MakePoint(200.0,400.0),MakeRect(100.0,100.0,300,200),MakeColor(200,255,0,0),MakeColor(200,255,255,255),'
Tescht',10,50);
graphics.Free;
end;
end.