| |
About ASPImage 1.0
ASPImage allows you to create
images on the fly from ASP. Features include:
- Create JPG and BMP formats
- Modify existing images
- Gradient fills
- Draw methods
ASPImage Installation
To use this ASP component move the
DLL into a subdirectory (like \winnt\system32 for NT or
\windows\system for Win95). Please use the version of
regsvr32 that is included with this component or the
version that comes with Microsoft ASP (they are the same
version).
To register the component on the
system change to the directory where you installed the
DLL and type:
regsvr32 aspimage.dll
Finally, run markimag.exe to mark
the component in the registry. Beta users must rerun
markimag with the released version of this utility.
You may need to modify this example
based on the directory you have installed the component
to.
Simple Image Example
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.
Set Image = Server.CreateObject("AspImage.Image")
rem Set various font parameters
Image.FontColor = vbBlack
Image.Italic = True
Image.Bold = True
Image.FontName = "Arial"
Image.FontSize = 12
Image.PadSize = 10
rem Calculate how big our text info is and set the image to this size
rem This has to be done since we want to fill the area with a gradient
strMessage = "Welcome to"
Image.MaxX = Image.TextWidth (strMessage)
Image.MaxY = Image.TextHeight (strMessage)
rem Create a one way gradient
Image.GradientOneWay vbRed, vbWhite, 0
rem Print our string to the image
Image.TextOut strMessage, Image.X, Image.Y, false
rem Set the filename and save
rem NOTE: You should gen the filename dynamically for multiuser usage
Image.FileName = "d:\inetpub\wwwroot\images\msg1.jpg"
if Image.SaveImage then
rem The image was saved so write the <img src> tag out for the browser to pick up
Response.Write "<img src=""/images/msg1.jpg""><br>"
else
rem Something happened and we couldn't save the image so just use an HTML header
rem We need to debug the script and find out what went wrong
Response.Write "<h2>Welcome to</h2>
end if
By testing the result of the
SaveImage method we can determine if the image save was
successful or not. If something happened that causes the
image not to be saved it probably means the script is
saving the image to an invalid directory or a directory
where write rights do not exist.
About purchasing ASPImage
- The registration license fee
covers only one CPU per license. The fee per
CPU is $49.95. We have priced the component
at a level where we hope that companies or
individuals using multiple copies will respect
the license agreement.
About Upgrades
- Who can upgrade?
- Users can upgrade for free for
minor version changes. For example, upgrades from
version 1.00 to 1.99 are free. The upgrade from
1.99 to 2.0 may carry an additional
license fee.
- How to get upgrades
- The latest version of the
components are always available at
http://www.genusa.com/asp/aspcomp.html. If a fee
is associated with obtaining the upgrade it will
be noted on that page.
Upgrade Instructions
To upgrade the component from a
previous version please follow these steps:
- Stop all IIS related services
such as Gopher, FTP and W3SVC.
- Change to the directory where
the component is located and type "regsvr32
/u aspimage.dll"
- Move the new copy of
aspimage.dll to the current directory and type
"regsvr32 aspimage.dll"
- Restart any necessary IIS
related services.
Common Problems
Server object error 80040154.
This is the most common error reported. The error means
that ASP could not create the object. Causes include:
- You never ran regsvr32 on the
DLL. See installation section of this document.
- You registered the DLL with
regsvr32 in one subdirectory and moved it to
another.
- IIS does not have proper
security permissions to access the DLL or the
directory you installed it to. See the ASP FAQ
(http://www.signmeup.com/faq/) for information on
changing security.
- Your server may be running low
on memory.
Note: Some users have reported that
restarting the server after registering the DLL was
required to use the component. This should not be
necessary but reportedly works in a few cases.
Server object error 'ASP
0177:800401f3'.
This error means "Invalid class string" -- in
other words the call to CreateObject failed because the
name object cannot be found by the OLE sub-system. Causes
include:
- You really didn't run regsvr32
on the server after all.
- You ran regsvr32 but it
reported an error.
- Someone modified security on
part of the registry that's preventing the OLE
subsystem from reading all or part of the
HKEY_CLASSES_ROOT tree.
- The name of the object you are
trying to create was mispelled or is incorrect.
AspImage isn't writing the
image files.
Check directory security and make sure that the IIS user
(authenticated and/or anonymous) has security permissions
that allow read/write to the directories in question. The
same problem may occur when using the AddImage method. If
this fails make sure the image file is valid and that
proper security permissions have been granted for the
component to access the file.
Questions about AspImage
Can I use
virtual paths? |
No. Since IIS
does not provide a standard API to lookup virtual
paths outside of ASP. The method for manually
looking these up will change between IIS 3 and
IIS 4 so we decided to implement physical paths
only. |
What color
constants are defined by VBScript? |
The standard
color constants are:
- vbBlack
- vbRed
- vbGreen
- vbYellow
- vbBlue
- vbMagenta
- vbCyan
- vbWhite
You can, of course, add your own constants to your scripting code. For example:
vbGrayText = &80000011
|
Why doesn't
AspImage support GIF? |
Unisys
differentiates between servers and workstations
in their GIF licensing policies. In the case of
Web servers, they expect the operator of the Web
server to pay $1500 a year to allow dynamic
generation of GIF images. Because of their policy
we cannot ship a GIF enabled version of AspImage
to anyone who can't provide proof of owning this
$1500 Unisys license. Our suggestion is to avoid
GIF. |
Is it
possible to set the color used by commands such
as Rectangle and Ellipse? |
See the
PenColor, PenStyle and PenWidth properties. |
Technical Support
If you require technical support
please send complete details about the problem you are
having. Include the version of AspImage you are using,
sample code snippets that demonstrate the problem (most
problems are scripting errors), information about the
hosting environment etc. For example, if you are using
ASP to host the component please let me know what version
of IIS and ASP you are running (and have you installed
any of the HotFixes). The more information you can
provide in your request for help, the faster your
problems can be resolved.
ASPImage Properties
Property |
Description |
AntiAliasText |
The AntiAliasText allows you to
create anti-aliased text on the image. By default
AntiAliasText is false. Example:
Image.AntiAliasText = True
|
AutoSize |
AutoSize determines
whether or not an image should be clipped when a
draw request that falls outside of the images
current coordinates occurs. If AutoSize is true
then the image will be enlarged to handle the
request. If AutoSize is false then the draw
request will be clipped to fit within the current
image. Example:
Image.AutoSize = False
|
BackgroundColor |
Integer value
specifies the background color. Example:
Image.BackgroundColor = vbWhite
|
Bold |
True/false value
determines if font is bold or not. Example:
Image.Bold = True
|
Expires |
If the component is
an eval or beta version the expires property will
return the date that the component quits
functioning. Example:
Response.Write "Component Expires: " & Image.Expires
|
FileName |
The FileName
property specifies the physical path where a file
will be saved using the SaveImage method. Example:
Image.FileName = "d:\inetpub\wwwroot\images\abc.jpg"
|
FontColor |
The integer
FontColor specifies the color of the font. Example:
Image.FontColor = vbRed
|
FontName |
The string FontName
specifies the name of the font. Example:
Image.FontName = "MS Sans Serif"
|
FontSize |
The integer FontSize
specifies the size of the font. Example:
Image.FontSize = 12
|
ImageFormat |
ImageFormat
determines what graphics for the image will be
saved to. Valid values are
| JPG = 1 |
| BMP = 2 |
Example:
Image.ImageFormat = 2
|
Italic |
True/false value determines if font is italic
or not. Example:
Image.Italic = True
|
JPEGQuality |
If the ImageFormat
is set to JPEG then the JPEGQuality property
specifies the quality of the JPEG image to be
saved. Valid values are 1-100. Example:
Image.JPEGQuality = 95
|
MaxX |
The MaxX property determines the X size of
the image. Example:
Image.MaxX = 100
|
MaxY |
The MaxY property determines the Y size of
the image. Example:
Image.MaxY = 100
|
PadSize |
The PadSize property
allows you to automatically placed horizontal and
vertical padding around text. Example:
Image.PadSize = 5
|
PenColor |
Color determines the color used to draw lines
on the canvas. Example:
Image.PenColor = &h80000011
|
PenStyle |
Style determines the style in which the pen
draws lines.
Value |
Type |
Description |
0 |
Solid |
A solid line. |
1 |
Dash |
A line made up of a series of dashes. |
2 |
Dot |
A line made up of a series of dots. |
3 |
DashDot |
A line made up of alternating dashes
and dots. |
4 |
DashDotDot |
A line made up of a serious of
dash-dot-dot combinations. |
5 |
Clear |
No line is drawn (used to omit the
line around shapes that draw an outline
using the current pen). |
6 |
InsideFrame |
A solid line, but one that may use a
dithered color if Width is greater than
1. |
|
PenWidth |
Width specifies the maximum width of the pen
in pixels. Example:
Image.PenWidth = 2
|
RegisteredTo |
Returns the name of the customer or company
who purchased the component or
"Evaluation" if the component is
unregistered. |
Strikeout |
True/false value
determines if font is strikeout or not. Example:
Image.Strikeout = False
|
TextAngle |
The TextAngle property
determines the angle the text written with
TextOut is written at. By default TextAngle is 0. Example:
Image.TextAngle = 90
|
ThreeDColor |
Sets the text color used for 3d text. Example:
Image.ThreeDColor = &h80000011
|
Underline |
True/false value
determines if font is underlined or not. Example:
Image.Underline = False
|
Version |
Gets the internal component version number. Example:
Response.Write "Component Version: " & Image.Version
|
X |
The X property indicates the current X
(horizontal) position of the cursor on the image. Example:
Image.X = 10
|
Y |
The Y property indicates the current Y
(vertical) position of the cursor on the image. Example:
Image.Y = 10
|
ASPImage Component Methods
Method |
Parameters |
Return
Value |
Description |
AddImage |
strFileName, intX, intY |
True/False |
Adds a new image to the canvas using the intX
and intY coordinates. |
Arc |
intX1, intY1, intX2, intY2, intX3, intY3,
intX4, intY4 |
N/A |
Draws an arc on the image along the perimeter
of the ellipse bounded by the specified
rectangle. |
Chord |
intX1, intY1, intX2,
intY2, intX3, intY3, intX4, intY4 |
N/A |
Draws a closed
figure represented by the intersection of a line
and an ellipse. |
ClearImage |
N/A |
N/A |
Clears the image
canvas using the current BackgroundColor as the
fill color. |
Ellipse |
intX1, intY1, intX2, intY2 |
N/A |
Ellipse draws the ellipse defined by a
bounding rectangle on the image. |
FillRect |
intLeft, intTop,
intRight, intBottom |
N/A |
FillRect fills the
specified rectangle on the image. |
FloodFill |
intX, intY, intColor,
intFillStyle |
N/A |
Use FloodFill to fill a possibly
non-rectangular region of the image. The
boundaries of the region to be filled are
determined by moving outward from the point (X,Y)
until a color boundary involving the Color
parameter is encountered. |
FrameRect |
intLeft, intTop, intRight,
intBottom |
N/A |
Draws a 1 pixel wide border
around a rectangular region using the points
specified. |
LoadImage |
strFileName |
True/False |
Loads an existing
image into the image canvas. You can load JPG,
and BMP files. |
GradientOneWay |
intBeginColor, intEndColor, intDirection |
N/A |
Creates a one way gradient beginning with the
color intBeginColor and ending in the color
specified by intEndColor. |
GradientTwoWay |
intBeginColor, intEndColor, intDirection,
intInOut |
N/A |
Creates a two way gradient beginning with the
color intBeginColor and ending in the color
specified by intEndColor. |
LineTo |
intX, intY |
N/A |
Creates a line from
properties X, Y and going to intX, intY. |
Pie |
intX1, intY1, intX2, intY2, intX3, intY3,
intX4, intY4 |
N/A |
Draws a pie-shaped the section of the ellipse
bounded by the rectangle (X1, Y1) and (X2, Y2) on
the image. |
Rectangle |
intX1, intY1, intX2, intY2 |
N/A |
Creates a rectangle using the points
specified. |
RoundRect |
intX1, intY1, intX2, intY2, intX3, intY3 |
N/A |
Creates a round rectangle using the points
specified. |
SaveImage |
N/A |
True/False |
Saves the current image canvas into the file
specified in the property FileName. |
TextOut |
strText, intX, intY, bol3d |
N/A |
TextOut writes a text value using the current
font, color and other characteristics to the
image at the location specified by intX and intY.
If bol3d is true then the text is rendered using
a 3d look. |
TextHeight |
strValue |
Integer |
Returns the text height for strValue using
the current font, font size and font
characteristics. |
TextWidth |
strValue |
Integer |
Returns the text width for strValue using the
current font, font size and font characteristics. |
Copyright © 1996, 1997 by Stephen Genusa. All Rights Reserved.
|