delphi - Draw polygon on Image -


I've been searching for a long time but the answer could not be found.

I want to draw a polygon on an image, but I want to do this by making marks; MouseCursor With this specific point of view, and drawing a line with these points with these buttons;

I found this:

  var poly: array of TPoint; Allocate dynamic array of start / TOPint SetLength (poly, 6); // Set array element poly [0]: = dot (10, 10); Shift [1]: = point (30, 5); Shift [2]: = point (100, 20); Shift [3]: = point (120, 100); Shift [4]: ​​= point (50, 120); Shift [5]: = point (10, 60); // Pass for regular canvas drawing. Polygon (poly); // Settleant (poly, 7) if needed; Shift [6]: = dot (1, 5); // Pass for regular canvas drawing. Polygon (poly); End;   

This is what I want, but the difference is given by dot [1] , dot [2] , etc. User MouseEvent .

You can override a paint box on your image and use a code like this < / P>

  unit unit 3; Interface uses Windows, Messages, SUsUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Extracts, STDCTL; Type TPointArray = array of TPoint; TForm3 = Class (TForm) Image1: TImage; Paintbox 1: Tepenbox; Button 1: Tibbon; Process PaintBox1MouseDown (Sender: Torque; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); Process PaintBox1Paint (Sender: Tubect); Click Process Button 1 (Sender: Tubect); Private (private-declaration) FPointArray: TPointArray; Public {public- Deklarationen} end; Var form 3: Teform 3; Implementation {$ R *. Dfm} Process TForm3.Button1Click (Sender: Tubbed); Start PaintBox1. Visible: = Wrong; Image1.Canvas.Polygon (FPointArray); End; Process TForm3.PaintBox1MouseDown (From: TOBject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); Start SetLength (FPointArray, Length (FPointArray) +1); FPointArray [High (FPointArray)] X: = X; FPointArray [High (FPointArray)] Y: = Y; Paintbox1.Invalidate; End; Process TForm3.PaintBox1Paint (Sender: Tubect); Var i: integer; Start the Paintbox 1. Canvas. Brush. Style: = BS Claire; // like a shaft painted as suggested by 1. Canvas. Polygon (FPSAirre); I: Starting from 0 = 0 to the higher (FPointArray) paint box 1. Canvas TextAut (FPSERRA [I]. X-5, FPNTARRA [I] .Y-5, ITTOST (I)); End; End; End.    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -