The task of image manipulation is quite common in applications that handle images. Common actions include: resizing, scaling, rotating, cropping, flipping horizontally and vertically, etc.
To allow the performance of such actions on images, GeneXus has added certain functions to the Image data type.
Read-only property. Returns the image width in pixels.
&width = &image.ImageWidth
Read-only property. Returns the image height in pixels.
&height = &image.ImageHeight
Read-only property. Returns the image's file size in bytes.
&fileSize = &image.FileSize
Returns a new image by resizing the original image.
Parameters:
- Width: Numeric - width of the new image,
- Height: Numeric - height of the new image,
- KeepAspect: Boolean, when set to True, the image is resized using "fill keeping aspect". Otherwise, "fill" is used.
&resizedImage = &image.Resize(100, 100, true)
Returns a new image by scaling the original image to the specified percentage.
Parameters:
&scaledImage = &image.Scale(80)
Returns a new image by rotating the original image in the specified angle. Valid angles are 90, 180, and 270 degrees; other values are ignored.
Parameters:
&rotatedImage = &image.Rotate(90)
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 - left coordinate in pixels where the cropping begins.
- Top: Numeric - top coordinate in pixels where the cropping begins.
- Width: Numeric - width of the new image in pixels.
- Height: Numeric - height of the new image in pixels.
&croppedImage = &image.Crop(0, 0, 50, 50)
Flips the image horizontally.
&hFlippedImage = &image.FlipHorizontally()
Flips the image vertically.
&vFlippedImage = &image.FlipVertically()
These properties and methods are available:
Image data type