| 
  (C#)  ASP.NET Write Text to Image ตัวอย่างการสร้างรูปภาพ และ การเขียนข้อความลงในรูปภาพ 
    |  
        (C#) ASP.NET Write Text to Image       |  
 Language Code : VB.NET ||
  C# 
 Framework : 1,2,3,4
 
 AspNetWriteTextImages1.aspx
 
 
 <%@ Page Language="C#" Debug="true" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<script runat="server">
	void Page_Load(object sender, EventArgs e)
	{
		int intWidth = 0;
		int intHeight = 0;
		string FileName = null;
		intWidth = 400;
		intHeight = 200;
		FileName = "MyImages/Images.png";
		
		Bitmap objBitmap = new Bitmap(intWidth, intHeight);
		Graphics objGraphic = Graphics.FromImage(objBitmap);
		//*** Create Images ***//
		objGraphic.FillRectangle(Brushes.Maroon, 0, 0, intWidth, intHeight);
		
		//*** Write Text ***//
		string strText = "ยินดีต้อนรับ Welcome To www.ThaiCreate.Com";
		//*** String ***//
		Font objFont = new Font("Tahoma", 10, FontStyle.Italic);
		//*** Font Style ***//
		PointF objPoint = new PointF(5, intHeight - 20);
		//*** Point ***//
		SolidBrush objBrushWrite = new SolidBrush(Color.YellowGreen);
		//*** Font Color ***//
		
		
		objGraphic.DrawString(strText, objFont, objBrushWrite, objPoint);
		
		//*** Save As ***//
		objBitmap.Save(Server.MapPath(FileName.ToString()), ImageFormat.Png);
		
		//*** Close ***//
		objGraphic.Dispose();
		
		//*** Nothing ***//
		objBitmap = null;
		objGraphic = null;
		
		//*** View Images ***//
		this.imgPicture.ImageUrl = FileName;
		
	}
</script>
<html>
<head>
<title>ThaiCreate.Com ASP.NET - Images (System.Drawing)</title>
</head>
<body>
	<form id="form1" runat="server">
		<asp:Image id="imgPicture" runat="server" />
	</form>
</body>
</html>
</form>
 จากตัวอย่างจะเห็นว่าสามารถเขียนข้อความได้ทั้งภาษาไทย และ ภาษาอังกฤษ
 
 Screenshot
 
 
   
 
 
 
                
                  | Property & Method (Others Related) |  
 
 |