Skip to main content
Version: v20 R4 BETA

Picture

A Picture field, variable or expression can be any Windows or Macintosh picture. In general, this includes any picture that can be put on the pasteboard or read from the disk using 4D commands such as READ PICTURE FILE.

4D uses native APIs to encode (write) and decode (read) picture fields and variables under both Windows and macOS. These implementations provide access to numerous native formats, including the RAW format, currently used by digital cameras.

  • on Windows, 4D uses WIC (Windows Imaging Component).
  • on macOS, 4D uses ImageIO.

WIC and ImageIO permit the use of metadata in pictures. Two commands, SET PICTURE METADATA and GET PICTURE METADATA, let you benefit from metadata in your developments.

Picture Codec IDs

4D supports natively a wide set of picture formats, such as .jpeg, .png, or .svg.

Picture formats recognized by 4D are returned by the PICTURE CODEC LIST command as picture Codec IDs. They can be returned in the following forms:

  • As an extension (for example “.gif”)
  • As a MIME type (for example “image/jpeg”)

The form returned for each format will depend on the way the Codec is recorded at the operating system level. Note that the list of available codecs for reading and writing can be different since encoding codecs may require specific licenses.

Most of the 4D picture management commands can receive a Codec ID as a parameter. It is therefore imperative to use the system ID returned by the PICTURE CODEC LIST command. Picture formats recognized by 4D are returned by the PICTURE CODEC LIST command.

Picture operators

OperationSyntaxReturnsAction
Horizontal concatenationPict1 + Pict2PictureAdd Pict2 to the right of Pict1
Vertical concatenationPict1 / Pict2PictureAdd Pict2 to the bottom of Pict1
Exclusive superimpositionPict1 & Pict2PictureSuperimposes Pict2 on top of Pict1 (Pict2 in foreground). Produces the same result as COMBINE PICTURES(pict3;pict1;Superimposition;pict2)
Inclusive superimpositionPict1 | Pict2PictureSuperimposes Pict2 on Pict1 and returns resulting mask if both pictures are the same size. Produces the same result as $equal:=Equal pictures(Pict1;Pict2;Pict3)
Horizontal movePicture + NumberPictureMove Picture horizontally Number pixels
Vertical movePicture / NumberPictureMove Picture vertically Number pixels
ResizingPicture * NumberPictureResize Picture by Number ratio
Horizontal scalingPicture *+ NumberPictureResize Picture horizontally by Number ratio
Vertical scalingPicture *| NumberPictureResize Picture vertically by Number ratio

Notes :

  • In order to use the | operator, Pict1 and Pict2 must have exactly the same dimension. If both pictures are a different size, the operation Pict1 | Pict2 produces a blank picture.
  • The COMBINE PICTURES command can be used to superimpose pictures while keeping the characteristics of each source picture in the resulting picture.
  • Additional operations can be performed on pictures using the TRANSFORM PICTURE command.
  • There is no comparison operators on pictures, however 4D proposes the Equal picture command to compare two pictures.

Examples

Horizontal concatenation

 circle+rectangle //Place the rectangle to the right of the circle
rectangle+circle //Place the circle to the right of the rectangle

Vertical concatenation

 circle/rectangle //Place the rectangle under the circle
rectangle/circle //Place the circle under the rectangle

Exclusive superimposition

Pict3:=Pict1 & Pict2 // Superimposes Pict2 on top of  Pict1

Inclusive superimposition

Pict3:=Pict1|Pict2 // Recovers resulting mask from superimposing two pictures of the same size

Horizontal move

rectangle+50 //Move the rectangle 50 pixels to the right
rectangle-50 //Move the rectangle 50 pixels to the left

Vertical move

rectangle/50 //Move the rectangle down by 50 pixels
rectangle/-20 //Move the rectangle up by 20 pixels

Resize

rectangle*1.5 //The rectangle becomes 50% bigger
rectangle*0.5 //The rectangle becomes 50% smaller

Horizontal scaling

circle*+3 //The circle becomes 3 times wider
circle*+0.25 //The circle's width becomes a quarter of what it was

Vertical scaling

circle*|2 //The circle becomes twice as tall
circle*|0.25 //The circle's height becomes a quarter of what it was