1、设置DPI
Bitmap bitmap2 = new Bitmap((int)w, (int)h); bitmap2.SetResolution(96, 96);
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; }
3、保存绘制的图片
if (saveFileDialog1.ShowDialog() == DialogResult.OK) { this.pictureBox1.Image.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Png); }