国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > 綜合 > 正文

如何在上傳的圖片上加上版權文字

2024-07-21 02:24:04
字體:
來源:轉載
供稿:網(wǎng)友
  • 本文來源于網(wǎng)頁設計愛好者web開發(fā)社區(qū)http://www.html.org.cn收集整理,歡迎訪問。


  • 很多時候需要在用戶上傳的圖片上加上版權或者一些其他的附加文字信息,如何實現(xiàn)這樣的功能,下面帖個簡單實現(xiàn)的例子,起到拋磚引玉的作用。
    <%@ 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+"字節(jié)數(shù)";
            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>



    很多時候需要在用戶上傳的圖片上加上版權或者一些其他的附加文字信息,如何實現(xiàn)這樣的功能,下面帖個簡單實現(xiàn)的例子,起到拋磚引玉的作用。
    <%@ 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+"字節(jié)數(shù)";
            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>



    發(fā)表評論 共有條評論
    用戶名: 密碼:
    驗證碼: 匿名發(fā)表
    主站蜘蛛池模板: 和顺县| 阿坝县| 乌什县| 永丰县| 林周县| 中宁县| 南皮县| 信阳市| 雷山县| 双城市| 罗江县| 花莲市| 吴川市| 灵台县| 三都| 嵊州市| 贡嘎县| 沙坪坝区| 阿鲁科尔沁旗| 和平区| 柞水县| 鹤峰县| 阿拉善盟| 台北县| 鄂州市| 丰原市| 牙克石市| 龙川县| 泾源县| 连城县| 张家港市| 陵川县| 海门市| 阳新县| 临颍县| 措美县| 二连浩特市| 思茅市| 左云县| 孝感市| 美姑县|