C#使用Matrix执行缩放的方法
程序员文章站
2022-07-22 20:35:41
本文实例讲述了c#使用matrix执行缩放的方法。分享给大家供大家参考。具体实现方法如下:
using system;
using system.collect...
本文实例讲述了c#使用matrix执行缩放的方法。分享给大家供大家参考。具体实现方法如下:
using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.text; using system.windows.forms; using system.drawing.drawing2d; namespace advanced_drawing { public partial class form4 : form { public form4() { initializecomponent(); } private void button1_click(object sender, eventargs e) { //使用转换将单位设置为英寸 graphics g=this.creategraphics(); matrix matrix = new matrix(); matrix.scale(g.dpix, g.dpiy); g.transform = matrix; font rulerfont = new font("ms sans serif", 8.25f / g.dpiy); pen blackpen=new pen(color.black,0); float rulerfontheight = rulerfont.getheight(g); rectanglef rulerrect = new rectanglef(0, 0, 6.5f, rulerfontheight * 1.5f); g.drawrectangle(blackpen, rulerrect.x, rulerrect.y, rulerrect.width, rulerrect.height); brush brush = system.drawing.brushes.red; g.drawstring("zhuzhao", rulerfont, brush, rulerrect); } } }
希望本文所述对大家的c#程序设计有所帮助。