Using the component is as simple as
- Creating the object
- Setting a few properties
- Calling the SaveImage method
The following code demonstrates how to use ASPImage from VBScript. In this example we'll create a text image that say's "Welcome to" with a gradient fill.
1 P>Set Image = Server.CreateObject("AspImage.Image")
2
3 rem Set various font parameters
4 Image.FontColor = vbBlack
5 Image.Italic = True
6 Image.Bold = True
7 Image.FontName = "Arial"
8 Image.FontSize = 12
9 Image.PadSize = 10
10
11 rem Calculate how big our text info is and set the image to this size
12 rem This has to be done since we want to fill the area with a gradient
13 strMessage = "Welcome to"
14 Image.MaxX = Image.TextWidth (strMessage)
15 Image.MaxY = Image.TextHeight (strMessage)
16
17 rem Create a one way gradient
18 Image.GradientOneWay vbRed, vbWhite, 0
19
20 rem Print our string to the image
21 Image.TextOut strMessage, Image.X, Image.Y, false
22
23 rem Set the filename and save
24 Image.FileName = "d:\inetpub\wwwroot\images\msg1.jpg"
25 if Image.SaveImage then
26 rem The image was saved so write the tag out for the browser to pick up
27 Response.Write "
"
28 else
29 rem Something happened and we couldn't save the image so just use an HTML header
30 rem We need to debug the script and find out what went wrong. See Image.Error for details
31 Response.Write "Welcome to
"
32 end if
33
34
35