usingSystem;usingSystem.Collections;usingSystem.Configuration;usingSystem.Data;usingsystem.web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.HtmlControls;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.WebControls.WebParts;usingSystem.Drawing;namespaceweb_picturewatermark{ Public Partial class_default:system.web.ui.page {protected voidPage_Load (Objectsender, EventArgs e) { This. Imgsource.imageurl =@"~/image/bear.bmp"; } //Picture Overlay protected voidBtn_watermark_click (Objectsender, EventArgs e) { stringPath = Server.MapPath (@"image/bear.bmp"); System.Drawing.Image imgsrc=System.Drawing.Image.FromFile (path); System.Drawing.Image Imgwarter= System.Drawing.Image.FromFile (Server.MapPath (@"image/water.bmp")); using(Graphics g =graphics.fromimage (IMGSRC)) {G.drawimage (Imgwarter,NewRectangle (Imgsrc.width-Imgwarter.width, Imgsrc.height-Imgwarter.height, Imgwarter.width, Imgwarter.height),0,0, Imgwarter.width, Imgwarter.height, GraphicsUnit.Pixel); } stringNewPath = Server.MapPath (@"image/watermark.bmp"); Imgsrc.save (NewPath, System.Drawing.Imaging.ImageFormat.Jpeg); This. Image_water.imageurl =@"~/image/watermark.bmp"; } //Picture Writing protected voidBtn_fontmark_click (Objectsender, EventArgs e) { stringPath = Server.MapPath (@"image/bear.bmp"); System.Drawing.Image imgsrc=System.Drawing.Image.FromFile (path); using(Graphics g =graphics.fromimage (IMGSRC)) {G.drawimage (IMGSRC,0,0, Imgsrc.width, imgsrc.height); using(Font f=NewFont ("Song Body", -)) { using(Brush B =NewSolidBrush (color.red)) { stringAddText ="I 'm in charge of my turf."; g.DrawString (AddText, F, B, -, -); } } } stringFontpath = Server.MapPath (@"image/fontmark.bmp"); Imgsrc.save (Fontpath, SYSTEM.DRAWING.IMAGING.IMAGEFORMAT.BMP); This. Image_font.imageurl =@"~/image/fontmark.bmp"; } }}
————————————————————————————————————————————————————————————————————————————————————————————————————————
After uploading the image, you can upload the image above the URL of their site, or the watermark image of their own web site superimposed on the uploaded image to achieve the effect of the watermark.
The implementation of the C # GUI is simply too easy and the code is as follows:
. Page HTML code:
<%@ Page Language="C #"AutoEventWireup="true"codebehind="Default.aspx.cs"Inherits="Web_picturewatermark._default" %><!DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd "><HTMLxmlns= "http://www.w3.org/1999/xhtml" ><Headrunat= "Server"> <title>ASP. NET C # for pictures and watermarks</title></Head><Body> <formID= "Form1"runat= "Server"> <Div> <Asp:imageID= "Imgsource"runat= "Server"IMAGEURL= "~/image/bear.bmp" /> </Div> <Div> <Asp:buttonID= "Btn_watermark"runat= "Server"Text= "Add watermark effect to picture"onclick= "Btn_watermark_click" /> <Asp:buttonID= "Btn_fontmark"runat= "Server"Text= "Add text effect to picture"onclick= "Btn_fontmark_click" /> </Div> <Divstyle= "width:410px; float:left; margin:0px;"> <Asp:imageID= "Image_water"runat= "Server" /> </Div> <Divstyle= "width:410px; float:left; margin:0px;"> <Asp:imageID= "Image_font"runat= "Server" /> </Div> </form></Body></HTML>
C # GDI + simple implementation of picture write text and picture overlay (watermark) (GO)