VPF Heading Generator - Reference


Version 1.0
DLL: HeadingGenerator.dll
 

 

METHODS

 
NewSurface
    VARIANT_BOOL NewSurface(long iWidth, long iHeight, VARIANT vtColor)
 
SaveToFile
    VARIANT_BOOL SaveToFile(BSTR bstrFile, BSTR bstrFormat, VARIANT vtParam1, VARIANT vtParam2)
 
SaveToStream
    VARIANT_BOOL SaveToStream(IUnknown *pUnkStream, BSTR bstrFormat, VARIANT vtParam1, VARIANT vtParam2)
 
LoadFromFile
    VARIANT_BOOL LoadFromFile(BSTR bstrFile)
 
LoadFromStream
    VARIANT_BOOL LoadFromStream(IUnknown *pUnkStream)
 
LoadFromObject
    VARIANT_BOOL LoadFromObject(IUnknown *pUnkObj, VARIANT vtDestX, VARIANT vtDestY, VARIANT vtSrcX, VARIANT vtSrcY, VARIANT vtSrcWidth, VARIANT vtSrcHeight)
 
SelectFontFromFile
    SelectFontFromFile(BSTR bstrFilePath, VARIANT_BOOL btUseCache)
 
SelectFontFromStream
    SelectFontFromStream(IUnknown *pUnkVpfStream, VARIANT_BOOL bStUseCache)
 
RemoveFontFromCache
    VARIANT_BOOL RemoveFontFromCache(VARIANT vIdentifier)
 
ClearCache
    VARIANT_BOOL ClearCache()
 
DrawText
    DrawText(BSTR bstrText, long lXPos, long lYPos)
 
CalculateTextWidth
    long CalculateTextWidth(BSTR bstrText)
 
CalculateTextHeight
    long CalculateTextHeight(BSTR bstrText)
 

 

PROPERTIES

 
Width
    long Width
 
Height
    long Height
 

 
NewSurface
 
Name NewSurface
   
Description Creates a surface that is used when drawing
   
Type Method
   
Interface
VARIANT_BOOL NewSurface (  
  long iWidth,
  long iHeight,
  VARIANT vtColor (optional)
)  
   
Parameters
iWidth The width of the image to be created
   
iHeight The height of the image to be created
   
vtColor Specifies background value (ARGB)
   
Returning value Returns true or false depending if the operation was successful
   
Example JScript:

var test = HeadingImageObj.NewSurface(100, 200, 0xFF00FF00);

VBScript:

test = HeadingImageObj.NewSurface(200, 300, &HFF00FF00&)
 

goto top  
SaveToFile
 
Name SaveToFile
   
Description Saves the generated image to file
   
Type Method
   
Interface
VARIANT_BOOL SaveToFile (  
  BSTR bstrFile,
  BSTR bstrFormat,
  VARIANT vtParam1, (optional)
  VARIANT vtParam2 (optional)
)  
   
Parameters
bstrFile Specifies the path and the filename to the file
   
bstrFormat Specifies the output format:

"BMP" - BMP (Bitmap)
"GIF" - GIF (Graphics Interchange Format)
"PNG" - PNG (Portable Network Graphic)
"TIFF" - TIFF (Tagged Image File Format)
"JPG" - JPG (Joint Photographic Experts Group)
   
vtParam1 Specifies color description value:
Valid values:

long (0-100), JPG Compression rate
   
vtParam2 Specifies an extra optional paramter (reserved for future use)
   
Returning value Returns true or false depending if the operation was successful
   
Example JScript:

var test = HeadingImageObj.SaveToFile(“c:\\myfont.jpg”, “JPG”, 100);

VBScript:

test = HeadingImageObj.SaveToFile(“c:\myfont.bmp”, “BMP”)
 

goto top  
SaveToStream
 
Name SaveToStream
   
Description Streams the image data
   
Type Method
   
Interface
VARIANT_BOOL SaveToStream (  
  IUnknown *pUnkStream,
  BSTR bstrFormat,
  VARIANT vtParam1, (optional)
  VARIANT vtParam2 (optional)
)  
   
Parameters
*pUnkStream Specifies any object that supports the interface IStream, for example the ASP Response object.
   
bstrFormat Specifies the output format:

"BMP" - BMP (Bitmap)
"GIF" - GIF (Graphics Interchange Format)
"PNG" - PNG (Portable Network Graphic)
"TIFF" - TIFF (Tagged Image File Format)
"JPG" - JPG (Joint Photographic Experts Group)
   
vtParam1 Specifies color description value:
Valid values:

long (0-100), JPG Compression rate
   
vtParam2 Specifies an extra optional paramter (reserved for future use)
   
Returning value Returns true or false depending if the operation was successful
   
Example JScript:

var test = HeadingImageObj.SaveToStream(Response, “JPG”, 100);

VBScript:

test = HeadingImageObj.SaveToStream(Response”, “BMP”)
 

goto top  
LoadFromFile
 
Name Load
   
Description Loads an image from file
   
Type Method
   
Interface
VARIANT_BOOL LoadFromFile (  
  BSTR bstrFile
)  
   
Parameters
bstrFile Specifies the path and the filename to the file
   
Returning value Returns true or false depending if the operation was successful
   
Example JScript:

var test = HeadingImageObj.LoadFromFile(“c:\\myfont.jpg”);

VBScript:

test = HeadingImageObj.LoadFromFile(“c:\myfont.bmp”)
 

goto top  
LoadFromStream
 
Name LoadFromStream
   
Description Loads an image from a stream
   
Type Method
   
Interface
VARIANT_BOOL LoadFromStream (  
  IUnknown *pUnkStream
)  
   
Parameters
*pUnkStream Specifies an object that supports the interface IStream.
   
Returning value Returns true or false depending if the operation was successful
   
Example JScript:

// Create Stream object
var FS = Server.CreateObject("ADODB.Stream");

FS.Type = 1;
FS.Mode = 3;
FS.Open();

FS.LoadFromFile("c:\\image.bmp");

var test = HeadingImageObj.LoadFromStream(FS);

FS.Close();

VBScript:

Dim FS
Dim test

' Create Stream object
Set FS = Server.CreateObject("ADODB.Stream")

FS.Type = 1
FS.Mode = 3
FS.Open

FS.LoadFromFile "c:\image.bmp"

test = HeadingImageObj.LoadFromStream(FS)

FS.Close

 

goto top  
LoadFromObject
 
Name LoadFromObject
   
Description Loads an object and applies the data.

Use this method to integrate w3Image with VPF Heading Generator.

For more info run Examples\Example03\JScript and VBScript (w3Image component required).
   
Type Method
   
Interface
VARIANT_BOOL LoadFromObject (  
  IUnknown *pUnkObj,
  VARIANT vtDestX,
  VARIANT vtDestY,
  VARIANT vtSrcX,
  VARIANT vtSrcY,
  VARIANT vtSrcWidth,
  VARIANT vtSrcHeight
)  
   
Parameters
*pUnkObject Specifies a VPF Heading Generator object or a w3Image object.
vtDestX Specifies the destination x-coordinate.
vtDestY Specifies the destination y-coordinate.
vtSrcX Specifies the source x-coordinate.
vtSrcY Specifies the source y-coordinate.
vtSrcWidth Specifies the source width.
vtSrcHeight Specifies the source height.
   
Returning value Returns true or false depending if the operation was successful
   
Example JScript:

// Load the w3Image object into the VPF Heading Generator surface
headingobj.LoadFromObject(w3imageobj,0,0,0,0,w3imageobj.Width,w3imageobj.Height);

VBScript:

' Load the w3Image object into the VPF Heading Generator surface
headingobj.LoadFromObject w3imageobj,0,0,0,0,w3imageobj.Width,w3imageobj.Height
 

goto top  
SelectFontFromFile
 
Name SelectFontFromFile
   
Description Select which font to use for the drawing operations

This method use default font folder location specified in the register settings.
Use the VPF Register Console to change the location.
   
Type Method
   
Interface
SelectFontFromFile (  
  BSTR bstrFilePath
   
  VARIANT_BOOL btUseCache
)  
   
Parameters
bstrFilePath Specifies the path and the filename to the font file (*.vpf file )
   
btUseCache Specifies if the image should be cached or not
   
Returning value None
   
Example JScript:

// Select font from a specified folder location
HeadingImageObj.SelectFontFromFile(“c:\\myfont.vpf”, true);

// Select font from the default font folder location
HeadingImageObj.SelectFontFromFile(“myfont.vpf”);

VBScript:

' Select font from a specified folder location
HeadingImageObj.SelectFontFromFile “c:\fonts\testfont.vpf”, false

' Select font from the default font folder location
HeadingImageObj.SelectFontFromFile “myfont.vpf”

 

goto top  
SelectFontFromStream
 
Name SelectFontFromStream
   
Description Select which font to use for the drawing operations
   
Type Method
   
Interface
SelectFontFromStream (  
  IUnknown *pUnkVpfStream
   
  VARIANT_BOOL btUseCache
)  
   
Parameters
*pUnkVpfStream Specifies an object that supports the interface IStream
   
btUseCache Specifies if the image should be cached or not
   
Returning value None
   
Example JScript:

// Create Stream object
var FS = Server.CreateObject("ADODB.Stream");

FS.Type = 1;
FS.Mode = 3;
FS.Open();

FS.LoadFromFile("c:\\myfont.vpf");

HeadingImageObj.SelectFontFromStream(FS, true);

FS.Close();

VBScript:

Dim FS

' Create Stream object
Set FS = Server.CreateObject("ADODB.Stream")

FS.Type = 1
FS.Mode = 3
FS.Open

FS.LoadFromFile "c:\myfont.vpf"

HeadingImageObj.SelectFontFromStream FS, true

FS.Close

 

goto top  
RemoveFontFromCache
 
Name RemoveFontFromCache
   
Description Removes a specific font from the font cache.

This method use default font folder location specified in the register settings.
Use the VPF Register Console to change the location.
   
Type Method
   
Interface
VARIANT_BOOL RemoveFontFromCache (  
  VARIANT vIdentifier
)  
   
Parameters
vIdentifier Specifies the font to be removed. This could be a file or a stream.
   
Returning value Returns true or false depending if the operation was successful
   
Example JScript:

// Remove font from cashe (specified folder location)
var test = HeadingImageObj.RemoveFontFromCashe("c:\\myfont.vpf");

// Remove font from cashe (default font folder location)
var test = HeadingImageObj.RemoveFontFromCashe("myfont.vpf");

VBScript:

' Remove font from cashe (specified folder location)
test = HeadingImageObj.RemoveFontFromCashe("c:\myfont.vpf")

' Remove font from cashe (default font folder location)

test = HeadingImageObj.RemoveFontFromCashe("myfont.vpf")
 

goto top  
ClearCache
 
Name ClearCache
   
Description Removes all fonts from the font cache
   
Type Method
   
Interface
VARIANT_BOOL ClearCache ()  
   
Parameters
None  
   
Returning value Returns true or false depending if the operation was successful
   
Example JScript:

var test = HeadingImageObj.ClearCache();

VBScript:

test = HeadingImageObj.ClearCache()
 

goto top  
DrawText
 
Name DrawText
   
Description Draws a text onto the surface.
   
Type Method
   
Interface
DrawText (  
  BSTR bstrText
   
  long lXPos
   
  long lYPos
)  
   
Parameters
bstrText Specifies the text to draw
   
lXPos Specifies the left edge coordinate of the text
   
lYPos Specifies the top edge coordinate of the text
   
Returning value None
   
Example JScript:

HeadingImageObj.DrawText("Dimac", 0, 0);

VBScript:

HeadingImageObj.DrawText "Dimac", 0, 0
 

goto top  
CalculateTextWidth
 
Name CalculateTextWidth
   
Description Returns the calculated width of a text using the selected font
   
Type Method
   
Interface
long CalculateTextWidth (  
  BSTR bstrText
)  
   
Parameters
bstrText Specifies the text to be calculated
   
Returning value Returns the calculated width in pixels of a specified text
   
Example JScript:

var width = HeadingImageObj.CalculateTextWidth(“Test”);

VBScript:

width = HeadingImageObj.CalculateTextWidth(“Test”)
 

goto top  
CalculateTextHeight
 
Name CalculateTextHeight
   
Description Returns the calculated height of a text using the selected font
   
Type Method
   
Interface
long CalculateTextHeight (  
  BSTR bstrText
)  
   
Parameters
bstrText Specifies the text to be calculated
   
Returning value Returns the calculated height in pixels of a specified text
   
Example JScript:

var height = HeadingImageObj.CalculateTextHeight(“Test”);

VBScript:

height = HeadingImageObj.CalculateTextHeight(“Test”)
 

goto top  
Width
 
Name Width
   
Description Returns the width of the image.
   
Type Property
   
Interface
long Width  
   
Parameters
None  
   
Returning value Returns the width of the image
   
Example JScript:

var width = HeadingImageObj.Width;

VBScript:

width = HeadingImageObj.Width
 

goto top  
Height
 
Name Height
   
Description Returns the height of the image.
   
Type Property
   
Interface
long Height  
   
Parameters
None  
   
Returning value Returns the height of the image
   
Example JScript:

var height = HeadingImageObj.Height;

VBScript:

height = HeadingImageObj.Height