Version 1.0 |
DLL: HeadingGenerator.dll |
| |
|
| |
Contents
|
| |
Copyright
|
Welcome to VPF Heading Generator
|
Installing VPF Heading Generator
|
Uninstalling VPF Heading Generator
|
The VPF fonts
|
Using VPF Heading Generator
|
Code examples
|
| |
| |
| |
|
| goto top |
|
Copyright |
| |
We have done our best to ensure that the information in this manual is both accurate
and useful; however, please be aware that errors may exist, and that Dimac Development / Duplo AB
(hereafter referred to as Duplo) does not give any guarantees concerning the accuracy of the information here
or in the use to which it may be put.
Duplo may have patents and/or pending patent applications covering subject matter in this document.
Copyright © 2004 Duplo AB. All rights reserved.
This document may only be reproduced (in whole or part),
copied, photocopied, translated, or converted to any electronic or machine readable form with the prior
permission of Duplo.
If any problems occur using this application, please visit our web site http://www.dimac.net
|
|
| |
|
|
| goto top |
|
Welcome to VPF Heading Generator |
| |
VPF Heading Generator is a component optimized to generate headings as images.
By using this component you will be able to use the information from your
own database to generate image headings for your website. It is also easy
to integrate in your Windows applications. The component generates texts
using full color images, which gives you the opportunity to create your
own personal headings with special effects. For this you can use your
own favorite image editor.
Do you want a nice transparent shadow or fill the characters with a self-chosen
pattern? The choice is yours! Your own creativity is what sets the limits
for what you can do with your character sets!
VPF Heading Generator is an ASP compatible COM object easily integrated in your
ASP solutions. The object can also be used in other environments such
as Windows applications. As a COM based solution, it is possible to use the
component in several programming languages such as C++, Visual Basic, and
other COM supported languages.
|
|
| |
|
|
| goto top |
|
Installing VPF Heading Generator |
| |
To use Dimac’s VPF Heading Generator you must have the HeadingGenerator.dll
registered on your server. This is done by either running the installation
program or copying the HeadingGenerator.dll file to your server and manually
registering it with the command:
regsvr32 HeadingGenerator.dll.
Any previous installations of VPF Heading Generator must first be removed,
as described below.
To run the installation program you must have administration
permission on the server. Double click the setup.exe or the
setup_trial.exe (trial version) file to run the installation program.
The installation will by default install at:
c:\Program Files\Dimac Development\VPF\VPF Heading Generator\
together with the manual, the reference, and some ASP and vpf font example files.
The installation will register the HeadingGenerator.dll file as a COM object.
|
|
| |
|
|
| goto top |
|
Uninstalling VPF Heading Generator |
| |
Uninstall is available in the Add/Remove Programs under the Control Panel.
You can also do this manually by unregistering the HeadingGenerator.dll
component (type: regsvr32 /u HeadingGenerator.dll) and then deleting the files.
|
|
| |
|
|
| goto top |
|
The VPF fonts |
| |
The VPF Heading Generator and the VPF Info Reader component uses font files (vpf) created by VPF Heading Composer.
The font files are created from a source image that contains all the characters
that you want your font to be able to handle. You can create the source image with your favorite
image editor, and let VPF Heading Composer generate a nice vpf font out of it.
When creating the source image it is important that the characters are positioned using
some kind of grid line, so that it is possible for the image to be divided in equally sized grids.
Each grid should contain one character.
When creating a source image you must be sure that:
- The image is saved in BMP, PNG or GIF format (recommended with 32-bit PNG, ARGB)
- The image does not contain noise.
- The characters can be separated in equally sizes grids.
|
|
| |
|
|
| goto top |
|
Using VPF Heading Generator |
| |
Creating a surface
In order to generate a text as an image, some kind of drawing surface is needed.
The VPF Heading Generator component can create a surface in four different ways.
By calling the NewSurface method you can set the size and the background
color of the generated image.
Loading a background image
By calling the LoadFromFile or the LoadFromStream method,
you can load an image from disc or stream and use it as background for your text.
Get the size of the image
You can use the properties Width and Height to retrieve the
size of the image. This may be useful if you have created the surface by
the LoadFromFile/LoadFromStream method or the DrawText method.
Selecting a font
Before drawing texts you must select which font to use for the drawing
operations. This is done by calling the SelectFontFromFile or
SelectFontFromStream method.
VPF Heading Generator then loads the specified vpf font. The component
can cache the fonts to improve performance. Normally you should use
this caching functionality.
Drawing a text
Call the DrawText method to draw a text on the created surface.
If no surface is created before this method is called, a surface will be
created. In this case the size of the surface will be equal to the size
of the text. A font must be selected before calling this method.
Calculating text sizes
It is possible to "ask" the component about the size of a specific text
before it is drawn. Use the methods CalculateTextWidth and CalculateTextHeight.
A font must be selected before calling this method.
Saving the image
The image is saved to disc using the SaveToFile method.
Streaming the image
The image is saved to a stream using the SaveToStream method. This is useful
when streaming the image to the client via the ASP response object.
Load object
By calling the LoadFromObject method, you can load data
from another VPF Heading Generator object or a w3Image object.
|
|
| |
|
|
| goto top |
|
Code examples |
| |
Example 01
The following example generates a text with VPF Heading Generator. It's a server side, an ASP
document that streams the created image to the client webbrowser.
For more info run Examples\Example01\JScript and VBScript.
File: index.html
<html>
<head>
</head>
<body>
<img id="headingGeneratorImage" src="image.asp">
</body>
</html>
File: image.asp (Generates the image)
<%@ Language=VBScript %>
<%
' Create heading generator object
Set headingobj = Server.CreateObject("HeadingGenerator.Generator")
' Select font from default folder location
headingobj.SelectFontFromFile "VPSpells.vpf"
' Create an image and draw the text
headingobj.DrawText "Hello World!",0,0
' Stream the image
headingobj.SaveToStream Response,"PNG"
%>
Example 02
The following code centers a text in an image.
For more info run Examples\Example02\JScript and VBScript.
Note: When streaming image data to the Response object you can not do any response messages (like Response.Write)
in the script generating the image (in this example: image.asp). This since the text message will interfere with the data generated by VPF Heading Generator.
File: index.html
<html>
<head>
</head>
<body>
<img id="headingGeneratorImage" src="image.asp">
</body>
</html>
File: image.asp (Generates the image)
<%@ Language=JScript %>
<%
// Since VPF Heading Generator may throw exceptions if errors occur, you should
// use a try-block. Run the image.asp separately to see the errors.
try
{
// Create the VPF Heading Generator object
var headingobj = Server.CreateObject("HeadingGenerator.Generator");
// Load an image from disk
headingobj.LoadFromFile("c:\\MyImages\\MyImage.jpg");
// Select a nice font from a specified directory
headingobj.SelectFontFromFile("c:\\MyFonts\\MyFont.vpf", false);
// Get the size of the loaded image
var imageWidth = headingobj.Width;
var imageHeight = headingobj.Height;
// The text to draw
var text = "Hello...";
// Get the size of the text
var textWidth = headingobj.CalculateTextWidth(text);
var textHeight = headingobj.CalculateTextHeight(text);
// Calculate the drawing position
var posX = ((imageWidth / 2) - (textWidth / 2));
var posY = ((imageHeight / 2) - (textHeight / 2));
// Draw the text
headingobj.DrawText(text, posX, posY);
// Stream the image to the Response object
headingobj.SaveToStream(Response, "PNG");
}
catch(e)
{
// Display error message
Response.Write("Error: " + e.message);
}
%>
|
|
| |
|