Omnis Technical Note TNGI0007

Picture Conversion in Omnis 7

For Omnis 7.3 version 7
By Gary Ashford

How can I store, retrieve and display GIF and JPG files in Omnis 7?

This document describes how you can use Omnis 7 to read images from disk, store and display them. It is adapted from previously available readme and PDF source files and has been brought up-to-date with the latest functionality

It describes the
DisplayImage graphic utility, and the getpicfromimage() function.

DisplayImage

Availability:
Mac68K, PowerMac, Win16, Win32

DisplayImage is a graphic utility for use on an Omnis 7 extended area field. An extended area of this type can be used to display non-animated GIF or JPEG files, either directly by specifying a pathname or using a pre-loaded image.

The JPEG may be of any resolution and use any size of color palette from 256 to 16 million colors. The image does not adjust to fit a window. If there is an error, the image does not display and the extended area remains transparent.

Extended Area Parameters: Data Field Name, (Field Name)

Data Field Name: Not Used.
Field Name: The name of a character variable containing the full pathname of the GIF/JPEG file or the name of a binary variable containing the image data. Literal values for the pathname are not accepted.

Note: that for Win16, DisplayImage(FieldName) is entered in the Calculation field in the form of a function, e.g. DisplayImage(FV_ACHAR).

getpicfromimage()

Availability: Mac68K, PowerMac, Win32 only
Syntax: getpicfromimage(pathname, mode)

Returns a Picture variable. The pathname parameter is a variable name or literal containing the path name to the GIF or JPEG file, or a binary variable containing pre-loaded image data. The mode parameter is a value specifying how the pathname argument should be interpreted: 0 if pathname is a binary variable,
or 1 if it is a character field which specifies the filename.

getpicfromimage() is an external function which can load and convert a JPEG or GIF file into an Omnis Picture variable in a single action. This function is provided by the external Wgfx.dll. getpicfromimage()
can be used to convert an image which has been pre-loaded into an Omnis binary variable.
Conversion occurs one way; from GIF or JPEG to type 'Omnis Picture'.

To display a JPEG, add a picture field to the window or report, and make it calculated, using the result of the getpicfromimage() function.

Example:

<Local variable pic (Picture
Local variable bin (Binary)
Local variable path (Character 100)
Calculate pic as
         getpicfromimage('e:\test\2992fnl.jpg',1)

GetFile (path,"Locate a GIF/JPG file",
         pick(sys(6)="M","*.GIF;*.JPG",
         "GIFf,TEXT,text,????"))
ReadBinFile (path,bin)
Calculate pic as getpicfromimage(bin,0)


Download demo library