The ability to anti-alias fonts was added to ImgWriter 1.1.6. This can be done by using the "AntiAliasFactor" property of the ImgGen object. AntiAliasFactor can be set to the following values:
Value
|
Enumerator*
|
0 |
saAntiAliasNone (default) |
2 |
saAntiAliasGood |
4 |
saAntiAliasBest (recommended) |
6 |
saAntiAliasHigh |
8 |
saAntiAliasHighest |
*Using an enumerator requires referencing or including the ImgWriter Type Library. The example below includes the type library in the METADATA tag.
<%@ Language=VBScript %>
<!-- METADATA TYPE="TypeLib"
UUID="{50D94450-589A-409B-819A-4F88B151C134}"-->
<%
Dim saImg
Set saImg = Server.CreateObject("SoftArtisans.ImageGen")
Dim strPath
Dim myFont
'-- Load the image
strPath = Server.MapPath("./Images")
saImg.LoadImage strPath & "/myImage.psd"
'-- Set the AntiAliasFactor
saImg.AntiAliasFactor = saAntiAliasBest
'--Add text to the image
saImg.Text = "This is big text."
set myFont = saImg.Font
With myFont
.Name = "Century Gothic"
.Height = 100
.Weight = 700
.Color = rgb(000,000,000)
End With
'-- Text area parameter supplied below will be ignored
'-- since font will be anti-aliased.
saImg.DrawTextOnImage 10, 10, 100, saImg.TextHeight
'-- Call the save method to stream the image to the browser.
saImg.SaveImage saiBrowser, saiJPG, strPath & "/myImage.jpg"
set saImg = Nothing
%>
The value of AntiAliasFactor is directly proportional to the amount of memory required for the process. The higher the AntiAliasFactor value, the more memory is required. saAntiAliasBest is the recommended value for the most efficient value in regards to processing time and smoothness of font.
The area provided for the text rectangle is normally calculated based on the top, left, height, and width parameters passed to DrawTextOnImage. However, when using AntiAliasFactor, these parameters are ignored and the dimensions of the text rectangle are determined by the font.
|