Prod.: Engine, ver.: 6, ID: 60001723, HowTo : How can I define a clip-bound on an image using a vdCurve object

HowTo : How can I define a clip-bound on an image using a vdCurve object

Article60001723
TypeHowTo
ProductEngine
Version6
Date Added6/8/2012
Submitted byMakarounis Giannis
Keywords

Subject

How can I define a clip-bound on an image using a vdCurve object

Summary

How can I define a clip-bound on an image using a vdCurve object , the vdCurve can be a vdRect , vdArc , vdCircle , vdPolyline , vdEllipse object.

Solution

Try a code like :
        private void button6_Click(object sender, EventArgs e)
        {
            vdDocument doc = vfc.BaseControl.ActiveDocument;
            doc.Open(@"C:\Users\Administrator\Desktop\DWG & More\test.vdml"); //this drawing conatins an Image and a polyline on it that defines the clip boundary
            doc.CommandAction.Zoom("E",0,0);

            //The curve that clips the image
            vdCurve curve = doc.Model.Entities.Last as vdCurve;
            //The vdImage Object
            vdImage img = doc.Model.Entities[0] as vdImage;


            double mHeight = img.Height;
            double imagescale = mHeight / (double)img.ImageDefinition.Height;

            gPoints pts = curve.GetSamplePoints(0, 0);
            curve.ECSMatrix.Transform(pts);
            img.ECSMatrix.GetInvertion().Transform(pts);

            Matrix mat = new Matrix();
            mat.ScaleMatrix(imagescale, -imagescale, 1.0d);
            mat.TranslateMatrix(0.0d, mHeight, 0.0d);
            mat.Invert();
            mat.Transform(pts);

            img.ClipBoundary = pts;
            img.Update();
        }