procedure TForm1.PaintBox1Paint(Sender: TObject);
Const
dash : array[0..3] of single = (1, 1, 5, 4);
Grani : array[0..2] of TPoint =
((x: 620; y: 180),
(x: 560; y: 200),
(x: 600; y: 260));
var
R : TRect;
Pen : TGPPen;
SolidBrush : TGPSolidBrush;
path : TGPGraphicsPath;
Image, pThumbnail: TGPImage;
begin
graphicsGDIPlus := TGPGraphics.Create(PaintBox1.Canvas.Handle);
pen:= TGPPen.Create(MakeColor(255, 0, 0, 0), 1);
R.X := 0; R.Y := 0;
R.Width := 50; R.Height := 50;
graphicsGDIPlus.DrawRectangle(Pen,R);
graphicsGDIPlus.DrawLine(Pen,R.X,R.Y,R.X+R.Width,R.Y+R.Height);
pen.Free;
pen:= TGPPen.Create(MakeColor(255, 0, 0, 0), 5);
R.X := 60; R.Y := 0;
R.Width := 50; R.Height := 50;
graphicsGDIPlus.DrawRectangle(Pen,R);
graphicsGDIPlus.DrawLine(Pen,R.X,R.Y,R.X+R.Width,R.Y+R.Height);
pen.Free;
pen:= TGPPen.Create(MakeColor(255, 0, 0, 0), 5);
Pen.SetDashPattern(@dash, 4);
R.X := 120; R.Y := 0;
R.Width := 50; R.Height := 50;
graphicsGDIPlus.DrawRectangle(Pen,R);
graphicsGDIPlus.DrawLine(Pen,R.X,R.Y,R.X+R.Width,R.Y+R.Height);
pen.Free;
path := TGPGraphicsPath.Create;
pen:= TGPPen.Create(MakeColor(255, 0, 0, 0), 1);
path.Reset;
R.X := 180 ; R.Y := 0;
R.Width := 50; R.Height := 50;
path.StartFigure();
path.AddArc(R, 0.0, -180.0);
path.AddLine(R.X, R.Y+25, R.X+25, R.Y+R.Height);
path.AddLine(R.X+25, R.Y+R.Height,R.X+R.Width, R.Y+25);
path.CloseFigure();
graphicsGDIPlus.DrawPath(pen, path);
Pen.Free;
SolidBrush := TGPSolidBrush.Create(MakeColor(255, 255, 255, 0));
R.X := 0 ; R.Y := 60;
R.Width := 50; R.Height := 50;
graphicsGDIPlus.FillRectangle(SolidBrush,R);
SolidBrush.Free;
SolidBrush := TGPSolidBrush.Create(MakeColor(255, 255, 255, 0));
R.X := 60 ; R.Y := 60;
R.Width := 50; R.Height := 50;
graphicsGDIPlus.FillEllipse(SolidBrush,R);
SolidBrush.Free;
path := TGPGraphicsPath.Create;
SolidBrush := TGPSolidBrush.Create(MakeColor(255, 255, 255, 0));
path.Reset;
R.X := 120 ; R.Y := 60;
R.Width := 50; R.Height := 50;
path.StartFigure();
path.AddArc(R, 0.0, -180.0);
path.AddLine(R.X, R.Y+25, R.X+25, R.Y+R.Height);
path.AddLine(R.X+25, R.Y+R.Height,R.X+R.Width, R.Y+25);
path.CloseFigure();
graphicsGDIPlus.FillPath(SolidBrush, path);
SolidBrush.Free;
Image:= TGPImage.Create('FRUIT.JPG');
pThumbnail := Image.GetThumbnailImage(60, 48, nil, nil);
graphicsGDIPlus.DrawImage(pThumbnail, 0, 120, pThumbnail.GetWidth, pThumbnail.GetHeight);
pThumbnail.Free;
pThumbnail := Image.GetThumbnailImage(20, 20, nil, nil);
graphicsGDIPlus.DrawImage(pThumbnail, 70, 120, pThumbnail.GetWidth, pThumbnail.GetHeight);
pThumbnail.Free;
graphicsGDIPlus.DrawImage(image, 0, 180);
R := MakeRect(220, 180, 320, 200);
graphicsGDIPlus.DrawImage(Image,R);
graphicsGDIPlus.DrawImage(Image, PPoint(@Grani), 3);
Image.Free;
graphicsGDIPlus.Free;
end;
|