Home     Products      Support      Corporate     Sign In 
Support Knowledge Base, Article 695
Product
ImgWriter
Version
1.1.6
Title
Anti-aliasing fonts with ImgWriter
Problem
Curved and diagnoal lines used to create letters in fonts are aliased when displayed on pixel devices such as computer monitors, resulting in jagged horizontal and vertical edges instead of smooth curves. Anti-aliasing is a technique that changes the appearance of fonts by shading pixels on the borders. This makes font edges appear smoother to the human eye, resembling the clear quality seen in print.
Solution

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.

Using AntialiasFactor in your script:

<%@ 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 %>

A note on the values for AntiAliasFactor:

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.

A note on how AntiAliasFactor affects DrawTextOnImage parameters:

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.

Created : 7/21/2003 11:41:21 AM (last modified : 7/21/2003 11:41:17 AM)
Rate this article!
 
Comments