网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > C/C++
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
本月文章推荐
.用C语言解决鬼谷算题.
.CGI脚本入门学习.
.ListBox自画的另一种效果.
.C++运算符重载转换运算符.
.C宏--智者的利刃,愚者的恶梦.
.容易理解魔方阵源程序.
.8 Quen.
.C++ 中不规则窗体的快速显示.
.C++ Builder初学问与答(十四).
.Windows Sockets:使用 CAsyncSo.
.解析C语言中的sizeof.
.编译器对标准库优化小测试.
.C++箴言:通过composition模拟“.
.main函数的参数.
.开发 C++ Builder&nbs.
.设计OutLook风格的工具栏.
.把其它程序(如网页等)的文字拖放.
.C语言库函数(V类字母).
.这些样式表,你都用过么?.
.C++中类的数据成员的安全隐患.

如何在上传的图片上写字

发表日期:2008-3-8


很多时候需要在用户上传的图片上加上版权或者一些其他的附加文字信息,如何实现这样的功能,下面帖个简单实现的例子,起到抛砖引玉的作用。
<%@ Page Language="c#" Debug="true" Trace="true"%>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<Html>
<script runat =server>
      void UploadBTn_Click(Object sender, EventArgs e) {
        String filename;
        String filename1;
        String[] filename2;
        int q;
        filename=UploadFile.PostedFile.FileName ;
        filename2=filename.Split(new Char[] {'\\'});
        q=filename2.GetUpperBound(0);
        filename1=filename2[q];
        dis.Text="上传文件名:"+filename1+"<br>";
        UploadFile.PostedFile.SaveAs(Server.MapPath(filename1));
        ImageEditor.Visible = true;
        dis.Text+="文件大小:"+UploadFile.PostedFile.ContentLength+"字节数";
        Image1.Src=filename1;     
      }
      void UpdateBtn_Click(Object sender, EventArgs e) {
        String filename1;
        filename1=Image1.Src;
        System.Drawing.Image image = System.Drawing.Image.FromFile(Server.MapPath(filename1));
        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(FontType.SelectedItem.Text, 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(filename1), ImageFormat.JPEG);

        Image1.Src=filename1;     
        Caption.Text="";   
 
      }   </script>   <body>
  <ASP:label id="dis" runat=server/>
    <form enctype="multipart/form-data" runat=server>
          选择上传文件: <input id="UploadFile" type=file runat=server>
          <asp:button Text="Upload Me!" OnClick="UploadBtn_Click" runat=server/>
          <hr>
          <asp:panel id="ImageEditor" Visible=false runat=server>
            <img ID="Image1" src="" runat="server"/>
                图像宽度: <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:dropdownlist id="FontType" runat=server>
                                        <asp:listitem>黑体</asp:listitem>
                                        <asp:listitem>仿宋</asp:listitem>
                                        <asp:listitem>隶书</asp:listitem>
                                        <asp:listitem>楷书</asp:listitem>
                                        <asp:listitem>彩云</asp:listitem>
                                        <asp:listitem>新魏</asp:listitem>
                                      </asp:dropdownlist>
                                               
                <asp:button Text="Update Image" OnClick="UpdateBtn_Click" runat=server/>

          </asp:panel>
      </form>   </body>
</html>

上一篇:汇编语言的高级语言特性 人气:561
下一篇:Java进阶:JNI使用技巧点滴 人气:551
浏览全部C/C++的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐