Home
What's New

User Manual
Object Reference
ASPJpeg
Brush
Canvas
Font
Gif
Info
InfoItem
Pen

Live Demos
Support

Download & Buy

Other Products
Contact Us


Search this site:

Canvas Object

The Canvas object encapsulates properties and methods which enable drawing and typing on top of an image. This method is returned by the Canvas property of the main ASPJpeg object.

Properties Methods
Brush
Font
ParagraphHeight
Pen
Arc
Bar
Circle
DrawArc
DrawBar
DrawCircle
DrawEllipse
DrawImage
DrawLine
DrawPie
DrawPNG
DrawPNGBinary
DrawQuad
DrawRoundRect
Ellipse
GetTextExtent
Line
Print
PrintText
PrintTextEx

Canvas Properties

Brush As IAspJpegBrush (read-only)
Returns the Brush object which enables setting brush properties.

See also: Chapter 5 - Drawing & Typing.

Font As IAspJpegFont (read-only)
Returns the Font object which enables setting font properties.

See also: Chapter 5 - Drawing & Typing.

ParagraphHeight As Long (read-only)
Returns the height (in pixels) of a text paragraph just rendered by a call to PrintTextEx. 0 by default. This property was introduced by Version 1.9.

See also: Section 5.3 - Advanced Text Drawing with PrintTextEx.

Pen As IAspJpegPen (read-only)
Returns the Pen object which enables setting pen properties.

See also: Chapter 5 - Drawing & Typing.

Canvas Methods

Sub Arc(X As Long, Y As Long, Radius As Long, StartAngle As Long, ArcAngle As Long)
Same as DrawArc. Obsolete, supported for backwards compatibility only.
Sub Bar(Left As Long, Top As Long, Right As Long, Bottom As Long )
Same as DrawBar. Obsolete, supported for backwards compatibility only.
Sub Circle(X As Long, Y As Long, Radius As Long)
Same as DrawCircle. Obsolete, supported for backwards compatibility only.
Sub DrawArc(X As Long, Y As Long, Radius As Long, StartAngle As Long, ArcAngle As Long)
Draws a circular arc with a center in (X, Y). The arc radius is specified by Radius (in pixels). StartAngle specifies the angle (in degrees) of the arc's starting point, and ArcAngle specifies the arc's span, in the counterclockwise direction. Uses the current pen. Arcs are not filled.

See also: Chapter 5 - Drawing & Typing.

Sub DrawBar(Left As Long, Top As Long, Right As Long, Bottom As Long )
Draws a rectangle specified by the coordinates of its upper-left and lower-right corners (in pixels) using the current pen and brush.

See also: Chapter 5 - Drawing & Typing.

Sub DrawCircle(X As Long, Y As Long, Radius As Long)
Draws a circle specified by its center coordinates and radius (in pixels) using the current pen and brush.

See also: Chapter 5 - Drawing & Typing.

Sub DrawEllipse(Left As Long, Top As Long, Right As Long, Bottom As Long )
Draws an ellipse specified by the coordinates of its bounding rectangle (in pixels) using the current pen and brush.

See also: Chapter 5 - Drawing & Typing.

Sub DrawImage(X As Long, Y As Long, Picture As ASPJpeg, Optional Opacity = 1, Optional TranspColor, Optional TranspDeviation = 0)
Draws an image on top of the current image. X and Y are coordinates (in pixels) of the upper-left corner of Picture within the current image. Picture is another instance of the AspJpeg object.

Opacity is a number between 0 and 1 which specifies the degree of opacity when Picture is blended onto the current image. Default value: 1 (opaque).

TranspColor specifies the color of pixels within Picture to be made transparent when blending the picture onto the current image. This must be an HTML-style hexadecimal number, e.g. &HFF0000 (red). By default, no pixels will be made transparent.

TranspDeviation is a number between 0 and 255 which specifies an allowable deviation of the RGB color values from TranspColor. Default value: 0. If TranspColor is not specified, this argument is ignored.

Starting with Version 1.9, this method requires that the color component count of the source and destination images match. E.g. an RGB image cannot be drawn on top of a CMYK one, or vice versa.

See also: Section 6.1 - Image Drawing.

Sub DrawLine(x1 As Long, y1 As Long, x2 As Long, y2 As Long )
Draws a line specified by the coordinates of its starting and ending points (in pixels) using the current pen.

See also: Chapter 5 - Drawing & Typing.

Sub DrawPie(X As Long, Y As Long, Radius As Long, StartAngle As Long, EndAngle As Long)
Draws a pie-shaped wedge with a center in (X, Y). The radius is specified by Radius (in pixels). StartAngle specifies the angle (in degrees) of the arc's starting point, and EndAngle specifies the arc's ending point, in the counterclockwise direction. Uses the current pen and brush. This method was introduced by version 2.0.

See also: Chapter 5 - Drawing & Typing.

Sub DrawPNG(X As Long, Y As Long, Path As String )
Draws a PNG picture specified by Path on top of a larger image and takes into account the PNG picture's alpha channel for better blending with the background. X and Y specify the horizontal and vertical offsets of the picture being drawn relative to the larger image. This method was introduced by version 1.7.

Starting with Version 1.8, DrawPNG also recognizes GIF format and should be used instead of the DrawImage method to render GIF images with transparency correctly.

See also: Section 6.3 - PNG Alpha Channel.

Sub DrawPNGBinary(X As Long, Y As Long, Image As Variant )
Same as DrawPNG except the Image being drawn is specified as a binary array of bytes as opposed to a file path. This method was introduced by version 1.7.

See also: Section 6.3 - PNG Alpha Channel.

Sub DrawQuad(X1 As Long, Y1 As Long, X2 As Long, Y2 As Long,X3 As Long, Y3 As Long,X4 As Long, Y4 As Long )
Draws a quadrilateral specified by the coordinates of its 4 corners using the current pen and brush. This method was introduced by version 2.0.

See also: Chapter 5 - Drawing & Typing.

Sub DrawRoundRect(Left As Long, Top As Long, Right As Long, Bottom As Long, CornerWidth As Long, CornerHeight As Long )
Draws a rectangle with rounded corners using the current pen and brush. The rectangle is specified by the coordinates of its upper-left and lower-right corners (in pixels). The corners are rounded by an ellipse with the width and height specified by CornerWidth andCornerHeight. This method was introduced by version 2.0.

See also: Chapter 5 - Drawing & Typing.

Sub Ellipse(Left As Long, Top As Long, Right As Long, Bottom As Long )
Same as DrawEllipse. Obsolete, supported for backwards compatibility only.
Function GetTextExtent(TextString As String, Optional Language = 1) As Long
Computes and returns the horizontal extent, in pixels, of the specified text string if rendered using the current font family, width and size. This method is useful for displaying centered text.

Note that the method PrintTextEx has built-in support for text alignment.

See also: Section 6.1 - Image Drawing.

Sub Line(x1 As Long, y1 As Long, x2 As Long, y2 As Long )
Same as DrawLine. Obsolete, supported for backwards compatibility only.
Sub Print(X As Long, Y As Long, TextString As String, Optional Language = 1 )
Prints TextString starting at (X, Y) using the current font.

Language is an optional parameter which should be used when TextString is in a language other than US ASCII. Valid values are:

0 (ANSI_CHARSET)
1 (DEFAULT_CHARSET)
2 (SYMBOL_CHARSET) 2
128 (SHIFTJIS_CHARSET)
129 (HANGEUL_CHARSET)
134 (GB2312_CHARSET)
136 (CHINESEBIG5_CHARSET)
255 (OEM_CHARSET)
130 (JOHAB_CHARSET)
177 (HEBREW_CHARSET)
178 (ARABIC_CHARSET)
161 (GREEK_CHARSET)
162 (TURKISH_CHARSET)
163 (VIETNAMESE_CHARSET)
222 (THAI_CHARSET)
238 (EASTEUROPE_CHARSET)
204 (RUSSIAN_CHARSET)
77 (MAC_CHARSET)
186 (BALTIC_CHARSET)

See also: Chapter 5 - Drawing & Typing.

Note: AspJpeg 1.8+ provides a more versatile PrintTextEx method described below.

Sub PrintText(X As Long, Y As Long, TextString As String, Optional Language = 1)
Same as Print. Added in AspJpeg 2.1.0.1 for compatibility with VB, as the name Print is a reserved word in VB and causes compile-time errors.
Function PrintTextEx(Text As String, X As Long, Y As Long, FontPath As String) As Long
Prints anti-aliased text using a TrueType/OpenType or Type 1 font specified by its physical path. Supports word wrapping, rotation, text alignment (to the left, right, center and justified) and adjustable line spacing. This method was introduced in Version 1.8 as a more versatile alternative to the PrintText method.

Text - specifies the text string to be printed (in Unicode format). May contain CR/LF characters for multi-line display.

X, Y - coordinates of the lower-left corner of the first character of the first line, relative to the upper-left corner of the image.

FontPath - specifies a physical path to the font file. The font does not need to be properly registered on the system as long as the path to the font file is known.

Additional optional parameters are specified via the Font object. The following Font properties affect PrintTextEx:

Font.Color - specifies the current text color as a Hex value. E.g. &HFF0000FF is blue.

Font.Rotation - specifies the rotation angle around the (X, Y) point in degrees. A positive value creates a counter-clockwise rotation.

Font.Size - specifies font size in pixels.

Font.Spacing - specifies an adjustment in pixels for the default line spacing when multi-line text is being rendered. A positive value increases the line spacing, a negative one decreases it.

Font.Width - specifies the width of an area in which the text string is to be inscribed. Word wrapping occurs if the text string does not fit in the area. This property must also be set if non-default text alignment is specified via Font.Align.

Font.Align - specifies text alignment. Valid values are: 0 - left (default), 1 - right, 2 - center, and 3 - justified. For values other than 0, Font.Width must also be specified.

Font.Opacity - specifies text opacity. Valid values are in the range [0, 1] with 0 meaning full transparency and 1 full opacity.

Returns the width (in pixels) of the text string being drawn. If the string is split into multiple lines, returns the width of the longest line. Starting with version 1.9, the height of the text paragraph just rendered can be obtained via the property ParagraphHeight.

For more information, see Section 5.3 - Advanced Text Drawing with PrintTextEx.

Home
Copyright © 1998 - 2007 Persits Software, Inc.
All Rights Reserved.
AspJpeg is a trademark of Persits Software, Inc.