Csharp/C#教程:C#实现将像素转换为页面单位的方法分享

本文实例讲述了C#实现将像素转换为页面单位的方法。分享给大家供大家参考。具体实现方法如下:

usingSystem; usingSystem.Collections.Generic; usingSystem.ComponentModel; usingSystem.Data; usingSystem.Drawing; usingSystem.Text; usingSystem.Windows.Forms; usingSystem.Drawing.Drawing2D; namespaceadvanced_drawing { publicpartialclassForm3:Form { publicForm3() { InitializeComponent(); } privatevoidbutton1_Click(objectsender,EventArgse) { Graphicsg=this.CreateGraphics(); g.PageUnit=GraphicsUnit.Inch; g.PageScale=1; PointF[]bottomRight=newPointF[]{newPointF(this.ClientSize.Width,this.ClientSize.Height)}; g.TransformPoints(CoordinateSpace.Page,CoordinateSpace.Device,bottomRight); Rectanglerect=newRectangle(0,0,10,10); Penpen=newPen(Color.Red); g.DrawRectangle(pen,rect); } } }

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

您可能感兴趣的文章:C#简易图片格式转换器实现方法ASP.NET2.0服务器控件之类型转换器C#设置页面单位和缩放的方法C#单位转换器简单案例

标签: 像素 方法

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

C语言实现小猫钓鱼算法

上述就是C#学习教程:C#实现将像素转换为页面单位的方法分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!

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

ctvol管理联系方式QQ:251552304

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

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

精彩推荐