Method of Graphic Class : clear, drawarc, drawbezier, drawclosedcurve, drawcurve, drawellipse, drawline, drawpath, drawpie, drawpolygon, drawrectangle, drawstring, fillclosedcurve, fillellipse, fillpath, fillpie, fillpolygon, fillrectangle
ตัวอย่างการใช้ method เช่น g.fillrectangle(br,2,2,146,146)
ประเภทของแปรงระบายสี : brush, solidbrush, texturebrush, hatchbrush, lineargradienbrush, pathgradientbrush
ตัวอย่างการใช้ แปรงระบายสี เช่น dim br as brush
6.1 วาดภาพด้วย script เช่น http://www.thaiabc.com/aspnet/graph01.aspx
<%@import namespace="system.drawing" %>
<%@import namespace="system.drawing.imaging" %>
<script language="VB" runat="server">
sub page_load(sender as object, e as eventargs)
dim b as new bitmap(150,150, pixelformat.format32bppargb)
dim g as graphics = graphics.fromimage(b)
dim br as brush
br = brushes.yellow
g.fillrectangle(br,2,2,146,146)
br = brushes.red
g.fillellipse(br,5,5,140,140)
response.contenttype = "image/gif"
b.save(response.outputstream, imageformat.gif)
b.dispose()
end sub
</script> |
6.2 โหลดภาพมาแสดงในคอนโทล เช่น http://www.thaiabc.com/aspnet/graph02.aspx
<%@ Page Language="VB" %>
<script runat="server">
Sub Page_Load(sender As Object,e As EventArgs)
img1.ImageUrl = "ta1.gif"
img1.Attributes.Add("OnClick", "alert('ทดสอบภาพ')")
img1.Style.Add("cursor", "hand")
img2.ImageUrl = "ta1.gif"
' ถ้าเปลี่ยน source เป็น utf8 จะ alert เป็นภาษาไทยอย่างถูกต้อง
End Sub
</script>
<html><head></head><body>
<form runat="server">
<asp:Image id="img1" runat="server"></asp:Image>
<asp:Image id="img2" runat="server"></asp:Image>
</form>
</body></html> |
|