JpegCanvas Object

Overview

The JpegCanvas 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 JpegImage object.

Member List

Properties


bool Antialiased (Read/Write)

True by default. If set to false, makes all drawing methods draw low-quality graphics without antialiasing.

See also: Chapter 5 - Drawing & Typing.


JpegBrush Brush (Read-only)

Returns the JpegBrush object which enables setting brush properties.

See also: Chapter 5 - Drawing & Typing.


JpegFont Font (Read-only)

Returns the JpegFont object which enables setting font properties.

See also: Chapter 5 - Drawing & Typing.


int ParagraphHeight (Read-only)

Returns the height (in pixels) of a text paragraph just rendered by a call to PrintText. 0 by default.

See also: Chapter 5 - Drawing & Typing.


JpegPen Pen (Read-only)

Returns the JpegPen object which enables setting pen properties.

See also: Chapter 5 - Drawing & Typing.


JpegUV UV (Read-only)

Returns the JpegUV object which encapsulates various 3D-surface mapping parameters.

See also: Chapter 11 - 3D Surface Mapping.

Methods


void ClearPath()

Clears the current path. A new path is to be populated via the methods MoveTo, LineTo and CurveTo. A path can be filled and stroked using the methods Fill and Stroke.

See also: Section 5.1 - Drawing: Overview.


void ClosePath()

Closes the current subpath by appending a straight line from the current point to the beginning of the subpath.

See also: Section 5.1 - Drawing: Overview.


void CurveTo(float x1, float y1, float x2, float y2, float x3, float y3)

Adds a Bezier curve to the current path using the current point as the beginning, point (x3, y3) as the ending, and points (x1, y1) and (x2, y2) as control points.

See also: Section 5.1 - Drawing: Overview.


void DrawArc(float x, float y, float Radius1, float Radius2, float Angle1, float Angle2, float TiltAngle)

Draws an arc with the center in (x, y), horizontal radius Radius1, vertical radius Radius2, beginning at the angle Angle1 relative to the horizontal axis of the ellipse, ending at the angle Angle2. The ellipse itself is tilted by an angle specified by TiltAngle. Uses the current pen's width, color, opacity and dash pattern.

See also: Section 5.2 - Shortcut Drawing Routines.


void DrawEllipse(float x, float y, float Radius1, float Radius2)

Draws an ellipse with the center in (x, y) and horizontal and vertical radii Radius1 and Radius2, respectively, using the current pen's width, color, opacity and dash pattern.

See also: Section 5.2 - Shortcut Drawing Routines


void DrawImage(int x, int y, JpegImage Image)
void DrawImage(int x, int y, JpegImage Image, double Opacity)
void DrawImage(int x, int y, JpegImage Image, uint TranspColor)
void DrawImage(int x, int y, JpegImage Image, uint TranspColor, uint TranspDeviation)
void DrawImage(int x, int y, JpegImage Image, double Opacity, uint TranspColor, uint TranspDeviation)

Draws an image on top of the current image. x and y are coordinates (in pixels) of the upper-left corner of Image within the current image. Image is another instance of the JpegImage object. If this image and/or Image have an alpha channel, they are taken into account during rendering.

If a 4-point path is defined prior to calling this method (a call to MoveTo followed by 3 calls to LineTo,) this method applies perspective projection to Image, and all arguments except Picture and Opacity are ignored.

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

TranspColor specifies the color of pixels within Image to be made transparent when blending the picture onto the current image. This must be an HTML-style hexadecimal number, e.g. 0xFF0000 (red). By default, no pixels will be made transparent, unless Image has an alpha channel.

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.

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, Section 6.3 - Perspective Projection.


void DrawImageChromaKey(int x, int y, JpegImage Image, int R, int G, int B, int Dist1, int Dist2)

Draws Image on the current image, removes the monochromatic background of the image being drawn by making it transparent to achieve the "chroma key" effect.

x and y are coordinates (in pixels) of the upper-left corner of Image within the current image.

Image is another instance of the JpegImage object representing the image with a monochromatic background, usually green or blue.

R, G, B are the RGB values (in the range [0, 255]) of the key color of the background.

Dist1, Dist2 are color distances controlling the range of colors to be made transparent. Chosen by trial and error. The values (20, 80) usually produce good results.

See also: Section 8.7 - Chroma Key.


void DrawImageUV(JpegImage Image)

Draws Image mapped to a 3D surface on the current image. The 3D surface equations as well as various other parameters pertaining to the 3D surface mapping process are specified via the JpegUV object obtainable from the JpegCanvas.UV property.

See also: Chapter 11 - 3D Surface Mapping.


void DrawLine(float x1, float y1, float x2, float y2)

Draws a line specified by the coordinates of its starting and ending points (in pixels) using the current pen's width, color, opacity and dash pattern.

See also: Section 5.2 - Shortcut Drawing Routines.


void DrawRect(float x, float y, float Width, float Height)

Draws a rectangle with the upper-left corner in (x, y) and specified Width and Height using the current pen's width, color, opacity, dash pattern and other parameters.

See also: Section 5.2 - Shortcut Drawing Routines.


void DrawRoundRect(float x, float y, float Width, float Height, float Rx, float Ry)

Draws a rectangle with rounded corners using the current pen's width, color, opacity and dash pattern. The rectangle is specified by the coordinates of its upper-left corner, width and height. The corners are rounded by an ellipse with the width and height specified by Rx and Ry.

See also: Section 5.2 - Shortcut Drawing Routines.


void DrawSegment(float x, float y, float Radius1, float Radius2, float Angle1, float Angle2, float TiltAngle)

Draws the segment of an ellipse with the center in (x, y), horizontal radius Radius1, vertical radius Radius2, beginning at the angle Angle1 relative to the horizontal axis of the ellipse, ending at the angle Angle2. The ellipse itself is tilted by an angle specified by TiltAngle. Uses the current pen's width, color, opacity, dash pattern and other parameters.

See also: Section 5.2 - Shortcut Drawing Routines.


void Fill()
void Fill(bool EvenOff)

Fills the current path using the current brush's color and opacity. If EvenOff is specified and set to true, the "even-odd" rule is used. By default, the nonzero winding number rule is used.

See also: Section 5.1 - Drawing: Overview.


void FillArc(float x, float y, float Radius1, float Radius2, float Angle1, float Angle2, float TiltAngle)

Fills an arc with the center in (x, y), horizontal radius Radius1, vertical radius Radius2, beginning at the angle Angle1 relative to the horizontal axis of the ellipse, ending at the angle Angle2. The ellipse itself is tilted by an angle specified by TiltAngle. Uses the current brush's color and opacity.

See also: Section 5.2 - Shortcut Drawing Routines.


void FillEllipse(float x, float y, float Radius1, float Radius2)

Fills an ellipse with the center in (x, y) and horizontal and vertical radii Radius1 and Radius2, respectively, using the current brush's color and opacity.

See also: Section 5.2 - Shortcut Drawing Routines.


void FillRect(float x, float y, float Width, float Height)

Fills a rectangle with the upper-left corner in (x, y) and specified Width and Height. using the current brush's color and opacity.

See also: Section 5.2 - Shortcut Drawing Routines.


void FillRoundRect(float x, float y, float Width, float Height, float Rx, float Ry)

Fills a rectangle with rounded corners using the current brush's color and opacity. The rectangle is specified by the coordinates of its upper-left corner, width and height. The corners are rounded by an ellipse with the width and height specified by Rx and Ry.

See also: Section 5.2 - Shortcut Drawing Routines.


void FillSegment(float x, float y, float Radius1, float Radius2, float Angle1, float Angle2, float TiltAngle)

Fill the segment of an ellipse with the center in (x, y), horizontal radius Radius1, vertical radius Radius2, beginning at the angle Angle1 relative to the horizontal axis of the ellipse, ending at the angle Angle2. The ellipse itself is tilted by an angle specified by TiltAngle. Uses the current brush's color and opacity.

See also: Section 5.2 - Shortcut Drawing Routines.


void FillStroke()
void FillStroke(bool EvenOff)

Fills and strokes the current path using the current pen and brush. If EvenOff is specified and set to true, the "even-odd" rule is used for the fill operation. By default, the nonzero winding number rule is used.

See also: Section 5.1 - Drawing: Overview.


void GetTextExtent(string Text, string FontPath)
void GetTextExtent(string Text, byte [] FontBytes)

Computes and returns the horizontal extent, in pixels, of the specified text string if rendered using the specified font, in a size specified by the JpegFont's Size property. This method is useful for displaying centered text.

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

See also: Section 6.1 - Image Drawing.


void LineTo(float x, float y)

Appends a straight line segment to the current path extending from the current point to (x, y).

See also: Section 5.1 - Drawing: Overview, Section 6.4 - Perspective Projection.


void MoveTo(float x, float y)

Starts a new subpath from the point with the coordinates (x, y).

See also: Section 5.4 - Anti-aliased Drawing Routines, Section 6.4 - Perspective Projection.


void PrintText(string Text, int x, int y, string FontPath)
void PrintText(string Text, int x, int y, string FontPath, int FontIndex)
void PrintText(string Text, int x, int y, byte [] FontBytes)
void PrintText(string Text, int x, int y, byte [] FontBytes, int FontIndex)

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.

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.

FontBytes - specifies a byte array containing the font to be used.

FontIndex - specifies the desired font index within the multi-font font (or byte array). 0 by default.

Additional optional parameters are specified via the JpegFont object. The following JpegFont properties affect PrintText:

JpegFont.Color - specifies the current text color as a Hex value. E.g. 0xFF0000FF is blue.

JpegFont.Rotation - specifies the rotation angle around the (x, y) point in degrees. A positive value creates a counter-clockwise rotation.

JpegFont.Size - specifies font size in pixels.

JpegFont.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.

JpegFont.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.

JpegFont.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.

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

JpegFont.Underline - specifies if the text should be underlined if set to true. The color and width of the underline should be specified separately via JpegPen.Color and JpegPen.Width, respectively.

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. The height of the text paragraph just rendered can be obtained via the property ParagraphHeight.

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


void Stroke()

Strokes the current path using the current pen's parameters.

See also: Section 5.1 - Drawing: Overview.