<%@PageLanguage="c#"Debug="true"Trace="true"%> <%@ImportNamespace="System.IO"%> <%@ImportNamespace="System.Drawing"%> <%@ImportNamespace="System.Drawing.Imaging"%> <html> <scriptrunat=server> voidUploadBtn_Click(Objectsender,EventArgse){ Stringfilename; Stringfilename1; String[]filename2; intq; filename=UploadFile.PostedFile.FileName; filename2=filename.Split(newChar[]{'//'}); 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; } voidUpdateBtn_Click(Objectsender,EventArgse){ Stringfilename1; filename1=Image1.Src; System.Drawing.Imageimage=System.Drawing.Image.FromFile(Server.MapPath(filename1)); System.Drawing.Imagenewimage=newBitmap(image.Width,image.Height,PixelFormat.Format32bppRGB); Graphicsg=Graphics.FromImage(newimage); g.DrawImage(image,0,0,image.Width,image.Height); Fontf=newFont(FontType.SelectedItem.Text,Int32.Parse(FontSize.SelectedItem.Text)); Brushb=newSolidBrush(Color.Red); g.DrawString(Caption.Text,f,b,10,140); g.Dispose(); System.Drawing.ImagethumbImage=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:labelrunat=server/> <formenctype="multipart/form-data"runat=server> 選擇上傳文件:<inputtype=filerunat=server> <asp:buttonText="UploadMe!"OnClick="UploadBtn_Click"runat=server/> <hr> <asp:panelVisible=falserunat=server> <imgID="Image1"src=""runat="server"/> 圖像寬度:<asp:textboxrunat=server/> 圖像高度:<asp:textboxrunat=server/><br> 文本標題:<asp:textboxrunat=server/> 標題字號:<asp:dropdownlistrunat=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:dropdownlistrunat=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:buttonText="UpdateImage"OnClick="UpdateBtn_Click"runat=server/> </asp:panel> </form>
</body> </html>
|