图像显示时加入水印文字效果[转]

shuiyin.aspx
                  *******************************
                  <%@ Page Language="vb" AutoEventWireup="false"
                  Codebehind="shuiyin.aspx.vb" Inherits="Test.shuiyin"%>
                  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

                  <HTML>
                   <HEAD>
                    <title>shuiyin</title>
                    <meta content="Microsoft Visual Studio .NET
                  7.1">
                    <meta content="Visual Basic .NET 7.1">
                    <meta content="JavaScript">
                    <meta
                  content="http://schemas.microsoft.com/intellisense/ie5">
                   </HEAD>
                   <body MS_POSITIONING="FlowLayout">
                    <form method="post" runat="server">
                     <FONT face="宋体">
                      <asp:TextBox runat="server"></asp:TextBox>
                      <asp:Button runat="server"
                  Text="Button"></asp:Button><BR>
                     </FONT>
                    </form>
                   </body>
                  </HTML>


                  shuiyin.aspx.vb
                  ***************************
                  Public Class shuiyin
                      Inherits System.Web.UI.Page

                  #Region " Web 窗体设计器生成的代码 "

                      ’该调用是 Web 窗体设计器所必需的。
                      <System.Diagnostics.DebuggerStepThrough()> Private Sub
                  InitializeComponent()

                      End Sub
                      Protected WithEvents txtPath As
                  System.Web.UI.WebControls.TextBox
                      Protected WithEvents Button1 As
                  System.Web.UI.WebControls.Button

                      ’注意: 以下占位符声明是 Web 窗体设计器所必需的。
                      ’不要删除或移动它。
                      Private designerPlaceholderDeclaration As System.Object

                      Private Sub Page_Init(ByVal sender As System.Object, ByVal
                  e As System.EventArgs) Handles MyBase.Init
                          ’CODEGEN: 此方法调用是 Web 窗体设计器所必需的
                          ’不要使用代码编辑器修改它。
                          InitializeComponent()
                      End Sub

                  #End Region

                      Private Sub Page_Load(ByVal sender As System.Object, ByVal
                  e As System.EventArgs) Handles MyBase.Load
                          ’在此处放置初始化页的用户代码
                      End Sub

                      Private Sub Button1_Click(ByVal sender As System.Object,
                  ByVal e As System.EventArgs) Handles Button1.Click

                          Dim FilePath As String = Server.MapPath(txtPath.Text)
                          Dim image As System.Drawing.Image =
                  System.Drawing.Image.FromFile(FilePath)
                          Dim g As Graphics = Graphics.FromImage(image)
                          g.DrawImage(image, 0, 0, image.Width, image.Height)
                          Dim f As Font = New Font("华文行楷", 30)
                          Dim b As Brush = New SolidBrush(Color.Red)
                          Dim s As String = "索网图片"
                          g.DrawString(s, f, b, 20, 20)
                          image.Save(Response.OutputStream,
                  System.Drawing.Imaging.ImageFormat.Jpeg)
                          g.Dispose()
                          image.Dispose()                           
                      End Sub
                  End Class

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值