首 页建站教程源码中心网站建设与网上创业处世绝学炫彩Qzong游客留言在线日历QQ诱惑
您当前的位置:海鸿源码网建站教程ASP → 建站内容 退出登录 用户管理
本类热门文章
海鸿源码网推荐
如何上传文件和图片
作者:火舞  来源:本站原创  发布时间:2007-10-24 10:42:22

减小字体 增大字体

<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<html>
<script language="C#" runat=server>
    void UploadBtn_Click(Object sender, EventArgs e) {
        UploadFile.PostedFile.SaveAs(Server.MapPath("chunfeng.jpg"));
        ImageEditor.Visible = true;
      }
     void UpdateBtn_Click(Object sender, EventArgs e) {
        System.Drawing.Image image = System.Drawing.Image.FromFile(Server.MapPath("chunfeng.jpg"));
        System.Drawing.Image newimage = new Bitmap(image.Width, image.Height, PixelFormat.Format32bppRGB);
        Graphics g = Graphics.FromImage(newimage);
        g.DrawImage(image,0,0,image.Width,image.Height);
        Font f = new Font("Lucida Sans Unicode", Int32.Parse(FontSize.SelectedItem.Text));
        Brush b = new SolidBrush(Color.Red);
        g.DrawString(Caption.Text, f, b, 10, 140);
        g.Dispose();
        System.Drawing.Image thumbImage = newimage.GetThumbnailImage(Int32.Parse(Width.Text),Int32.Parse
(Height.Text),null,0);
        image.Dispose();
        thumbImage.Save(Server.MapPath("chunfeng.jpg"), ImageFormat.JPEG);
      }
  </script>
  <body>
    <form enctype="multipart/form-data" runat=server>
          <h3>
          请选择上传文件: <input id="UploadFile" type=file runat=server>
          <asp:button Text="上传文件" OnClick="UploadBtn_Click" runat=server/>
          <hr>
          <asp:panel id="ImageEditor" Visible=false runat=server>
            <img src="chunfeng.jpg">
            <h3>
                图像宽度: <asp:textbox id="Width" runat=server/>
                图像高度: <asp:textbox id="Height" runat=server/> <br>
                文本标题: <asp:textbox id="Caption" runat=server/>
                标题尺寸: <asp:dropdownlist id="FontSize" runat=server>
                                        <asp:listitem>14</asp:listitem>
                                        <asp:listitem>18</asp:listitem>
                                        <asp:listitem>26</asp:listitem>
                                        <asp:listitem>36</asp:listitem>
                                        <asp:listitem>48</asp:listitem>
                                        <asp:listitem>62</asp:listitem>
                                      </asp:dropdownlist>
                <asp:button Text="上传图片" OnClick="UpdateBtn_Click" runat=server/>
            </h3>
          </asp:panel>
      </form>
  </body>
</html
[] [返回上一页] [打 印]
建站评论 (评论内容只代表网友观点,与本站立场无关!)

用户名: 查看更多评论

分 值:100分 85分 70分 55分 40分 25分 10分 0分

内 容:

         (注“”为必填内容。) 验证码: 验证码,看不清楚?请点击刷新验证码

关于本站 - 网站帮助 - 广告合作 - 下载声明 - 友情连接 - 网站地图 -