این کدی که برای واترمارک استفاده میکنم بعد از واترمارک میاد تصویر رو دانلود میکنه من میخوام بعد از واتر مارک تصویر رو ذخیره کنه جای تصویر قبلی یعنی یه جورهایی روی تصویری که واترمارک شده ذخبره کنه
string jpg1 = Server.MapPath("/NewFolder1/Untitled.png"); string watermarkText = "© Barnamenevisan.Org"; //Get the file name. string fileName = Path.GetFileNameWithoutExtension(jpg1) + ".png"; //Read the File into a Bitmap. using (Bitmap bmp = new Bitmap(jpg1, false)) { using (Graphics grp = Graphics.FromImage(bmp)) { //Set the Color of the Watermark text. Brush brush = new SolidBrush(Color.Red); //Set the Font and its size. Font font = new System.Drawing.Font("Arial", 30, FontStyle.Bold, GraphicsUnit.Pixel); //Determine the size of the Watermark text. SizeF textSize = new SizeF(); textSize = grp.MeasureString(watermarkText, font); //Position the text and draw it on the image. Point position = new Point((bmp.Width - ((int)textSize.Width + 10)), (bmp.Height - ((int)textSize.Height + 10))); grp.DrawString(watermarkText, font, brush, position); using (MemoryStream memoryStream = new MemoryStream()) { //Save the Watermarked image to the MemoryStream. bmp.Save(memoryStream, ImageFormat.Png); bmp.Dispose(); memoryStream.Position = 0; //Start file download. Response.Clear(); Response.ContentType = "image/png"; Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName); //Write the MemoryStream to the Response. memoryStream.WriteTo(Response.OutputStream); Response.Flush(); Response.Close(); Response.End(); } } }
با سلام خدمت شما
برای این کار ، خط 27 تا 46 رو پاک کنید و کد زیر رو قرار بدید
bmp.Save(fileName);
دوتا سوال برام پیش اومد
1-آیا میشه متن مورد نظر کم رنگ و پررنگش کرد یعنی Opacity اون رو تنظیم کرد؟
2-به فیلد داخل جدول دارم که رنگ واترمارک هست حالا چه چور به جای خط زیر قرار بدم؟
Brush brush = new SolidBrush(Color.Red);
هیچ کاربری تا کنون از این پست تشکر نکرده است
با ما تماس بگیرید تا در این مسیر همراهتان باشیم :)