ASP Painter
Home
Home
Samples
Samples
Purchase
Purchase
Download
Download
Documentation
Documentation


ASPPainter Documentation

Quick start instruction
   Introduction
   Methods
   Error handling

Quick start instruction

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.


Introduction

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.


 Implemented Methods:

Method

Description

ClearBrush

Clear brush data. Cancel the brush set with SetBrush

ClearFontRectangle

Clear font rectangledata. Cancel the rectangle set with SetFontRectangle

ClearFontStyle

Clear font style. Cancel the font style set with SetFontBold, SetFontItalic and etc

ClearGradient

Clear brush data. Cancel the brush set with SetGradient

ClearRegion

Cancel the region set with SetRegion.

Copy

Copy image part

Create

Create image

Destroy

Destroy image and free allocated memory

DestroyALL

Destroy images, objects and free allocated memory

DrawArc

Draw Arc

DrawBezier

Draw Bezier lines

DrawCircle

Draw circle

DrawLine

Draw line

DrawEllipse

Draw Ellipse

DrawFilledCircle

Draw filled circle

DrawFilledEllipse

Draw filled ellipse

DrawFilledPie

Draw filled pie

DrawFilledPolygon

Draw filled polygon

DrawFilledRectangle

Draw filled rectangle

DrawPie

Draw filled arc (can be used to create pie charts)

DrawPolygon

Draw polygon

DrawRectangle

Draw rectangle

ExistFont

Check if the font exists

Fill

Color fill (changing color for another color)

GetColor

Get current color in ARGB format (FFFFFFFF - white)

GetColorAlpha

Gets the alpha channel value of active foreground color

GetColorBlue

Get blue value of current color

GetColorGreen

Get green value of current color

GetColorIndex

Get color handle

GetColorRed

Get red value of current color

GetFontHeight

Get the height of a text string

GetImageIndex

Get image handle

GetPixelAlpha

Get the value of alpha channel color component

GetPixelBlue

Get blue value for a pixel

GetPixelGreen

Get green value for a pixel

GetPixelRed

Get red value for a pixel

Height

Get image height

HorizontalFlip

Flip image horizontal

LoadDatabse

Read image from database

LoadFile

Read image from file

LoadStream

Read image from variable

MakeThumbnail

Make a thumbnail from current image

Merge

Merge image parts

Mirror

Make a mirror image

ResizeCopy

Copy image part with resize

Rotate

Rotate image on an arbitrary angle

SaveToDatabase

Write image to database

SaveToFile

Write image to file

SaveToStream

Write image to variable (can be also used to write image directly to browser data stream)

SaveToVariant

Write image to variable (can be also used to write image to OleLoadPicture in VC++)

SetAlignText

Set text align data

SetBKColor

Set background color. New images will be filled with current background color. The method can be used to create transparent images

SetBlendingMode

Enables/Disables alpha blending

SetBrush

Select current image as a brush

SetColor

Set foreground color

SetColorAsTransparent

Set current color as transparent. (set alpha channel value to 0)

SetColorIndex

Select color

SetFontAntialias

Set antialias font

SetFontBold

Set bold font style

SetFontGradient

Draw text using gradient fill

SetFontItalic

Set italic font style

SetFontName

Set font name. For example to "Times New Roman"

SetFontOrientation

Set angle to draw text

SetFontRectangle

Set rectangle to draw text

SetFontRegular

Set regular font style

SetFontSize

Set the size of True Type Font

SetFontStrikeout

Set strikeout font style

SetFontUnderline

Set underline font style

SetFormat

Set image format (PNG, Jpeg, BMP, GIF, TIFF)

SetGradient

Select gradient

SetImageIndex

Select image

SetJpegQuality

Set Jpeg quality value

SetLineWidth

Set line thickness for simple drawing operations

SetPixel

Set pixel

SetRegion

Set region for painting

SetSaveAsPalette

Save current image in Palette format (PNG,TIFF, BMP). GIF image is a palette one by default

SetTransparentPixel

Set transparent pixel

TextOut

Draws text with selected TrueType font

Grayscale

Convert image to Grayscale

Monochrome

Convert image to black and white

DrawUnclosedPolygon

Draw unclosed polygon (first point is not connected to the last one)

VerticalFlip

Flip image vertical

Width

Get image width

Error handling

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:

  1. 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.
  2. 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.
  3. 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.
  4. GDIPlus initialization error . It may happen when you didn't place gdiplus.dll to the directory of the component.
  5. General error . It may appear in some unforeseen conditions (low memory, etc.).
  6. 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.
  7. Memory initialization error. The possible cause is an attempt to create a very large file.


home samples purchase documentation download