2.8 tile (pattern)

Graphics, pictures and patterns used within the IDM must be declared as resources. The keyword for this is tile, followed by an identifier and the tile definition. The tile definition is either included directly in the IDM file or in a separate graphics file.

Definition

{ export | reexport } tile <Identifier> <tileSpec> | <variantDef> <scaleMode>
tileSpec ::= <tileBitmap> | "<file path>" | "<graphics resource>" { scale | 
		noscale | numscale | propscale | dpiscale } { smooth }

 

tileBitmap ::= <x>, <y>,
               "<pattern line>"
           [ , "<pattern line>" ]
variantDef ::=
{
           0 :  <tileSpec> 
  [ <number> :  <tileSpec> ]
}

For the definition of variants it is recommended to always define a variant with the number 0, since this is the default variant if no variant, a non-existent variant, or an invalid variant is set. The other numbers may be arbitrary natural numbers.

The tile variant to be used can be set with the command line option -IDMtile when starting the application. During runtime of the application it can be queried and set with the .tile attribute of the setup object.

2.8.1 Internal pattern (Bitmap)

<x> and <y> represent the number of pixels in horizontal and vertical direction. Width (<x>) and height (<y>) may be chosen arbitrarily.

<pattern line> denotes a string of <x> characters in which each character represents one pixel of the tile. Only rectangular tiles are possible, therefore exactly <y> pattern lines with <x> characters each have to be defined.

The pattern lines consist of the characters period (.) space ( ) and hash (#), which have the following meaning:

.

Adopts the background color, i.e. the pattern will be transparent at this point.

If the tile resource is used in the .picture or .picture[enum] attributes of an image object whose .imagebgc attribute is set, a pixel in the color .imagebgc is displayed here.

#

At this point, a pixel in the foreground color will be displayed.

When using the tile resource in the .picture or .picture[enum] attributes of an image object, this will be the color set in the .imagefgc attribute of the image object.

Example for the Definition of an Internal Pattern

tile TiGray 16, 16,
  "# # # # # # # # ",
  " # # # # # # # #",
  "# # # # # # # # ",
  " # # # # # # # #",
  "# # # # # # # # ",
  " # # # # # # # #",
  "# # # # # # # # ",
  " # # # # # # # #",
  "# # # # # # # # ",
  " # # # # # # # #",
  "# # # # # # # # ",
  "# # # # # # # # ",
  " # # # # # # # #",
  "# # # # # # # # ";

Note for Qt:

When using an internal pattern as a menu or notepage images please note that the scalestyle_none does not lead to a real 1:1 pixel representation as using an image file.

We advise against using internal patterns as window icons, because it can lead to faulty interactions when used in parallel with other object classes, such as menus.

2.8.2 External pattern

With the definition using a file name (including path), the IDM assumes that the definition of the tile is in a separate graphics file. The IDM loads the corresponding file and displays its contents using the system functions of the respective toolkit. Therefore it depends on the platform which graphics formats can be displayed.

The following table shows which graphics formats are supported on each platform:

Table 20-4: Graphics formats supported by the tile resource

Graphics Format

File Extension

Microsoft Windows

Motif

Qt

Graphics Interchange Format

.gif

yes

yes

yes

Device Independent Bitmap

.bmp

yes

no

yes

X PixMap

.xpm

no

since Motif 2.1

no

JPEG File Interchange Format

.jpg

yes

since Motif 2.3

yes

Portable Network Graphics

.png

yes

since Motif 2.3

yes

Enhanced Metafile
Windows Metafile

.emf
.wmf

yes

no

no

Aldus Placeable Metafile

.apm

yes

no

no

Windows Icon Resource File

.ico

yes

no

no

Windows Icon Resource
Windows Bitmap Resource

yes

no

no

Scalable Vector Graphics .svg yes no

yes

The definition using a graphics resource is only supported by the IDM for Windows. The identifiers IDM_AppIcon and IDM_DefIcon of the resources defined in the IDM libraries may be used here (see also attribute .icon in the “Attribute Reference”).

Additionally, on Microsoft Windows, the following identifiers for predefined bitmap resources of the system can be specified:

BTNCORNERS

BTSIZE

CHECK

CHECKBOXES

CLOSE

COMBO

DNARROW

DNARROWD

DNARROWI

LFARROW

LFARROWD

LFARROWI

MNARROW

OLD_CLOSE

OLD_DNARROW

OLD_LFARROW

OLD_REDUCE

OLD_RESTORE

OLD_RGARROW

OLD_UPARROW

OLD_ZOOM

REDUCE

REDUCED

RESTORE

RESTORED

RGARROW

RGARROWD

RGARROWI

SIZE

UPARROW

UPARROWD

UPARROWI

ZOOM

ZOOMD

 

Note

The images of the tile resource are now automatically enlarged according to the configured scaling factor. It is assumed hereby that the images were designed for a DPI value of 96. If the images of the application are designed for a higher resolution, then this can be set in the setup object with the attribute .tiledpi.

When specifying an external file, it is recommended not to define the absolute path but rather to use an environment variable, e.g. "IDM_IMAGEPATH:Check.gif".

Other graphics formats can be processed using a self-implemented graphics handler (GFX handler; see function DM_PictureHandler in manual “C Interface - Functions”).

2.8.3 Scaling

By specifying a scalestyle in the tile definition, the tile or picture will be resized to fit the available space according to specific criteria.

The .scalestyle attribute determines the type of scaling of the pattern or image.

Definition on Tile Dynamic setting Meaning
noscale scalestyle_none

The pattern or image is not scaled. .tiledpi has no impact.

scale scalestyle_any

The height and width of the pattern or image are fully enlarged to fit the available area.

propscale scalestyle_prop

Height and width of the pattern or image are enlarged to the available area, while height and width proportions of the pattern or image are maintained in any case. I.e. free spaces can be created above and below or left and right.

numscale scalestyle_num

The scaling of the pattern or image is done by a numerical scaling divider. The scaling is done in quarter steps, i.e. 1.25-fold, 1.5-fold, 1.75-fold, 2-fold, 2.25-fold, 2.5-fold, and so on.
A downscaling is done down to a maximum of 0.25-fold.

dpiscale scalestyle_dpi

The pattern or image is always scaled according to the set screen scaling.

Not provided

scalestyle_auto

The pattern or image is scaled according to the set screen scaling. A scaling compatible to the previous version takes place. Default value

See also

Attribute .scalestyle in manual “Attribute Reference”

Best practice: If possible, patterns should already be available in the correct or used size, as any scaling is associated with a loss of sharpness or richness of detail.

2.8.4 Smooth Scaling

Scaling pixel images is usually necessary to display images in the desired size on the user interface or to prepare images for the current scaling level of the desktop.

By default, the IDM uses the fastest scaling algorithm, "Nearest Neighbor," for this scaling or image transformation. This algorithm duplicates existing pixel values ​​(when enlarging) or omits pixels (when shrinking).

By using the smooth keyword on the tile resource, you can explicitly switch to an interpolating scaling algorithm for this tile. This algorithm calculates missing pixels from neighboring pixels or "computes" multiple pixels when resizing.

Both scaling algorithms have their advantages and disadvantages and should be chosen according to the image content as well as the possible scaling sizes.

Example

Original

Nearest Neighbour / Fast Scaling

Interpolated / Smooth Scaling

Magnification to 200% and 125%

Reduction to 75% and 50%

Advantages

Contrast is maintained

Even with minimal maginification/reduction, the image impression remains intact

Interpolation reduces stair-stepping

When reducing, image content remains visible

Disadvantages

When enlarged, they appear "pixelated" or displayed like "stairs"

Loss of information when reducing

High-contrast images appear blurry, even when zoomed in/out minimally

For optimal image quality, it's recommended to provide images in multiple sizes or scaling levels. This can be done as a resource variant, as a HiDPI image variant using @nx-additional images (n = 2...9), or, on Windows, as an icon resource with multiple image variants. Alternatively, vector images in SVG format are also recommended.

2.8.5 Dynamically Changeable Attributes

The modifiable attributes can be found in the following table. It should be noted that .name on the one hand and .width, .height and .pattern on the other hand are mutually exclusive, so that get leads to a can't get value error message.

For variant tile resources, the attributes of the current tile variant are accessed; the current variant can be queried and set using the .tile attribute of the setup object.

Table 20-5: Modifiable attributes of the tile resource

Attribute

Data Type

Index Range

Description

.name

string

File path of an image file.

.width

integer

Width of the pattern in pixels.

.height

integer

Height of the pattern in pixels.

.pattern

string

Complete pattern as string.

.pattern[integer]

string

1 … .height

Single lines of the pattern.

The length of each string must be equal to .width.

.scale

boolean

Resizing to the available space.

Default value false (no resizing).

.scalestyle

enum

Controls the display and scaling of a tile.

Default value scalestyle_auto

.smooth_rescale

boolean

Enables interpolating scaling

Default value false

2.8.6 SVG Support

On Windows and Qt, the tile resource now also supports vector images in SVG format.

2.8.6.1 Notes for Qt

The .svg file extension is recognized as a SVG image format and vector-based drawing is used when displaying it in the various objects. This ensures the best possible reproduction of vector images for applications that are displayed on HiDPI screens.

For performance reasons, the pixel-based proxy image is used when drawing background tiles of grouping objects in the tilestyle_tiled style.

Installation note: The Qt package qt5-qtsvg must already be installed in order to make the corresponding SVG support library available and to ensure that an IDM application can be started.

2.8.6.2 Notes for Windows

Microsoft Direct2D is used to ensure the support of graphic formats. The SVG support of Microsoft Direct2D depends on the Microsoft Windows version. As of the Windows 10 Creators Update, support is provided in a limited form.

It is recommended to only use icon definitions with the same color depth in an icon file or icon resource, because it cannot be guaranteed that the image with the higher color depth will be used if the image size is the same. If different color depths are required, use a second icon file or icon resource and utilize the IDM's variant mechanism.

As Direct2D package uses different scaling methods than the Windows GDI, patterns (images) that need to be scaled for display may look different than in the previous versions of the IDM. This applies in particular to patterns that are used as window icons or as images in the treeview and notepage objects, as Microsoft Windows requires the icon data type here. It is recommended to use an icon file or an icon resource for treeview and notepage objects and window icons.

The SVG support with Microsoft Direct2D

Support depends on the Microsoft Windows version. As of the Windows 10 Creators Update, the following SVG elements and attributes are supported:

Element

Supported attributes

circle

id, style, transform, cx, cy, r

clipPath

id, style, transform, clipPathUnits

defs

id, style, transform

desc

id

ellipse

id, style, transform, cx, cy, rx, ry

g

id, style, transform

image

id, style, transform, x, y, width, height, preserveAspectRatio, xlink:href

line

id, style, transform, x1, y1, x2, y2

linearGradient

id, style, x1, y1, x2, y2, gradientUnits, gradientTransform, spreadMethod, xlink:href

path

id, style, transform, d

polygon

id, style, transform, points

polyline

id, style, transform, points

radialGradient

id, style, cx, cy, r, fx, fy, gradientUnits, gradientTransform, spreadMethod, xlink:href

rect

id, style, transform, x, y, width, height, rx, ry

stop

id, style, offset

svg

id, style, x, y, width, height, viewBox, preserveAspectRatio

title

id

use

id, style, transform, x, y, width, height, xlink:href

SVG presentation attributes

- clip-path

- clip-rule

- color

- display

- fill

- fill-opacity

- fill-rule

- opacity

- overflow

- stop-color

- stop-opacity

- stroke

- stroke-dasharray

- stroke-dashoffset

- stroke-linecap

- stroke-linejoin

- stroke-miterlimit

- stroke-opacity

- stroke-width

- visibility

Supported length units

The user-space length values and percentage length values as well as absolute unit identifiers: px, pt, pc, cm, mm and in.

Image sources

The image element is only supported if its xlink:href attribute is set to a base64-encoded Image.

See also: https://learn.microsoft.com/en-us/windows/win32/direct2d/svg-support

Also see A.06.03.a