There are several things you need to know about providing an image resource in a Genero program.
Genero supports several image data formats, typically PNG, JPEG and SVG. Check the front-end platform documentation for supported image formats. True Type Font (TTF) files are also supported, the TTF format is used when image-to-font-glyph mapping is enabled by specifying a mapping file in the FGLIMAGEPATH environment variable.
Consider using the appropriate image resolution for the target front-end platform. For example, mobile devices have a much higher pixel density (a higher resolution) than desktop monitors. An image which looks nice on a desktop can appear small or as an upscaled image on a mobile device.
The image data can be provided in different ways, according to the image resource specification:
If the image specification starts with a URL prefix, the front-end will try to download the image from the location specified by the URL.
The network access to the web server must exist and network bandwidth must be sufficient to rapidly download the images.
Image resource location (URL) | Description |
---|---|
http://location-specification | HTTP server |
https://location-specification | HTTPS server (HTTP over SSL) |
If the image specification is a simple name (without a file extension), and the FGLIMAGEPATH environment variable defines an icon mapping file for the runtime system, the image name is converted to a font file and font glyph according to the mapping file entries, and the image form item displays that glyph/icon. The mapping file and the font definition file are centralized on the application server.
image-name=font-file:hexa-ordinal[:color-spec]
smiley=FontAwesome.ttf:f118 red_smiley=FontAwesome.ttf:f118:#8B0000
An image resource (IMAGE attribute, IMAGECOLUMN value, and so on) with the name "smiley" will be mapped to the glyph with ordinal position 0xf118 in the FontAwesome.ttf font file, and the image resources using "red_smiley" will use the same glyph, but will get a red color.
<StyleList> <Style name="Window.important"> <StyleAttribute name="defaultTTFColor" value="red" /> </Style> ...
A default mapping file named "image2font.txt" and the "FontAwesome.ttf" font file are provided in FGLDIR/lib. If FGLIMAGEPATH is not defined, the runtime system will use these files to make the image to font glyph mapping.
It is possible to mix several plain image file directories with several image-to-font glyph mapping files in FGLIMAGEPATH. The list of mapping files and directories defines the order of precedence, for example:
$ export FGLIMAGEPATH="/var/myapp/myimages:/var/myapp/myicons.txt:/var/myapp/fontfiles:$FGLDIR/lib/image2font.txt:$FGLDIR/lib"
-- /var/myapp/myimages: Directory where plain image files can be found
-- /var/myapp/myicons.txt: custom image-to-font-glyph mapping file (icons)
-- /var/myapp/fontfiles: Font files used by the myicons.txt mapping file
-- $FGLDIR/lib/image2font.txt: Genero default icon mapping files (using FontAwesome.ttf)
Consider defining your own image mapping file and make FGLIMAGEPATH point to your own files.
See FGLIMAGEPATH for more details about this environment variable.
If the image specification is a simple file path (without an URL prefix, and typically with an image file extension), the front-end gets the image file from the runtime system. The image file is searched on the platform where the program executes. The runtime system uses FGLIMAGEPATH environment variable when searching for the images. If FGLIMAGEPATH is not set, the current working directory is searched for the image files.
The front-end provides the name of the image file, and a list of supported file extensions. The runtime system searches for image files in different locations as described here: The search depends on the name of the image file, the list of directories defined in FGLIMAGEPATH, and the expected file extensions provided by the front-end.
For example:
The search for the image file would be as follows:
This search procedure using a proposal of file extensions was implemented to allow different type of front-ends to pass the type of image compression format required, so you can define the image name in your forms without any extension. However, it is much more efficient to specify the image file with a portable extension.
When FGLIMAGEPATH is defined, the current working directory is not searched. If you want to look for image files in the current working directory and in other directories, add "." to the FGLIMAGEPATH path list.
Web Components can display static images (part of the Web Component assets), and application images provided at runtime (for example, a photo gallery web component). In order to provide application images to a Web Component, the program must use the ui.Interface.filenameToURI() method to convert the local file name to a URI that can be accessed by the front-end.
For more details, see Using image resources with the gICAPI web component.