作者: Erase_Liu
查看: 1474|回复: 3

[求助] Graphics 问题

[复制链接]
Erase_Liu 发表于 2016-4-21 10:35:06 | 显示全部楼层 |阅读模式
查看: 1474|回复: 3
[C#] 纯文本查看 复制代码
        public Image getProgress()
        {
            double pro = (double)uploaded / file.Length * 170;
            Bitmap progress = new Bitmap(170, 60);
            Graphics graphics = Graphics.FromImage(progress);
            graphics.Clear(Color.Transparent);// 上面的部分
            graphics.DrawString(this.ToString(), new Font("宋体", 13), Brushes.Red, new PointF(10, 15));
// 下面的部分
            graphics.DrawString(this.ToString(), new Font("黑体", 13), Brushes.Red, new PointF(10, 30));
            graphics.Flush();
            return progress;
        }



为啥换个字体就虚了呢?
怎么才能不虚呢?

对比

对比
回复 论坛版权

使用道具 举报

 楼主| Erase_Liu 发表于 2016-4-21 10:46:24 | 显示全部楼层
[C#] 纯文本查看 复制代码
        public Image getProgress()
        {
            double pro = (double)uploaded / file.Length * 170;
            Bitmap progress = new Bitmap(170, 60);
            Graphics graphics = Graphics.FromImage(progress);
            graphics.Clear(Color.Transparent);
            //graphics.FillRectangle(Brushes.Red, 0, 0, (float)pro, 8f);
            graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
            graphics.DrawString(this.ToString(), new Font("黑体", 7), Brushes.Red, new PointF(10, 1));
            graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
            graphics.DrawString(this.ToString(), new Font("黑体", 7), Brushes.Red, new PointF(10, 10));
            graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
            graphics.DrawString(this.ToString(), new Font("黑体", 7), Brushes.Red, new PointF(10, 20));
            graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixel;
            graphics.DrawString(this.ToString(), new Font("黑体", 7), Brushes.Red, new PointF(10, 30));
            graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
            graphics.DrawString(this.ToString(), new Font("黑体", 7), Brushes.Red, new PointF(10, 40));
            graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault;
            graphics.DrawString(this.ToString(), new Font("黑体", 7), Brushes.Red, new PointF(10, 50));
            graphics.Flush();
            return progress;
        }

已解决!真是已发帖就能早到解决办法!不发一上午都找不到

绘制对比

绘制对比
乔克斯 发表于 2016-4-21 10:51:14 | 显示全部楼层
= =噗。。下次请发到技术求助板块。
 楼主| Erase_Liu 发表于 2016-4-21 13:49:16 | 显示全部楼层
乔克斯 发表于 2016-4-21 10:51
= =噗。。下次请发到技术求助板块。

好的
您需要登录后才可以回帖 登录 | 加入CSkin博客

本版积分规则

QQ|申请友链|小黑屋|手机版|Archiver|CSkin ( 粤ICP备13070794号

Powered by Discuz! X3.2  © 2001-2013 Comsenz Inc.  Designed by ARTERY.cn
GMT+8, 2024-3-28 19:14, Processed in 0.666792 second(s), 34 queries , Gzip On.

快速回复 返回顶部 返回列表