The ImageObject component provides means to transform and manipulate images. More...
Import Statement: | import ArcGIS.AppFramework 1.0 |
Properties
- asynchronous : bool
- autoTransform : bool
- availableReadFormats : QStringList
- availableWriteFormats : QStringList
- bitPlaneCount : int
- byteCount : int
- canPasteFromClipboard : bool
- depth : int
- empty : bool
- exifInfo : ExifInfo
- format : ImageFormat
- hasAlphaChannel : bool
- height : int
- image : QImage
- size : size
- textKeys : QStringList
- textValues : object
- url : url
- width : int
Signals
Methods
- clear()
- clear(int width)
- clear(int width, int height)
- clear(int width, int height, imageformat format)
- clip(rect rect)
- clip(int x, int y, int width, int height)
- convertToFormat(imageformat format)
- convertToFormat(imageformat format, imageconversionflags flags)
- ImageObject convertedToFormat(imageformat format)
- ImageObject convertedToFormat(imageformat format, imageconversionflags flags)
- ImageObject copy(rect rect)
- ImageObject copy(int x, int y, int width, int height)
- bool copyToClipboard()
- ImageObject create(int width, int height)
- ImageObject create(int width, int height, imageformat format)
- fill(color color)
- invertPixels()
- invertPixels(invertmode invertMode)
- bool load(url url)
- bool load(url url, string format)
- bool load(string path)
- bool load(string path, string format)
- bool loadFromData(var data)
- bool loadFromData(var data, string format)
- mirror(bool horizontal, bool vertical)
- ImageObject mirrored(bool horizontal, bool vertical)
- bool pasteFromClipboard()
- color pixel(int x, int y)
- rotate(double angle)
- rotate(double angle, int x)
- rotate(double angle, int x, int y)
- rotate(double angle, int x, int y, transformationmode transformationMode)
- ImageObject rotated(double angle)
- ImageObject rotated(double angle, int x)
- ImageObject rotated(double angle, int x, int y)
- ImageObject rotated(double angle, int x, int y, transformationmode transformationMode)
- bool save(url url)
- bool save(url url, string format)
- bool save(url url, string format, int quality)
- bool save(string path)
- bool save(string path, string format)
- bool save(string path, string format, int quality)
- scale(int width, int height)
- scale(int width, int height, aspectratiomode aspectRatioMode)
- scale(int width, int height, aspectratiomode aspectRatioMode, transformationmode transformationMode)
- scaleToHeight(int height)
- scaleToHeight(int height, transformationmode transformationMode)
- scaleToWidth(int width)
- scaleToWidth(int width, transformationmode transformationMode)
- ImageObject scaled(int width, int height)
- ImageObject scaled(int width, int height, aspectratiomode aspectRatioMode)
- ImageObject scaled(int width, int height, aspectratiomode aspectRatioMode, transformationmode transformationMode)
- ImageObject scaledToHeight(int height)
- ImageObject scaledToHeight(int height, transformationmode transformationMode)
- ImageObject scaledToWidth(int width)
- ImageObject scaledToWidth(int width, transformationmode transformationMode)
- setPixel(int x, int y, color color)
- setText(string key, string text)
- sync()
- string text()
- string text(string key)
- var toArrayBuffer()
- var toArrayBuffer(string format)
- var toArrayBuffer(string format, int quality)
Detailed Description
The ImageObject component provides a hardware-independent image representation. On top of displaying the image and returning data from it, this component also contains tools to transform the image and direct access to the pixel data.
In this sample, the load method is enacted with a button to select an image from the device, with the height property displaying information about the image once it has been loaded.
App { id: app width: 400 height: 640 ColumnLayout { anchors { fill: parent margins: 10 } ImageObject { id: imageObject onUrlChanged: { console.log("url:", url); } onImageChanged: { console.log("image:", image); } } Text { text: imageObject.height color: "blue" font.bold: true } Button { text: "Load" onClicked: { loadDialog.open(); } } Image { fillMode: Image.PreserveAspectFit source: imageObject.url horizontalAlignment: Image.AlignHCenter verticalAlignment: Image.AlignVCenter cache: false } } FileDialog { id: loadDialog title: "Load Image" selectExisting: true selectMultiple: false nameFilters: [ "Image files (*.jpg *.png)", "All readable formats (" + imageObject.readFormats + ")", "All files (*)" ] folder: Qt.platform.os == "ios" ? "file:assets-library://" : AppFramework.standardPaths.standardLocations(StandardPaths.PicturesLocation)[0] onAccepted: { imageObject.load(fileUrl); } } }
Enumerations
AspectRatioMode enumeration
This enum type is used to describe how the aspect ratio of an image should be respected when scaling. Informs the scale and scaled properties.
Name | Value |
---|---|
ImageObject.AspectRatioIgnore | 0 |
ImageObject.AspectRatioKeep | 1 |
ImageObject.AspectRatioKeepByExpanding | 2 |
TransformationMode enumeration
This enum describes whether the process of transforming an image will prioritize speed or smoothness of image. Informs the rotate, rotated, scale, scaled, and scaleToWidth methods.
Name | Value |
---|---|
ImageObject.TransformationModeFast | 0 |
ImageObject.TransformationModeSmooth | 1 |
InvertMode enumeration
This enum type is used to describe how pixel values should be inverted in the invertPixels() method.
Name | Value |
---|---|
ImageObject.InvertRgb | 0 |
ImageObject.InvertRgba | 1 |
ImageFormat enumeration
This enum describes the format of the image bieng made. This enum informs the format property, which is called on in the convertToFormat(), convertedToFormat() and create() functions.
Name | Value |
---|---|
ImageObject.ImageFormatInvalid | 0 |
ImageObject.ImageFormatMono | 1 |
ImageObject.ImageFormatMonoLSB | 2 |
ImageObject.ImageFormatIndexed8 | 3 |
ImageObject.ImageFormatRGB32 | 4 |
ImageObject.ImageFormatARGB32 | 5 |
ImageObject.ImageFormatARGB32_Premultiplied | 6 |
ImageObject.ImageFormatRGB16 | 7 |
ImageObject.ImageFormatARGB8565_Premultiplied | 8 |
ImageObject.ImageFormatRGB666 | 9 |
ImageObject.ImageFormatARGB6666_Premultiplied | 10 |
ImageObject.ImageFormatRGB555 | 11 |
ImageObject.ImageFormatARGB8555_Premultiplied | 12 |
ImageObject.ImageFormatRGB888 | 13 |
ImageObject.ImageFormatRGB444 | 14 |
ImageObject.ImageFormatARGB4444_Premultiplied | 15 |
ImageObject.ImageFormatRGBX8888 | 16 |
ImageObject.ImageFormatRGBA8888 | 17 |
ImageObject.ImageFormatRGBA8888_Premultiplied | 18 |
ImageObject.ImageFormatBGR30 | 19 |
ImageObject.ImageFormatA2BGR30_Premultiplied | 20 |
ImageObject.ImageFormatRGB30 | 21 |
ImageObject.ImageFormatA2RGB30_Premultiplied | 22 |
ImageObject.ImageFormatAlpha8 | 23 |
ImageObject.ImageFormatGrayscale8 | 24 |
Property Documentation
If set to true, the image can be fetched from a network URL. Setting this to true also handles token-based authentication for secure images.
ImageObject { id: imgObject asynchronous: true onImageChanged: { imgObject.save(imageObjectSaveUrl); imgFromImageObject.source = ""; imgFromImageObject.source = AppFramework.resolvedPathUrl(imageObjectSaveUrl); } }
If set to true, honors the Orientation tag on the EXIF metadata within the JPEG image and appropriately rotates the image on load. This EXIF data can be retrieved using ExifInfo. The default value is false, meaning no automatic transformation occurs on load. If set to true, upon calling the load method it will update the EXIF data of the image so it reflects the orientation of the image after the rotation has been applied.
This property only functions using JPEG images.
Item { ImageObject { id: imgObject Layout.fillWidth: true autoTransform: false asynchronous: true onLoaded: { displayImage(imgObject, localImageUrl); } } CheckBox { id: autoTransformBox checked: false onCheckedChanged: { if (autoTransformBox.checked) { imgObject.autoTransform = true; } else { imgObject.autoTransform = false; } } } Button { id: loadImageBtn text: "Load From File Path" onClicked: { imgObject.load(documentDialog.fileUrl); } } }
Returns the image formats supported by the image reader.
Returns the image formats supported by the image writer.
Returns the number of bit planes in the image. The number of bit planes is the number of bits of color and transparency information for each pixel.
Returns true if there is an image in the clipboard that can be pasted to the ImageObject instance. Otherwise, returns false.
Returns the depth of the image. The image depth is the number of bits used to store a single pixel, also called bits per pixel (bpp).
Returns true if the given image file does not exist. Otherwise, returns false.
Returns true if the image has a format that supports the alpha channel.
Extracts and displays the key text associated with the image, through either PNG tEXt chunks or JPEG COM markers.
Depending on the file type, this will display differently. A PNG tEXt chunk contains key / value pairs, and so would return separately, as 'key="Name"' and 'value="Bruce", while a JPEG COM marker is a comment, and will return them in the format 'Name: Bruce'.
Windows devices are unable to view or edit PNG tEXt chunks or JPEG COM markers without third party software, due to a limitation of Windows Explorer. This property will still work on WIndows devices, however.
Signal Documentation
Signal emitted when the content of the image has been changed.
Note: The corresponding handler is onImageContentChanged
.
Signal emitted when an asynchronous load of an image object from a network request or asynchronous image provider completes. This signal is also emitted when the autoTransform property is set to true, because all automatic transforms on JPEG images are asynchronous.
Note: The corresponding handler is onLoaded
.
Signal emitted when the embedded text in the image has been changed.
Note: The corresponding handler is onTextChanged
.
Method Documentation
Replaces the image with a blank image of the given width.
The width parameter
The width of the blank image to generate, in pixels.
Replaces the image with a blank image of the given height and width.
The width parameter
The width of the blank image to generate, in pixels.
The height parameter
The height of the blank image to generate, in pixels.
Replaces the image with a blank image of the given height and width, in the defined image format.
The width parameter
The width of the blank image to generate, in pixels.
The height parameter
The height of the blank image to generate, in pixels.
The format parameter
The image format the blank image will be in.
Reduces the image down to the section outlined by the defined rectangle.
The rect parameter
The dimensions of the rectangle you're using to reduce the image.
Reduces the image down to the defined section.
The x parameter
The x (horizontal) coordinate of the target image area's starting point.
The y parameter
The y (vertical) coordinate of the target image area's starting point.
The width parameter
The width of the target area of the image, in pixels.
The height parameter
The height of the target area of the image, in pixels.
Converts the image into the defined format, without making a copy of it.
The format parameter
The format the image is to be converted to.
Converts the image into the defined format, without making a copy of it.
The format parameter
The format the image is to be converted to.
The flags parameter
Controls the format the image data is being converted into.
ImageObject convertedToFormat(imageformat format) |
Creates a new copy of the image in the defined format.
The format parameter
The format that the copy of the new image is being converted to.
ImageObject convertedToFormat(imageformat format, imageconversionflags flags) |
Creates a new copy of the defined image in the current format, respecting the given image conversion flags.
The format parameter
The format to convert the image to.
The flags parameter
Controls the format of the image data the copy is being made in.
ImageObject copy(rect rect) |
Returns a defined section of the image as a new image.
The rect parameter
The dimensions of the rectangle to copy the contents of.
ImageObject copy(int x, int y, int width, int height) |
Returns a defined section of the image as a new image.
The x parameter
The x (horizontal) coordinate of the copied area's starting point.
The y parameter
The y (vertical) coordinate of the copied area's starting point.
The width parameter
The width of the image to be copied, in pixels.
The height parameter
The height of the image to be copied, in pixels.
Copies the image in the ImageObject instance to the system clipboard.
ImageObject create(int width, int height) |
Crates and image object of the given height and width.
The width parameter
The width of the image you're creating, in pixels.
The height parameter
The height of the image you're creating, in pixels.
ImageObject create(int width, int height, imageformat format) |
Creates an image object of the given height and width, in the defined file format.
The width parameter
The width of the image you're creating, in pixels.
The height parameter
The height of the image you're creating, in pixels.
The format parameter
The file format you're going to create the image as, i.e. JPG.
Fills the entire image with the given color.
The color parameter
The hex value of the color to fill with.
Inverts the color values for all pixels in an image. To be used if the image's depth is 32.
The invertMode parameter
'InvertRgb' will leave the alpha channel unchanged, 'InvertRgba' will also invert the alpha channel. Informed by the InvertMode enum.
Loads an image from the given url, in the format the file's header describes.
The url parameter
URL to load the image from.
Returns the image from an image provider, from a base64 string, or from an HTTP or HTTPS web address, reading it as the specified format.
Item { property url httpImageObjectUrl: "http://localhost:8000/TestFolderforImageObject/9248x6936_Samsung_S21.jpg" ImageObject { id:imageObjectFromHttp Layout.fillWidth: true onLoaded: { console.error("Loaded....url"); displayImage(imageObjectFromHttp, localImageUrlNew); } } Button { id: loadImageFromHttpBtn text: "Load From url" onClicked: { fileFolder.removeFile(localImageUrlNew); imageObjectFromHttp.load(httpImageObjectUrl, "jpg"); busyIndicatorSpinner.running = true; } } }
The url parameter
URL to load the image from. This can accept three different formats, determined by the prefix used.
- image:// uses the specified image provider, or the default Qt image provider if none can be found. For example, image://arcgis/https://exampleorg.maps.arcgis.com/sharing/rest/content/items/f9559f47ecfb4a778384621a2c46ad1a/data
- data:// loads an image from a base64 string.
- http:// and https:// load an image from a network resource using a suitable network request. For example, https://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Image_created_with_a_mobile_phone.png/320px-Image_created_with_a_mobile_phone.png
The format parameter
The format the image is being loaded as, for example PNG, JPG
Loads an image from a file defined by the given string, using the format defined by the file's header.
The path parameter
The path to the file, for example "/FullApplicationPath/Application/Images/RedCircle.png" for macOS or Linux.
Loads an image using the given path, in the specified format.
The path parameter
The path to the file, for example "/FullApplicationPath/Application/Images/RedCircle.png" for macOS or Linux.
The format parameter
The format the image is being loaded as, for example PNG, JPG
Loads the image from the supplied data.
The data parameter
The data being loaded as an image. If this data is a string, it is assumed to be binary data encoded as a base64 string.
Loads the image from the supplied data, in the given format.
The data parameter
The data being loaded as an image. If this data is a string, it is assumed to be binary data encoded as a base64 string.
The format parameter
The format the image is being loaded as, e.g. PNG, JPG
Mirrors the image on either the horizontal axis, vertical axis, or both.
The horizontal parameter
If the image is to be flipped horizontally, true. Otherwise, false.
The vertical parameter
If the image is to be flipped vertically, true. Otherwise, false.
ImageObject mirrored(bool horizontal, bool vertical) |
Returns a mirror of the image as a new image object.
The horizontal parameter
If the image is to be flipped horizontally, true. Otherwise, false.
The vertical parameter
If the image is to be flipped vertically, true. Otherwise, false.
Pastes the image in the clipboard to the ImageObject instance, replacing the entire image.
Returns the color of the pixel at the given x,y coordinate.
The x parameter
The x (horizontal) coordinate of the pixel to be read.
The y parameter
The y (vertical) coordinate of the pixel to be read.
See also setPixel().
Rotates the image clockwise.
The angle parameter
The angle to rotate the image, in degrees.
Rotates the image clockwise, size scaled to the given x value while keeping aspect ratio the same.
The angle parameter
The angle to rotate the image, in degrees.
The x parameter
The width parameter.
Rotates the image clockwise, size scaled to the given x and y values.
The angle parameter
The angle to rotate the image, in degrees.
The x parameter
The width parameter.
The y parameter
The height parameter.
Rotates the image clockwise, size scaled to the given x and y values. Uses transformation mode to apply filtering.
The angle parameter
The angle to rotate the image, in degrees.
The x parameter
The width parameter.
The y parameter
The height parameter.
The transformationMode parameter
0 to be performed quickly with no smoothing, 1 to use bilinear filtering to smooth image. Informed by the TransformationMode enum.
ImageObject rotated(double angle) |
Rotates the image clockwise.
The angle parameter
The angle to rotate the image clockwise, in degrees.
ImageObject rotated(double angle, int x) |
Returns a rotated version of the image as a new image object, size scaled to the given x value while keeping aspect ratio the same.
The angle parameter
The angle to rotate the image clockwise, in degrees.
The x parameter
The width parameter.
ImageObject rotated(double angle, int x, int y) |
Returns a rotated version of the image as a new image object, size scaled to the given x and y values.
The angle parameter
The angle to rotate the image clockwise, in degrees.
The x parameter
The height parameter.
The y parameter
The height parameter.
ImageObject rotated(double angle, int x, int y, transformationmode transformationMode) |
Returns a rotated version of the image as a new image object, size scaled to the given x and y values. Uses transformation mode to apply filtering.
The angle parameter
The angle to rotate the image clockwise, in degrees.
The x parameter
The width parameter.
The y parameter
The height parameter.
The transformationMode parameter
0 to be performed quickly with no smoothing, 1 to use bilinear filtering to smooth image. Informed by the TransformationMode enum.
Saves the image to the given file url.
The url parameter
Url of the saved file's location.
Saves the image to the given file url, in the defined format.
The url parameter
Url of the saved file's location.
The format parameter
Format to save the image as, e.g. PNG, JPG.
Saves the image to the given file url, in the defined format and at the given level of quality.
The url parameter
Url of the saved file's location.
The format parameter
Format to save the image as, e.g. PNG, JPG.
The quality parameter
A value from 0 to 100, or -1. Numbers closer to 0 for small and compressed files, or closer to 100 for larger uncompressed files. -1 for default settings.
Saves the image to the given file path location.
The path parameter
The path to the file, e.g. "/FullApplicationPath/Application/Images/RedCircle.png" for macOS or Linux.
Saves the image to the given file path location, in the defined format.
The path parameter
The path to the file, e.g. "/FullApplicationPath/Application/Images/RedCircle.png" for macOS or Linux.
The format parameter
Format to save the image as, e.g. PNG, JPG.
Saves the image to the given file url, in the defined format. and at the given level of quality.
The path parameter
The path to the file, e.g. "/FullApplicationPath/Application/Images/RedCircle.png" for macOS or Linux.
The format parameter
Format to save the image as, e.g. PNG, JPG.
The quality parameter
A value from 0 to 100, or -1. Numbers closer to 0 for small and compressed files, or closer to 100 for larger uncompressed files. -1 for default settings.
Scales the image to the defined size, ignoring the aspect ratio.
The width parameter
Width to scale the image to, in pixels.
The height parameter
Height to scale the image to.
Scales the image to the defined size, according to given aspect ratio mode.
The width parameter
Width to scale the image to, in pixels.
The height parameter
Height to scale the image to, in pixels.
The aspectRatioMode parameter
0 to ignore, 1 to keep while scaling to a rectangle as large as possible while fitting both size parameters, 2 to keep while scaling to a rectangle as small as possible while fitting only one size parameter. Informed by the AspectRatioMode enum.
Scales the image to the defined size, according to given aspect ratio mode and transformation mode.
The width parameter
Width to scale the image to, in pixels.
The height parameter
Height to scale the image to, in pixels.
The aspectRatioMode parameter
0 to ignore, 1 to keep while scaling to a rectangle as large as possible while fitting both size parameters, 2 to keep while scaling to a rectangle as small as possible while fitting only one size parameter. Informed by the AspectRatioMode enum.
The transformationMode parameter
0 to ignore, 1 to keep while scaling to a rectangle as large as possible while fitting both size parameters, 2 to keep while scaling to a rectangle as small as possible while fitting only one size parameter. Informed by the TransformationMode enum.
Scales the image to the defined height, preserving aspect ratio. Does not make a copy, instead altering the image itself.
The height parameter
Height to scale the image to, in pixels.
Scales the image to the defined height, preserving aspect ratio. Uses transformation mode to apply filtering. Does not make a copy, instead altering the image itself.
The height parameter
Height to scale the image to, in pixels.
The transformationMode parameter
0 to be performed quickly with no smoothing, 1 to use bilinear filtering to smooth image. Informed by the TransformationMode enum.
Scales the image to the defined width, preserving aspect ratio. Does not make a copy, instead altering the image itself.
The width parameter
Width to scale the image to, in pixels.
Scales the image to the defined width, preserving aspect ratio. Uses transformation mode to apply filtering. Does not make a copy, instead altering the image itself.
The width parameter
Width to scale the image to, in pixels.
The transformationMode parameter
0 to be performed quickly with no smoothing, 1 to use bilinear filtering to smooth image. Informed by the TransformationMode enum.
ImageObject scaled(int width, int height) |
Returns a copy of the image scaled to a given size, ignoring the aspect ratio.
The width parameter
Width to scale the image to.
The height parameter
Height to scale the image to, in pixels.
ImageObject scaled(int width, int height, aspectratiomode aspectRatioMode) |
Returns a copy of the image scaled to a defined size, according to given aspect ratio mode.
The width parameter
Width to scale the image to, in pixels.
The height parameter
Height to scale the image to, in pixels.
The aspectRatioMode parameter
0 to ignore, 1 to keep while scaling to a rectangle as large as possible while fitting both size parameters, 2 to keep while scaling to a rectangle as small as possible while fitting only one size parameter. Informed by the AspectRatioMode enum.
ImageObject scaled(int width, int height, aspectratiomode aspectRatioMode, transformationmode transformationMode) |
Returns a copy of the image scaled to a defined size, and according to aspect ratio mode and transformation mode.
The width parameter
Width to scale the image to, in pixels.
The height parameter
Height to resize the image to, in pixels.
The aspectRatioMode parameter
0 to ignore, 1 to keep while scaling to a rectangle as large as possible while fitting both size parameters, 2 to keep while scaling to a rectangle as small as possible while fitting only one size parameter. Informed by the AspectRatioMode enum.
The transformationMode parameter
0 to be performed quickly with no smoothing, 1 to use bilinear filtering to smooth image. Informed by the TransformationMode enum.
ImageObject scaledToHeight(int height) |
Returns a copy of the image scaled to the defined height, preserving aspect ratio.
The height parameter
Height to scale the image to, in pixels.
ImageObject scaledToHeight(int height, transformationmode transformationMode) |
Returns a copy of the image scaled to the defined height, preserving aspect ratio. Uses transformation mode to apply filtering.
The height parameter
Height to scale the image to, in pixels.
The transformationMode parameter
0 to be performed quickly with no smoothing, 1 to use bilinear filtering to smooth image. Informed by the TransformationMode enum.
ImageObject scaledToWidth(int width) |
Returns a copy of the image scaled down to the defined width, preserving aspect ratio.
The width parameter
Width to scale the image to, in pixels.
ImageObject scaledToWidth(int width, transformationmode transformationMode) |
Returns a copy of the image scaled to the defined width, preserving aspect ratio. Uses transformation mode to apply filtering.
The width parameter
Width to scale the image to, in pixels.
The transformationMode parameter
0 to be performed quickly with no smoothing, 1 to use bilinear filtering to smooth image. Informed by the TransformationMode enum.
Sets the pixel at the defined position to the defined color.
The x parameter
The x (horizontal) coordinate of the pixel to be colored.
The y parameter
The y (vertical) coordinate of the pixel to be colored.
The color parameter
The hex value or name of the color to set the pixel to. For example, '#1925c1' or 'blue'.
See also pixel().
Sets the image's embedded text and associates it with the given key.
The key parameter
Key to associate the text to.
The text parameter
Text to embed in the image.
See also text().
Emits the ImageContentChanged signal without changing anything. This function is intended to 'remind' the application of programs it may not have picked up.
Returns the image text associated with the given key.
The key parameter
Key that the text will be called from.
See also setText().
Saves an image directly into a byte array, which is returned as an array buffer in the defined format.
The format parameter
The format to save the image into. Informed by the ImageFormat enum.
Saves an image directly into a byte array, which is returned as an array buffer in the defined format and at the given level of quality.
The format parameter
The format to save the image into. Informed by the ImageFormat enum.
The quality parameter
The quality level to save the image at.