Simple code, record to prevent forgetting.
The implementation process is similar to the Verification code generation process.
Public void savephoneimg (string phone, string path) {system. drawing. bitmap image = new system. drawing. bitmap (135, 25); graphics G = graphics. fromimage (image); try {Font font = new system. drawing. font ("", 15, (system. drawing. fontstyle. bold); system. drawing. drawing2d. lineargradientbrush brush = new system. drawing. drawing2d. lineargradientbrush (New rectangle (5, 5, image. width, image. height), color. black, color. black, 1.2f, true); G. drawstring (phone, Font, brush, 2, 0); // draw the border line G of the image. drawrectangle (new pen (color. silver), 0, 0, image. width-1, image. height-1); system. io. filestream MS = new system. io. filestream (path, filemode. create); image. save (MS, system. drawing. imaging. imageformat. PNG);} finally {G. dispose (); image. dispose ();}}
Code