当图像尺寸增加或减少时,水印图像会自动增加或减少。 我想修复此水印大小和字符串大小,我的水印图像在小像素图像中太大,如果像素像2000 X 1222图像,并且文本变小。我希望将文本和图像固定在恒定大小的图像上。这是我的代码
System.Drawing.Image img1 = System.Drawing.Image.FromFile(MapPath("images/" + Path.GetFileName(_HttpPostedFile.FileName)));
System.Drawing.Image img2 = System.Drawing.Image.FromFile(MapPath("~/images/abc[enter image description here][1].png"));[enter image description here][1]
Graphics g = Graphics.FromImage(img1);
float width = ((img1.Width / 2) - (img2.Width / 2));
float height = (img1.Height/2) - (img2.Height/2);
g.DrawImage(img2,width, height);
g.DrawString(Username, new Font("arial", 100,
FontStyle.Bold), new SolidBrush(System.Drawing.ColorTranslator.FromHtml("#FFFFFF")), new Point(Convert.ToInt32(width)-20, img1.Height-300),new StringFormat());
g.DrawString(contact, new Font("arial", 100,FontStyle.Bold), new SolidBrush(System.Drawing.ColorTranslator.FromHtml("#FFFFFF")), new Point(Convert.ToInt32(width) , img1.Height - 200),new StringFormat());
img1.Save(Server.MapPath("Watermark_Images/" + Path.GetFileName(_HttpPostedFile.FileName)));