社区
C#
帖子详情
DrawString(string s, Font font, Brush brush, float x, float y); 坐标单位是像素吗
大韩
2017-12-30 09:56:36
一个打印证书程序,请问 float x , float y ,是像素单位吗?,如果是,那么和打印纸单位mm,怎么进行换算方法更合适
DrawString(string s, Font font, Brush brush, float x, float y);
...全文
812
4
打赏
收藏
DrawString(string s, Font font, Brush brush, float x, float y); 坐标单位是像素吗
一个打印证书程序,请问 float x , float y ,是像素单位吗?,如果是,那么和打印纸单位mm,怎么进行换算方法更合适 DrawString(string s, Font font, Brush brush, float x, float y);
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
4 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
秋的红果实
2018-01-01
打赏
举报
回复
计算机里面的单位,默认都是像素,像素和长度单位的换算,要通过分辨率来转换 .NET已经封装了这些,请搜索pageunit
xuzuning
2017-12-31
打赏
举报
回复
是的,默认是像素 但你可以通过指定 Graphics 的 PageScale 属性改变 比如设置成毫米 Graphics g = e.Graphics; g.PageScale = (float)GraphicsUnit.Millimeter; 虽然浮点的像素最终会化为整数,但在计算中意义是很大的,因为画布也有缩放比例可以调整
Luskyle
2017-12-31
打赏
举报
回复
楼上正解,,
threenewbee
2017-12-30
打赏
举报
回复
取决于你的单位的设置 graphics.PageUnit https://msdn.microsoft.com/zh-cn/library/fwb00wkk(VS.80).aspx 不过请记住,如果是像素的话,小数点是没有意义的。
C#利用GDI+绘制旋转文字
public void
Draw
String
(
string
s,
Font
font
,
Brush
brush
, RectangleF layoutRectangle,
String
Format format,
float
angle) { // 求取字符串大小 SizeF size = _graphics.Measure
String
(s,
font
); // 根据...
c#拆线图可根据业务修改
g.
Draw
String
(myLabel, axes
Font
, black
Brush
, x - 4, y + 10); g.
Draw
Line(blackPen, x, y + 2, x, y - 2); } // 绘制Y轴标签 for (int i = 0; i ; i++) {
float
x = ChartInset;
float
y = ChartHeight + ...
C#绘制验证码噪点源码(十分经典)
graphics.
Draw
String
(c.To
String
(),
font
,
brush
, x, y); x +=
font
Size * 1.5; // 调整字符间的距离 } ``` 噪点的添加是验证码中常见的干扰元素,用于增强安全性。在C#中,我们可以用`FillEllipse`方法在画布上...
C#绘制验证码噪点源码.rar
graphics.
Draw
String
(captchaCode[i].To
String
(),
font
,
Brush
es.Black, 0, 0); graphics.ResetTransform(); }
font
.Dispose(); ``` 6. **保存或显示验证码**:完成绘制后,可以选择将图像保存到文件,或者直接...
C#利用GDI+绘制旋转文字等效果实例
1. `
Draw
String
(
string
s,
Font
font
,
Brush
brush
, RectangleF layoutRectangle,
String
Format format,
float
angle)` 方法接收一个矩形区域、文本、字体、填充刷、布局格式和旋转角度作为参数。首先,它测量文本的...
C#
111,092
社区成员
642,554
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章