Csharp/C#教程:C#使用Matrix执行缩放的方法分享

本文实例讲述了C#使用Matrix执行缩放的方法。分享给大家供大家参考。具体实现方法如下:

usingSystem; usingSystem.Collections.Generic; usingSystem.ComponentModel; usingSystem.Data; usingSystem.Drawing; usingSystem.Text; usingSystem.Windows.Forms; usingSystem.Drawing.Drawing2D; namespaceadvanced_drawing { publicpartialclassForm4:Form { publicForm4() { InitializeComponent(); } privatevoidbutton1_Click(objectsender,EventArgse) { //使用转换将单位设置为英寸 Graphicsg=this.CreateGraphics(); Matrixmatrix=newMatrix(); matrix.Scale(g.DpiX,g.DpiY); g.Transform=matrix; FontrulerFont=newFont("MSSansSerif",8.25f/g.DpiY); PenblackPen=newPen(Color.Black,0); floatrulerFontHeight=rulerFont.GetHeight(g); RectangleFrulerRect=newRectangleF(0,0,6.5f,rulerFontHeight*1.5f); g.DrawRectangle(blackPen,rulerRect.X,rulerRect.Y,rulerRect.Width,rulerRect.Height); Brushbrush=System.Drawing.Brushes.Red; g.DrawString("zhuzhao",rulerFont,brush,rulerRect); } } }

希望本文所述对大家的C#程序设计有所帮助。

您可能感兴趣的文章:PHP+&#106avascript模拟Matrix画面Android变形(Transform)之Matrix用法深入理解AndroidMatrix理论与使用的详解如何使用Matrix对bitmap的旋转与镜像水平垂直翻转Android中利用matrix控制图片的旋转、缩放、移动Android中Matrix用法实例分析Android中使用Matrix控制图形变换和制作倒影效果的方法如何利用matrix实现图片倒影效果

标签: 方法 tr

C++小知识:不要节约代码行数

C语言实现纸牌游戏之小猫钓鱼算法

上述就是C#学习教程:C#使用Matrix执行缩放的方法分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/cdevelopment/907282.html

(0)
上一篇 2021年10月24日
下一篇 2021年10月24日

精彩推荐