1. Watermark
1. Canvas
System.Drawing.Image img = System.Drawing.Image.FromStream(FileUpload1.FileContent);
2. Create a drawing object and tell it which picture to draw on
Graphics g = Graphics.FromImage(img);
3. Drawing content
string s = <a href="http://www.php.cn">www.php.cn</a>;
4 . Drawing font
Font f = new Font("黑体",130);
5. Drawing brush
Brush b = new SolidBrush(Color.Red);
6. Start drawing
g.DrawString(s, f, b, 5, 5);
2. Picture verification code
Bitmap bit = new Bitmap(90, 40);//画布大小 Graphics g = Graphics.FromImage(bit);//创建绘制对象,告诉它往哪张图片上绘制 Random r = new Random(); string s = ""; Color color1 = Color.FromArgb(r.Next(155, 255), r.Next(155, 255), r.Next(155, 255)); g.FillRectangle(new SolidBrush(color1), 0, 0, 90, 40);//画布颜色随机 for (int i = 0; i < 10; i++)//随机画干扰线 { Color color3 = Color.FromArgb(r.Next(170, 255), r.Next(190, 255), r.Next(170, 255)); Pen pp = new Pen(new SolidBrush(color3), r.Next(0, 5)); g.DrawLine(pp, r.Next(0, 90), r.Next(0, 40), r.Next(0, 90), r.Next(0, 40)); } string yan = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";//设置随机的验证码,从里面抽取 int wei = 0; for (int i = 0; i < 4; i++)//取四位验证码,颜色随机 { string m = yan.Substring(r.Next(0, yan.Length), 1); s += m; Color color2 = Color.FromArgb(r.Next(0, 155), r.Next(0, 155), r.Next(0, 155)); int w = r.Next(20, 25); Font f = new Font("黑体", w); SolidBrush b = new SolidBrush(color2); g.DrawString(m, f, b, wei, r.Next(0, 10)); wei += w; } Session["YZM"] = s;//把验证码保存到session中 for (int i = 0; i < 251; i++) { Color color3 = Color.FromArgb(r.Next(0, 255), r.Next(0, 255), r.Next(0, 255)); Pen pp = new Pen(new SolidBrush(color3), r.Next(0, 5)); int a = r.Next(0, 90); int b = r.Next(0, 40); g.DrawLine(pp, a, b, (a + 1), (b + 1)); } bit.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg); Response.End();
Verification code:
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox> <asp:Image ID="Image1" runat="server" ImageUrl="Default2.aspx" />//这里图片路径不是一张图片的话会默认打开
The above is the watermark and image verification code for Web front-end development shared by the editor. I hope it will be helpful to everyone

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

SublimeText3 English version
Recommended: Win version, supports code prompts!

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.