InkHelper
Previous Topic  Next Topic 

Product

InkHelper

Manufacturer

Standard Satellite Forms component

Website

http://www.satelliteforms.net/

Source code provided

Yes

Platform

PalmOS, PocketPC

Sample project(s)

InkHelper

Keywords

ink, BMP, bitmap, signature, hextext, binary


InkHelper provides utility functions for working with Ink fields.


InkHelper provides these functions:



1. IH_InkFieldToBitmap - Save the contents of an ink field to a BMP file.

USAGE: err=IH_InkFieldToBitmap( Tables("TableName").Fields("InkFieldName").Index, row, BMPfilename )

Specify a full path and name for the BMP file, eg. \My Documents\My App\signature_01.bmp

For PalmOS internal streamed files, do not use any path, just the case sensitive filename.



2. IH_InkFieldToHexText - Return the contents of an ink field as hextext.  The HexText can be converted back to binary data on the PC, and then displayed with the Satellite Forms Ink View ActiveX control (see the SatForms KnowledgeBase for Ink View help).

USAGE: hextext=IH_InkFieldToHexText( Tables("TableName").Fields("InkFieldName").Index, row )



3. IH_FileToHexText - Return the contents of a file as hextext.  It is intended for use with BMP files but can be used for any file (for PalmOS internal RAM files, only streamed databases such as BMP files created with IH_InkFieldToBitmap are suported, not regular prc/pdb databases).  The HexText can be converted back to the binary file on the PC.

USAGE: hextext=IH_FileToHexText( filename )

Specify a full path and name for the file, eg. \My Documents\My App\signature_01.bmp

For PalmOS internal streamed files, do not use any path, just the case sensitive filename.



4. IH_FileToUUEText - Return the contents of a file as uuencoded text.  It is intended for use with BMP files but can be used for any file (for PalmOS internal RAM files, only streamed databases such as BMP files created with IH_InkFieldToBitmap are suported, not regular prc/pdb databases).  The UUEText can be converted back to the binary file on the PC using any standard uudecoder algorithm or utility.

USAGE: uuetext=IH_FileToUUEText( filename )

Specify a full path and name for the file, eg. \My Documents\My App\signature_01.bmp

For PalmOS internal streamed files, do not use any path, just the case sensitive filename.



5. IH_FileToBinField - Import a file into a binary field.

USAGE: result=IH_FileToBinField( filename, Tables("TableName").Fields("BinaryFieldName").Index, row )

Specify a full path and name for the file, eg. \My Documents\My App\signature_01.bmp

The binary field specified should NOT be the ink binary field, and must be a different binary field. This function is intended for importing BMP files into the binary field directly.



6. IH_DeleteFile - Delete specified file (eg. delete a BMP after you are finished with it).

USAGE: err=IH_DeleteFile( fullpathandname )

Returns 0 if no err, 1 if there was an error deleting the file.  For PalmOS internal streamed files, do not use any path, just the case sensitive filename.



7. IH_PalmFileSettings - PalmOS Only. Specify PalmOS file settings used for other functions that access files. Call this function on PalmOS BEFORE the other functions that work with files.

USAGE: err=IH_PalmFileSettings( volumenumber, filetype, filecreatorid, filebackup )

Specify the volumenumber as:

0 - use internal (RAM) streamed files

1 - first VFS volume found

2 - 2nd VFS volume found

n - nth VFS volume found

filetype - Pass the 4-character case sensitive file type for streamed files.  For compatibility with the PalmDataPro SFInkView conduit, set the type to 'strm'.

filecreatorid - Pass the 4-character case sensitive creatorID for streamed files.  For compatibility with the PalmDataPro SFInkView conduit, set the creatorID to 'EWIV', otherwise use your application's creatorID.

filebackup - Pass True or False to set the backup bit on streamed files.  If the backup bit is set, the Palm Backup conduit will back up the BMP files as streamed file PDBs in the user's Backup folder. You can convert these streamed file PDBs to standard Windows BMPs using the freeware PAR utility.



8. IH_BMPColorSettings - Set foreground (pen) and background colors (8-bit RGB values) for monochrome BMP file.

USAGE: IH_BMPColorSettings( fgRed, fgGreen, fgBlue, bgRed, bgGreen, bgBlue )

The default color settings if none are specified are:

fgRed=0, bgGreen = 0, bgBlue = 0          (black)

bgRed=255, bgGreen = 255, bgBlue = 255    (white)

To invert the colors for printing with PrintBoy on WM5 devices, use

fgRed=255, fgGreen = 255, fgBlue = 255

bgRed=0, bgGreen = 0, bgBlue = 0

and set these colors via

IH_BMPColorSettings( 255, 255, 255, 0, 0, 0)




What is HexText?


HexText is an ASCII text representation of binary data, in which the hexadecimal value of each binary byte is converted to 2 ASCII characters that indicate the binary hex value.  For example, the single binary byte 0xA5 is represented in HexText as the ASCII string A5.  When the binary data is converted into HexText, it can then be transported via methods that only support plain text (for example using TCPIP sockets via the Internet or Winsock extensions, or POSTing to a web server using HTTP). The HexText can then be converted back into binary form on the destination/host system, for example converting the HexText back into a standard BMP file.


Here is sample Visual Basic desktop code to decode the hextext back to the source binary file, assumed to be a BMP file in this example:


Private Sub btnDecode_Click()

    Dim file_name As String

    Dim fnum As Integer

    Dim bytes() As Byte

    Dim txt As String

    Dim i As Integer

    Dim ch As String

    Dim num_values As Integer

    Dim num As Integer


    file_name = tbLoc.Text

    num_values = 0

    txt = ""

    fnum = FreeFile


    Open file_name For Input As #fnum

        Do While Not EOF(fnum)

            Line Input #fnum, txt

            For i = 1 To Len(txt)

                num_values = num_values + 1

                ReDim Preserve bytes(1 To num_values)

                ch = Mid$(txt, i, 2)

                num = CDec("&H" & ch)

                bytes(num_values) = num

                i = i + 1

            Next i

        Loop

    Close #fnum


    ' Save the file.

    fnum = FreeFile

    Open App.Path & "\my.bmp" For Binary As #fnum

    Put #fnum, 1, bytes

    Close #fnum

End Sub



DocID: 10195  DocDate: 2008-05-28