asp.net in the following code, the text watermark and add the image watermark code can not coexist, in order to facilitate the display before writing in a piece of
private void Btn_upload_click (object sender, System.EventArgs e)
{
if (UploadFile.PostedFile.FileName.Trim ()!= "")
{
Uploading files
string extension = Path.getextension (UploadFile.PostedFile.FileName). ToUpper ();
String fileName = DateTime.Now.ToString ("Yyyymmddhhmmss");
String path = Server.MapPath (".") + "/uploadfile/" + fileName + extension;
UploadFile.PostedFile.SaveAs (path);
Add text watermark, note that the code here and the following image watermark code can not coexist
System.Drawing.Image Image = System.Drawing.Image.FromFile (path);
Graphics g = graphics.fromimage (image);
G.drawimage (image, 0, 0, image. Width, image. Height);
Font f = new Font ("Verdana", 32);
Brush B = new SolidBrush (color.white);
String addtext = AddText.Value.Trim ();
g.DrawString (AddText, F, B, 10, 10);
G.dispose ();
Save the image after the watermark, delete the original picture
String NewPath = Server.MapPath (".") + "/uploadfile/" + fileName + "_new" + extension;
Image. Save (NewPath);
Image. Dispose ();
if (file.exists (path))
{
File.delete (path);
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.