<% @ Page Language = "C #" autoeventwireup = "true" codefile = "default. aspx. cs" inherits = "_ default" %> <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <HTML xmlns = "http://www.w3.org/1999/xhtml">
View plain
Copy to clipboard
Print
?
- Using system;
- Using system. Data;
- Using system. configuration;
- Using system. Web;
- Using system. Web. Security;
- Using system. Web. UI;
- Using system. Web. UI. webcontrols;
- Using system. Web. UI. webcontrols. webparts;
- Using system. Web. UI. htmlcontrols;
- Using system. drawing;
- Public partial class _ default: system. Web. UI. Page
- {
- Protected void page_load (Object sender, eventargs E)
- {
- }
- Protected void button#click (Object sender, eventargs E)
- {
- String filename = fileupload1.filename;
- String nowpath = server. mappath (".") + "\\";
- Filename = nowpath + filename;
- // Save the source Image
- Fileupload1.saveas (filename );
- System. Drawing. Image image, newimage, syimage;
- System. Drawing. image. getthumbnailimageabort callb = NULL;
- Image = system. Drawing. image. fromfile (filename );
- Syimage = system. drawing. image. fromfile (server. mappath (". ") +" \ "+" .gif "); // to place a" .gif "file under the directory, you can download from the Internet: http://www.baidu.com/img/baidu.gif
- // Save the thumbnail
- Newimage = image. getthumbnailimage (100,100, callb, new intptr ());
- Newimage. Save (filename + ".w.tu.png ");
- Newimage. Dispose ();
- // Process the original image
- Graphics G = graphics. fromimage (image );
- Font F = new font ("", 16 );
- Brush B = new solidbrush (colortranslator. fromhtml ("# ff0000 "));
- String addtext = "text watermark content ";
- G. drawstring (addtext, F, B, 10, 10 );
- G. drawimageunscaled (syimage, 50, 50 );
- // G. drawimage (newimage, 50, 50, 100,100 );
- G. Dispose ();
- // Generate a watermark image
- Image. Save (filename + ". .png ");
- Image. Dispose ();
- Syimage. Dispose ();
- Image1.imageurl = fileupload1.filename;
- Image2.imageurl = fileupload1.filename + ". .png ";
- Image3.imageurl = fileupload1.filename + ". .png ";
- }
- }