打开APP
未登录
开通VIP,畅享免费电子书等14项超值服
开通VIP
首页
好书
留言交流
下载APP
联系客服
c#使用Matrix执行缩放
hxdou
>《GDI》
2012.07.31
关注
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);
}
}
}
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报
。
打开APP,阅读全文并永久保存
查看更多类似文章
猜你喜欢
类似文章
【热】
打开小程序,算一算2024你的财运
C#winform圆角窗体绘制
实现C#打印窗体实例详解
C#使用Stateless和箭头控件实现状态机的控制及显示
WinForm(C#)自定义控件之
[转载]怎样画水墨竹之二:画竹枝法
在C#中实现listbox的项上下移动(winform)
更多类似文章 >>
生活服务
热点新闻
留言交流
回顶部
联系我们
分享
收藏
点击这里,查看已保存的文章
导长图
关注
一键复制
下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!
联系客服
微信登录中...
请勿关闭此页面
先别划走!
送你5元优惠券,购买VIP限时立减!
5
元
优惠券
优惠券还有
10:00
过期
马上使用
×