Xbasic

a5_ink_to_png Function

Syntax

a5_ink_to_png(C ink, N heightInPoints, N widthInPoints, C filename [, L flagUseViewBox [, C backgroundColor]])

Arguments

inkCharacter

the Ink data to be converted

heightInPointsNumeric

the height of the PNG image in points (72 points = 1 inch)

widthInPointsNumeric

the width of the PNG image in points

filenameCharacter

the filename of the PNG image

flagUseViewBoxLogical

Default = .F.. If .F., image will be sized to fit the ink drawing with a 20px border. If .T., the image will be sized to fit the entire ink page.

backgroundColorCharacter

The RGB code for the background color (#R,G,B), or an Alpha Anywhere color name. If blank (the default value) the background will be transparent.

Description

Generate a PNG image from Ink data.

Discussion

The Ink control (in the UX component) uses a special syntax for the Ink data. The a5_ink_to_png() function converts the ink data to a PNG image.

Example: Sizing the Image to the Ink Page

This function has a new parameter that lets you control how the image is created from the ink. By default, the image was bound to the size of the ink with a 20px border. You can set the flagUseViewBox parameter to .T. to size the image to the entire ink page, not just the bounds of the ink drawing. For example:

dim flagUseViewBox as L
flagUseViewBox = .t.

' Include the whole ink page in the generated png:
a5_ink_to_png(ink,300,500,"c:/temp/ink.png",flagUseViewBox)

Example: Setting the Background color

This example demonstrates setting the background color for the png image:

' An Ajax Callback example
' Get ink data from INK1 control in UX Component
dim ink as C = e.dataSubmitted.INK1

dim height as N = 300
dim width as N = 500
dim filename as C = "C:/temp/ink.png"

' Red:
dim backgroundColor as C = "#255,0,0"

' Also Red:
' backgroundColor = "red"

dim flagUseViewBox as L = .t.

' Convert ink to a PNG with a background color of "red"
a5_ink_to_png(ink,height,width,filename,flagUseViewBox,backgroundColor)