el-mono
10-03-2015, 02:38:24
Buenas noches.
Tengo un pequeño problema que no se resolver y espero poder recibir ayuda de ustedes.
Lo que quiero hacer: Quiero mediante código dibujar un polígono con un color y un borde para resaltar una porción de la imagen
Obtener puntos del polígono a dibujar: Para obtener los puntos del poligono que siempre sera el mismo puse sobre un formulario un control Timage y cargue la imagen, luego puso un control del tipo TSelectionPoint luego ejecute el proyecto temporal y fui capturando los puntos mediante la sentencia: TSelectionPoint.Position.Point.X / Y.
Dibujar Polígono y sorpresa: Cuando ya obtuve mis puntos para poder dibujar el polígono cree un código (lo pego abajo para que vean) en un control TButton para dibujar mi polígono y ver los resultados, pero me lleve una sorpresa al ver que mi polígono se me dibuja por arriba de las coordenadas que obtuve con el control TSelectionPoint. No se que estoy haciendo mal, espero haberme explicado :D
var
p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12: TPointF;
MyPolygon: TPolygon; //System.Math.Vectors unit needed.
begin
// sets the points that define the polygon
p1 := TPointF.Create(88, 84);
p2 := TPointF.Create(108, 99);
p3 := TPointF.Create(113, 107);
p4 := TPointF.Create(116, 127);
p5 := TPointF.Create(114, 144);
p6 := TPointF.Create(93, 149);
p7 := TPointF.Create(77, 148);
p8 := TPointF.Create(65, 147);
p9 := TPointF.Create(61, 132);
p10 := TPointF.Create(59, 113);
p11 := TPointF.Create(68, 98);
p12 := TPointF.Create(88, 84);
// creates the polygon
SetLength(MyPolygon, 12);
MyPolygon[0] := p1;
MyPolygon[1] := p2;
MyPolygon[2] := p3;
MyPolygon[3] := p4;
MyPolygon[4] := p5;
MyPolygon[5] := p6;
MyPolygon[6] := p7;
MyPolygon[7] := p8;
MyPolygon[8] := p9;
MyPolygon[9] := p10;
MyPolygon[10] := p11;
MyPolygon[11] := p12;
Image2.Bitmap.Canvas.BeginScene;
// draws the polygon on the canvas
Image2.Bitmap.Canvas.Stroke.Color := $FF4193F9;
Image2.Bitmap.Canvas.Stroke.Thickness := 10;
Image2.Bitmap.Canvas.Fill.Color := $FFF8FD5F;
// Image1.Bitmap.Canvas.Fill.Kind := TBrushKind.None;
Image2.Bitmap.Canvas.DrawPolygon(MyPolygon, 90);
Image2.Bitmap.Canvas.FillPolygon(mypolygon,90);
Image2.Bitmap.Canvas.EndScene;
Les dejo una imagen para ilustrar mas:
https://drive.google.com/file/d/0B4dZxYUXPxPiMEh4RWlQb3llQzg/view?usp=sharing
Tengo un pequeño problema que no se resolver y espero poder recibir ayuda de ustedes.
Lo que quiero hacer: Quiero mediante código dibujar un polígono con un color y un borde para resaltar una porción de la imagen
Obtener puntos del polígono a dibujar: Para obtener los puntos del poligono que siempre sera el mismo puse sobre un formulario un control Timage y cargue la imagen, luego puso un control del tipo TSelectionPoint luego ejecute el proyecto temporal y fui capturando los puntos mediante la sentencia: TSelectionPoint.Position.Point.X / Y.
Dibujar Polígono y sorpresa: Cuando ya obtuve mis puntos para poder dibujar el polígono cree un código (lo pego abajo para que vean) en un control TButton para dibujar mi polígono y ver los resultados, pero me lleve una sorpresa al ver que mi polígono se me dibuja por arriba de las coordenadas que obtuve con el control TSelectionPoint. No se que estoy haciendo mal, espero haberme explicado :D
var
p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12: TPointF;
MyPolygon: TPolygon; //System.Math.Vectors unit needed.
begin
// sets the points that define the polygon
p1 := TPointF.Create(88, 84);
p2 := TPointF.Create(108, 99);
p3 := TPointF.Create(113, 107);
p4 := TPointF.Create(116, 127);
p5 := TPointF.Create(114, 144);
p6 := TPointF.Create(93, 149);
p7 := TPointF.Create(77, 148);
p8 := TPointF.Create(65, 147);
p9 := TPointF.Create(61, 132);
p10 := TPointF.Create(59, 113);
p11 := TPointF.Create(68, 98);
p12 := TPointF.Create(88, 84);
// creates the polygon
SetLength(MyPolygon, 12);
MyPolygon[0] := p1;
MyPolygon[1] := p2;
MyPolygon[2] := p3;
MyPolygon[3] := p4;
MyPolygon[4] := p5;
MyPolygon[5] := p6;
MyPolygon[6] := p7;
MyPolygon[7] := p8;
MyPolygon[8] := p9;
MyPolygon[9] := p10;
MyPolygon[10] := p11;
MyPolygon[11] := p12;
Image2.Bitmap.Canvas.BeginScene;
// draws the polygon on the canvas
Image2.Bitmap.Canvas.Stroke.Color := $FF4193F9;
Image2.Bitmap.Canvas.Stroke.Thickness := 10;
Image2.Bitmap.Canvas.Fill.Color := $FFF8FD5F;
// Image1.Bitmap.Canvas.Fill.Kind := TBrushKind.None;
Image2.Bitmap.Canvas.DrawPolygon(MyPolygon, 90);
Image2.Bitmap.Canvas.FillPolygon(mypolygon,90);
Image2.Bitmap.Canvas.EndScene;
Les dejo una imagen para ilustrar mas:
https://drive.google.com/file/d/0B4dZxYUXPxPiMEh4RWlQb3llQzg/view?usp=sharing