c#图片上写字

来源:互联网 发布:打印软件下载 编辑:程序博客网 时间:2024/05/16 23:56

这里试了抗锯齿的效果,不过没发现多大区别,因为字体本身不模糊,之前绘制的字体比较模糊。

          //合成图片            Bitmap bpall = new Bitmap(1000, 1100);//局部大小            System.Drawing.Pen myPen = new System.Drawing.Pen(System.Drawing.Color.Red);//画笔            System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);//画刷            Font myFont = new Font("宋体", 100, GraphicsUnit.Pixel);            Graphics g1 = Graphics.FromImage(bpall);            Bitmap bpidenti = new Bitmap(1000, 1000);            System.IO.FileStream fs = new System.IO.FileStream("Chrysanthemum.jpg", System.IO.FileMode.Open, System.IO.FileAccess.Read);            bpidenti = (System.Drawing.Bitmap)Bitmap.FromStream(fs);            fs.Close();            g1.DrawImage(bpidenti,//原图             new Rectangle(new Point(0, 0), new Size(1000, 1000)),//目标位置              new Rectangle(new Point(0, 0), bpidenti.Size),//原图位置              GraphicsUnit.Pixel);            g1.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;//抗锯齿            //g1.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixel;            g1.DrawString("现场人像", myFont, myBrush, new PointF(20, 1000));                      myPen.Dispose();            myBrush.Dispose();            pictureBox2.Image = bpall;


0 0
原创粉丝点击