C#:绘图问题

 

1、设置DPI

Bitmap bitmap2 = new Bitmap((int)w, (int)h);
bitmap2.SetResolution(96, 96);
View Code

2、设置Graphic(如:去锯齿等)

        private Graphics GetG(Bitmap bitmap)
        {
            Graphics g = Graphics.FromImage(bitmap);
            //设置高质量插值法
            g.InterpolationMode = InterpolationMode.HighQualityBicubic;
            //如何将图片覆盖到G
            g.CompositingMode = CompositingMode.SourceOver;
            //图片呈现质量
            g.CompositingQuality = CompositingQuality.HighQuality;
            //文字抗锯齿
            g.TextRenderingHint = TextRenderingHint.AntiAlias;
            //设置高质量,低速度呈现平滑程度
            g.SmoothingMode = SmoothingMode.AntiAlias;
            //设置背景颜色
            g.Clear(Color.White);

            return g;
        }
View Code

3、保存绘制的图片

if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                this.pictureBox1.Image.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Png);
            }
View Code

 

posted @ 2016-06-16 10:05  慧由心生  阅读(546)  评论(0编辑  收藏  举报