DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> HTML基礎知識 >> HTML5教程 >> 實現自己網站的圖片假水印功能
實現自己網站的圖片假水印功能
編輯:HTML5教程     

 --------Web.config----------------
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpHandlers>
<add verb="*" path="images/*.jpg" type="模塊與處理程序.ImageDeal"/>
</httpHandlers>
</system.web>
</configuration>
-------------ImageDeal.cs類-------------------------
namespace 模塊與處理程序
{
public class ImageDeal:IHttpHandler
{
public bool IsReusable
{
get { return true; }
}
public void ProcessRequest(HttpContext context)
{
Image img = Image.FromFile(context.Request.PhysicalPath);
Graphics g = Graphics.FromImage(img);
g.DrawString("QQ", new Font("宋體", 20, FontStyle.Bold), Brushes.Red, 10, 10);
img.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
context.Response.Flush();
context.Response.End();
}
}
}
----------default2.aspx前台------------------------
<body>
<form id="form1" runat="server">
<div>

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="sid" DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="sid" HeaderText="sid" InsertVisible="False"
ReadOnly="True" SortExpression="sid" />
<asp:BoundField DataField="sname" HeaderText="sname" SortExpression="sname" />
<asp:BoundField DataField="sex" HeaderText="sex" SortExpression="sex" />
<asp:BoundField DataField="age" HeaderText="age" SortExpression="age" />
<asp:ImageField DataImageUrlField="photo"
DataImageUrlFormatString="~/images/{0}" HeaderText="照片">
</asp:ImageField>
<asp:HyperLinkField DataNavigateUrlFields="sid,sname"
DataNavigateUrlFormatString="{0}/{1}/viewDetail.html" HeaderText="操作"
Text="查看詳情" />
</Columns>
</asp:GridView>
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:studentConnectionString %>"
SelectCommand="SELECT [sid], [sname], [sex], [age], [photo] FROM [student]">
</asp:SqlDataSource>

</div>
</form>
</body>
-------------default3前台-----------------------
<body>
<form id="form1" runat="server">
<div>
<asp:Image ID="Image1" ImageUrl="http://localhost:1695/images/liubei.jpg" runat="server" />
</div>
</form>
</body>

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved