Equinox Online Help - Language Reference - A to Z

Home

ImportPicture

Applies to
SyntaxImportPicture PictureItem, FileExpression

Also

ImportPicture PictureItem, "CLIPBOARD", [ImageType], [hClip], [iSize]
ImportPicture PictureItem, "FILE", ImageType, hFile, [iSize]
ImportPicture PictureItem, "MEMORY", ImageType, hMem, [iSize]
Action[Statement] Imports a picture to a picture field.
Scope[Statement] Imports a picture to a picture field.
Notes

This statement imports an image to a specified picture field. PictureItem is the name of the picture field, in the current record. There are four forms of the ImportPicture statement, corresponding to the four sources from which you can read an image:

  • From a file path
  • From the Windows clipboard
  • From an open file handle
  • From an open memory handle

If you import the image from a file path, FileExpression is a string and identifies the image file name. If you do not specify a path for the file, Equinox searches the following directories (in the specified order):

  • The current directory
  • The Windows directory (for Windows installations only)
  • The Windows system directory (for Windows installations only)
  • The Equinox directory
  • Any other pathed directories

If you import the image from a file path, Equinox takes the file-type from the file extension used. If the type is "BMP", Equinox assumes that the file starts with a standard file header (referred to as a BITMAPFILEHEADER in the Windows SDK documentation) and removes it before storing the file in the database.

In order to import the file from the server, prepend "SERVER:" (in any case) to the FileExpression. This prefix is ignored by the single user version.

If you import the image from any of the other three sources, ImageType is a three-letter string which must match the file-type. It can be one of the following:

  • .bmp
  • .gif
  • .jpg
  • .png
  • .pcs
  • .tif
  • .wmf
  • .emf
  • .pax
  • .psd
  • .tla
  • .tga
  • .pcx

If you import the image from the Windows clipboard, Equinox assumes that the type is "BMP" (clipboard type CF_DIB) unless the ImageType parameter is supplied. The clipboard handle may be supplied if required.

If you import the image from an open file handle, the ImageType parameter must be supplied. You must also supply the file handle using hFile, having first obtained it using FileOpen in one of the binary (random) modes.

If you import the image from an open memory handle, the ImageType parameter must be supplied. You must also supply the memory handle using hMem, having first obtained it using GlobalAlloc.

The iSize parameter optionally determines the size of the image. If it is supplied as the wrong value, unpredictable results will occur. If it is not supplied, the image size is calculated as follows:

  • FileExpression - the size of the file
  • "CLIPBOARD" - the size of the clipboard item
  • "FILE" - the size of the rest of the file
  • "MEMORY" - the size of the memory block
CategoryPictures
See Also ErasePicture, ExportPicture, IsPicture, PictureSize, PictureType, SelectPicture, ShowPictures
Example

The following examples assume a picture field PicField, character workareas HandleType(3), MemType(3) and a numeric workarea MemHandle(8,0)

|* File Operations *|
ImportPicture PicField, "C:\EQUINOX\PICTURE\TEST.BMP"
if syserror then alert "ImportPicture from file failed"

|* Clipboard operations *|
ImportPicture PicField, "CLIPBOARD"
if syserror then alert "ImportPicture from clipboard failed"

|* File handle operations *|
block
handle hnd
int error

block
error = 1

if HandleType = "" then exit block
error = 2

FileOpen "C:\EQUINOX\PICTURE\HANDLE." & HandleType, RandomReadOnly, hnd
if syserror then exit block
error = 3

ImportPicture PicField, "FILE", HandleType, hnd
if syserror then exit block
error = 0
end block

FileCloseAll
if error then StatusLine "Assignment failed - error " & error
end block

|* Memory operations *|
block
int error

block
error = 1

if MemHandle = 0 or MemType = "" then exit block
error = 2

ImportPicture PicField, "MEMORY", MemType, MemHandle
if syserror then exit block
error = 0
end block

if MemHandle then GlobalFree MemHandle
MemHandle = 0

if error then
StatusLine "Assignment failed - error " & error
else
StatusLine "Ok"
end if
end block