Image manipulation API - Draft

Unofficial Content

Current status

This is currently available on iOS only, in GeneXus Tero beta version. Android support is coming soon.

This document is a draft and may change in the future.

Introduction

Image manipulation is a quite common task in Smart Devices applications. Actions that are common include: resizing, scaling, rotating, cropping, flipping horizontally and vertically, etc.

To let you perform these actions on images, GeneXus adds some functions to the Image data type.

API

Properties

ImageWidth: Numeric

Read-only property. Returns the image's width in pixels.

&width = &image.ImageWidth

ImageHeight: Numeric

Read-only property. Returns the image's height in pixels.

&height = &image.ImageHeight

FileSize: Numeric

Read-only property. Returns the image's file size in bytes.

&fileSize = &image.FileSize

 

Methods

Resize

Returns a new image by resizing the original image.

Parameters:

  • width: Numeric, the width of the new image,
  • height: Numeric, the height of the new image,
  • keepAspect: Boolean, if set to True the image is resized using "fill keeping aspect", otherwise it uses "fill".
&resizedImage = &image.Resize(100, 100, true)

Scale

Returns a new image by scaling the original image by the specified percentage.

Parameters:

  • percentage: Numeric.
&scaledImage = &image.Scale(80)

Rotate

Returns a new image by rotating the original image by the specified angle. Valid angles are: 90, 180 and 270; other values are ignored.

Parameters:

  • angle: Numeric.
&rotatedImage = &image.Rotate(90)

Crop

Returns a new image by cropping the original image. The dimensions of the new image are determined from the square indicated by the parameters

Parameters:

  • left: Numeric, the left coordinate in pixels where the cropping begins,
  • top: Numeric, the top coordinate in pixels where the cropping begins,
  • width: Numeric, the width of the new image in pixels,
  • height: Numeric, the height of the new image in pixels.
&croppedImage = &image.Crop(0, 0, 50, 50)

FlipHorizontally

Flips the image horizontally.

&hFlippedImage = &image.FlipHorizontally()

FlipVertically

Flips the image vertically.

&vFlippedImage = &image.FlipVertically()