ASPPainter Documentation
1. Quick start instruction to use ASPPainter component
-
Register ASPPainter component on your computer (it's not necessary to have a
web server). OpenStart->Run dialog and type "path_to_regsvr\regsvr32.exe
path_to_ASPPainter\ASPPainter.dll". Make sure you specify correct paths. For
example, "C:\windows\regsvr32.exe C:\ASPPainter\ASPPainter.dll". You should see
"ASPPainter DLL registered successfully" message.
-
Place GDI+ library (gdiplus.dll file) to the directory where ASPPainter
component is located. You don't need to register gdiplus.dll
-
Run block.vbs smaple located in samples folder. You can verify that newly
created image has appeared (the file with the image named chart.png will be
created in the root of drive C).
-
Sample "Writing image to database". Create DSN "asppainter" that will point to
MS Access "asppainter.mdb". Create a web-site or virtual directory
2. Quick start instruction for ASP developers
-
Register ASPPainter component on your computer (it's necessary to have a Web
server like IIS or PWS). Go to menu "Start", choose "Command Prompt" and change
the directory to where ASPPainter component is located. Run from command line
"regsvr32 ASPPainter.dll". You should see "ASPPainter DLL registered
successfully" message.
-
If you have problem with registration, try to specify path before regsvr32.exe
and ASPPainter component. For example, "C:\windows\regsvr32.exe
C:\ASPPainter\ASPPainter.dll"
-
Place GDI+ library (gdiplus.dll file) to the directory where ASPPainter
component is located. You don't need to register gdiplus.dll
-
Place "chart.asp" from distribution package to your virtual directory.
-
Open corresponding url from your browser.
General information
Component is distributed with complete source code that can be easily extended
with your own functionality (See purchase page). Another advantage is that you
can host the component on servers where system security policy allows running
only open source components.
Working with the component
Let us take a close look at the component internals on a simple sample.
Image Creation.
Used method: Create (width, height)
Create method allocates memory and creates image with specified image dimensions
(width and height) in a special internal format. You should use SetBKColor to
set a background color. By default the background is set to transparent black
color. You need to select image type every time you need to import/export image
to/from the component e.g. saving image to file, database or data stream.
Image format.
Used method: SetFormat (type)
Image format can be set with Format method. Type 0 sets PNG format (default),
type 1- Jpeg, type 3 - GIF, type 4 -TIFF, type 5 - BMP.
Draw
1.Text Output.
Used method: TextOut
' Define object variable
Dim pic
' Create object
Set pic = CreateObject("ASPPainter.Pictures.1")
' Set background color in RGB format
pic.SetBKColor 191,255,255,255
' Create image with specified width and height
pic.Create 150,75
pic.SetColor 0,0,0,255
' Set foreground color in RGB format (black)
'TrueType font
pic.SetFontName "Verdana"
pic.SetFontSize 14
pic.SetFontBold 1
pic.SetFontAntialias 1
pic.TextOut 10,40, "TrueType"
' Save Image to file.
pic.SaveToFile "C:\font.png"
' Delete image and free memory
pic.DestroyALL
Set pic = Nothing
' Clear the variable

2. Line.
Used method: SetLineWidth (num). Line thickness (in number of pixels) is applied
for DrawLine, DrawArc and DrawPolygon methods. Default value is 1
3. Polygon.
Used method: DrawPolygon (array a, integer point_num) DrawUnclosedPolygon (array
a, integer point_num),
This sample draws polygons. You need to define coordinates array and
consequently fill it with x,y pairs. For example coord(0) = x1, coord(1) = y1,
etc. In a call to DrawPolygon you have to specify the array and the number of
points (or x, y pairs) to draw.
Save Image
Used method: SaveToFile, SaveToDatabase, SaveToStream
Image can be saved to file, database or directly to a data stream.
Destroy image
Used method: Destroy , DestroyALL
Deletes current image and frees memory. It's necessary to call this method after
using every image.
If you want to catch errors returned from the component, you have to
enable it in ASP/VBScript code, adding “On Error Resume Next”. The component
throws the following exceptions:
-
Empty Image.
It may happen when (a) you draw on NULL image object. Check if you called
Create before calling drawing methods (b) When you save empty image to
file/database/variable (c) You deleted image with Destroy or tried to call
SetImageNumber with wrong image number (d) You tried to load the image of wrong
format or set incorrect format in a call to SetFormat.
-
Invalid parameter. The passed parameters may have wrong type,
incorrect value (blue color component is greater than 255 or negative color for
example) Also this error may be thrown when you try specify more than 4998
polygon vertexes.
-
Font not found. This error may appear while drawing a text when you
specified an invalid font name or when you specified a font file name that
doesn't exist.
-
GDIPlus initialization error
. It may happen when you didn't place gdiplus.dll to the directory of the
component.
-
General error
. It may appear in some unforeseen conditions (low memory, etc.).
-
Read/Write error.
It may be caused by an invalid filename or file path, or when you don't have
file read or file write permissions.
-
Memory initialization error. The possible cause is an attempt to create
a very large file.