akpert
April 11th, 2008, 05:51 AM
//Borland Developer Studio 2006
//why result of GetRegionScans is not a array of rectanglef ?????
//where is the mistake
//This Prblem is also in C ++ to
procedure TWinForm.DrawRg(g: graphics);
var
gp,gp1:GraphicsPath;
a:array [0..6]of pointf;
rg:System.Drawing.Region;
b:array of rectanglef;
r:rectanglef;
begin
a[0]:=pointf.Create(10.11,10.11);
a[1]:=pointf.Create(300.44,10.11);
a[2]:=pointf.Create(300.44,150.66);
a[3]:=pointf.Create(150.66,150.66);
a[4]:=pointf.Create(150.66,100.11);
a[5]:=pointf.Create(10.11,100.11);
a[6]:=a[0];
gp:=GraphicsPath.Create();
gp.AddPolygon(a);
rg:=System.Drawing.Region.Create(gp);
b:=rg.GetRegionScans(Matrix.Create());
r:=rg.GetBounds(g);
listbox1.Items.Add(convert.ToString(r.Left));
//10,11 it is correctly
listbox1.Items.Add(convert.ToString(b[0].Left));
//11 it is not correctly, it should be 10.11
listbox1.Items.Add(convert.ToString(b[0].Top));
//11 it is not correctly, it should be 10.11
listbox1.Items.Add(convert.ToString(b[0].Width));
//290 it is not correctly, it should be 290.33
g.DrawPath(pen.Create(color.Red,1),gp);
g.DrawRectangles(pen.Create(color.Blue,1),b);
end;
//why result of GetRegionScans is not a array of rectanglef ?????
//where is the mistake
//This Prblem is also in C ++ to
procedure TWinForm.DrawRg(g: graphics);
var
gp,gp1:GraphicsPath;
a:array [0..6]of pointf;
rg:System.Drawing.Region;
b:array of rectanglef;
r:rectanglef;
begin
a[0]:=pointf.Create(10.11,10.11);
a[1]:=pointf.Create(300.44,10.11);
a[2]:=pointf.Create(300.44,150.66);
a[3]:=pointf.Create(150.66,150.66);
a[4]:=pointf.Create(150.66,100.11);
a[5]:=pointf.Create(10.11,100.11);
a[6]:=a[0];
gp:=GraphicsPath.Create();
gp.AddPolygon(a);
rg:=System.Drawing.Region.Create(gp);
b:=rg.GetRegionScans(Matrix.Create());
r:=rg.GetBounds(g);
listbox1.Items.Add(convert.ToString(r.Left));
//10,11 it is correctly
listbox1.Items.Add(convert.ToString(b[0].Left));
//11 it is not correctly, it should be 10.11
listbox1.Items.Add(convert.ToString(b[0].Top));
//11 it is not correctly, it should be 10.11
listbox1.Items.Add(convert.ToString(b[0].Width));
//290 it is not correctly, it should be 290.33
g.DrawPath(pen.Create(color.Red,1),gp);
g.DrawRectangles(pen.Create(color.Blue,1),b);
end;