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); }