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


C# Canvas.Scale方法代码示例

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


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

示例1: ToBitmap

        public static System.Drawing.Bitmap ToBitmap(this UniversalEditor.ObjectModels.Multimedia3D.Model.ModelObjectModel model, int width, int height, UniversalEditor.ObjectModels.Multimedia3D.Pose.PoseObjectModel pose)
        {
            System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(width, height);
            System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap);
            graphics.Clear(System.Drawing.Color.Black);

            IntPtr hdc = graphics.GetHdc();

            Canvas canvas = new Canvas(hdc, bitmap.PixelFormat);

            canvas.MakeCurrent();
            canvas.Matrix.Mode = MatrixMode.Projection;
            canvas.Matrix.Reset();

            Internal.GLU.Methods.gluPerspective(45.0, 640 / 480, 0.0, 45.0);

            canvas.EnableDepthTesting = true;
            canvas.EnableNormalization = true;
            canvas.EnableTexturing = true;

            Internal.OpenGL.Methods.glTexEnv(Internal.OpenGL.Constants.TextureEnvironmentTarget.TextureEnvironment, Internal.OpenGL.Constants.TextureEnvironmentParameterName.TextureEnvironmentMode, Internal.OpenGL.Constants.TextureEnvironmentParameterValue.Modulate);

            canvas.CullingMode = CullingMode.Front;

            canvas.EnableBlending = true;
            Internal.OpenGL.Methods.glBlendFunc(Internal.OpenGL.Constants.GLBlendFunc.SourceAlpha, Internal.OpenGL.Constants.GLBlendFunc.OneMinusSourceAlpha);

            Internal.OpenGL.Methods.glEnable(Internal.OpenGL.Constants.GLCapabilities.AlphaTesting);
            Internal.OpenGL.Methods.glAlphaFunc(Internal.OpenGL.Constants.GLAlphaFunc.GreaterOrEqual, 0.05f);

            World.Lights[0].Position = new PositionVector4(0.45f, 1.45f, -4.0f, 0.0f);
            World.Lights[0].DiffuseColor = Color.FromRGBA(0.9f, 0.9f, 0.9f, 1.0f);
            World.Lights[0].AmbientColor = Color.FromRGBA(0.7f, 0.7f, 0.7f, 1.0f);
            World.Lights[0].SpecularColor = Color.FromRGBA(0.7f, 0.7f, 0.7f, 1.0f);
            World.Lights[0].Enabled = true;

            canvas.Matrix.Mode = MatrixMode.Projection;
            canvas.Reset();
            canvas.Translate(0.0, -1, 0.5);
            canvas.Scale(0.05, 0.08, 0.1);

            canvas.Matrix.Mode = MatrixMode.ModelView;
            canvas.DrawModel(model);

            graphics.ReleaseHdc();
            graphics.Flush();

            bitmap.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipX);

            if (pose != null)
            {
            }

            return bitmap;
        }
开发者ID:Narinyir,项目名称:Sanjigen,代码行数:55,代码来源:ExtensionMethods.cs


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