View Single Post
  #3 (permalink)  
Old 03-07-2006
Vaughn Vaughn is offline
Member
 
Join Date: Aug 2004
Posts: 65
Rep Power: 0
Vaughn is on a distinguished road
Send a message via MSN to Vaughn Send a message via Yahoo to Vaughn
Default

2) Drawing the text

We will be using similar code as I mentioned in the example, except, the method will be slightly different. For ease of use, we will separate the form processing code and image generation code in two separate files. We will create an ASP file to generate the image and then ‘insert’ that image into our form at run time. The code to generate the image is as below, save it in a file called ‘genImage.asp':

Code:
<%@Language=VBScript%>
<%
Dim strWord
Dim intImageWidth
Dim intImageHeight
Dim oDynImage

strWord = "12345"
intImageWidth = 300
intImageHeight = 150

Set oDynImage = CreateObject("DynImage.DynImage")
With oDynImage
	.Open intImageWidth, intImageHeight

	.FontFace = "Arial"
	.FontWeight = 800
	.FontSize = 48
	.TextAlign = 5
	.TextOut (intImageWidth/2), (intImageHeight/2), strWord

	Response.ContentType = "image/png"
	Response.BinaryWrite .Image

	.Close
End With
Set oDynImage = Nothing
%>
The code is quite similar to what we saw earlier with a few additions. I’ve set the font face, weight size and alignment properties. For now it just draws the string ‘12345’ in the exact center of the image. We’ll replace it a string of our choice later. When browsed it will display the below image:

__________________
Vaughn
Team Leader // Tech. Support
AccuWebHosting.Com
email:support@accuwebhosting.com

Blog: blogsandbloggers.com/Vaughn
http://www.accuwebhosting.biz/Vaughn...aughn_Sign.jpg
Reply With Quote