本文整理匯總了C#中Canvas.Translate方法的典型用法代碼示例。如果您正苦於以下問題:C# Canvas.Translate方法的具體用法?C# Canvas.Translate怎麽用?C# Canvas.Translate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Canvas
的用法示例。
在下文中一共展示了Canvas.Translate方法的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;
}