当前位置: 首页>>代码示例>>C#>>正文


C# System.Drawing.Drawing2D.Matrix.Shear方法代码示例

本文整理汇总了C#中System.Drawing.Drawing2D.Matrix.Shear方法的典型用法代码示例。如果您正苦于以下问题:C# System.Drawing.Drawing2D.Matrix.Shear方法的具体用法?C# System.Drawing.Drawing2D.Matrix.Shear怎么用?C# System.Drawing.Drawing2D.Matrix.Shear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Drawing.Drawing2D.Matrix的用法示例。


在下文中一共展示了System.Drawing.Drawing2D.Matrix.Shear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestAffineTransform2D

            public void TestAffineTransform2D()
            {
                //Setup some affine transformation
                System.Drawing.Drawing2D.Matrix matrix = new System.Drawing.Drawing2D.Matrix();
                matrix.RotateAt(30, new System.Drawing.PointF(0, 0));
                matrix.Translate(-20, -20, System.Drawing.Drawing2D.MatrixOrder.Append);
                matrix.Shear(0.95f, -0.2f, System.Drawing.Drawing2D.MatrixOrder.Append);

                //Create some random sample data
                CreatingData cd = new CreatingData();
                SharpMap.Data.FeatureDataTable fdt1 =
                cd.CreatePointFeatureDataTableFromArrays(GetRandomOrdinates(80, -180, 180),
                                                         GetRandomOrdinates(80, -90, 90), null);

                //Clone random sample data and apply affine transformation on it
                SharpMap.Data.FeatureDataTable fdt2 = TransformedFeatureDataTable(matrix, fdt1);

                //Get affine transformation with LeastSquaresTransform
                SharpMap.Utilities.LeastSquaresTransform lst = new SharpMap.Utilities.LeastSquaresTransform();

                //Add at least three corresponding points
                lst.AddInputOutputPoint(
                ((SharpMap.Data.FeatureDataRow)fdt1.Rows[0]).Geometry as SharpMap.Geometries.Point,
                ((SharpMap.Data.FeatureDataRow)fdt2.Rows[0]).Geometry as SharpMap.Geometries.Point);

                lst.AddInputOutputPoint(
                ((SharpMap.Data.FeatureDataRow)fdt1.Rows[39]).Geometry as SharpMap.Geometries.Point,
                ((SharpMap.Data.FeatureDataRow)fdt2.Rows[39]).Geometry as SharpMap.Geometries.Point);

                lst.AddInputOutputPoint(
                ((SharpMap.Data.FeatureDataRow)fdt1.Rows[79]).Geometry as SharpMap.Geometries.Point,
                ((SharpMap.Data.FeatureDataRow)fdt2.Rows[79]).Geometry as SharpMap.Geometries.Point);

                /*
                //Get affine transformation calculates mean points to improve accuaracy
                //Unfortunately the result is not very good, so, since I know better I manually set these
                //mean points.
                lst.SetMeanPoints(new SharpMap.Geometries.Point(0, 0),
                              new SharpMap.Geometries.Point(matrix.OffsetX, matrix.OffsetY));
                 */

                //Create Affine
                AffineCoordinateTransformation2D at2 = new AffineCoordinateTransformation2D(lst.GetAffineTransformation());

                //Create Map
                SharpMap.Map map = new SharpMap.Map(new System.Drawing.Size(720, 360));

                //Add not transformed layer
                map.Layers.Add(new SharpMap.Layers.VectorLayer("L1",
                                                           new SharpMap.Data.Providers.GeometryFeatureProvider(fdt1)));
                ((SharpMap.Layers.VectorLayer) map.Layers[0]).Style.Symbol =
                new System.Drawing.Bitmap(@"..\..\..\DemoWinForm\Resources\flag.png");

                //Add transformed layer
                map.Layers.Add(new SharpMap.Layers.VectorLayer("L2",
                                                           new SharpMap.Data.Providers.GeometryFeatureProvider(fdt2)));
                ((SharpMap.Layers.VectorLayer) map.Layers[1]).Style.Symbol =
                new System.Drawing.Bitmap(@"..\..\..\DemoWinForm\Resources\women.png");

                //Render map
                map.ZoomToExtents();

                //Get map and save to file
                var bmp = (System.Drawing.Bitmap)map.GetMap();
                bmp.Save("affinetransform1.bmp");

                //we want to reverse the previously applied transformation.
                ((SharpMap.Layers.VectorLayer) map.Layers[1]).CoordinateTransformation = (AffineCoordinateTransformation2D)at2.Inverse();

                //Render map
                map.ZoomToExtents();

                //Get map and save to file
                bmp = (System.Drawing.Bitmap)map.GetMap();
                bmp.Save("affinetransform2.bmp");
                //Hopefully women cover flags ;-).
            }
开发者ID:PedroMaitan,项目名称:sharpmap,代码行数:77,代码来源:ProjectionExamples.cs


注:本文中的System.Drawing.Drawing2D.Matrix.Shear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。