ImageObject QML Type
The ImageObject component provides means to transform and manipulate images. More...
Import Statement: | import ArcGIS.AppFramework 1.0 |
Properties
- asynchronous : 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(width)
- clear(width, int height)
- clear(width, int height, imageformat format)
- clip(rect)
- clip(x, int y, int width, int height)
- convertToFormat(format)
- convertToFormat(format, imageconversionflags flags)
- ImageObject convertedToFormat(format)
- ImageObject convertedToFormat(format, imageconversionflags flags)
- ImageObject copy(rect)
- ImageObject copy(x, int y, int width, int height)
- bool copyToClipboard()
- ImageObject create(width, int height)
- ImageObject create(width, int height, imageformat format)
- fill(color)
- invertPixels()
- invertPixels(invertMode)
- bool load(url)
- bool load(url, string format)
- bool load(path)
- bool load(path, string format)
- bool loadFromData(data)
- bool loadFromData(data, string format)
- mirror(horizontal, bool vertical)
- ImageObject mirrored(horizontal, bool vertical)
- bool pasteFromClipboard()
- color pixel(x, int y)
- rotate(angle)
- rotate(angle, int x)
- rotate(angle, int x, int y)
- rotate(angle, int x, int y, transformationmode transformationMode)
- ImageObject rotated(angle)
- ImageObject rotated(angle, int x)
- ImageObject rotated(angle, int x, int y)
- ImageObject rotated(angle, int x, int y, transformationmode transformationMode)
- bool save(url)
- bool save(url, string format)
- bool save(url, string format, int quality)
- bool save(path)
- bool save(path, string format)
- bool save(path, string format, int quality)
- scale(width, int height)
- scale(width, int height, aspectratiomode aspectRatioMode)
- scale(width, int height, aspectratiomode aspectRatioMode, transformationmode transformationMode)
- scaleToHeight(height)
- scaleToHeight(height, transformationmode transformationMode)
- scaleToWidth(width)
- scaleToWidth(width, transformationmode transformationMode)
- ImageObject scaled(width, int height)
- ImageObject scaled(width, int height, aspectratiomode aspectRatioMode)
- ImageObject scaled(width, int height, aspectratiomode aspectRatioMode, transformationmode transformationMode)
- ImageObject scaledToHeight(height)
- ImageObject scaledToHeight(height, transformationmode transformationMode)
- ImageObject scaledToWidth(width)
- ImageObject scaledToWidth(width, transformationmode transformationMode)
- setPixel(x, int y, color color)
- setText(key, string text)
- sync()
- string text()
- string text(key)
- var toArrayBuffer()
- var toArrayBuffer(format)
- var toArrayBuffer(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.
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.
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() function.
Name | Value |
---|---|
ImageObject.InvertRgb | 0 |
ImageObject.InvertRgba | 1 |
ImageFormat enumeration
This enum describes the format of the image bieng made. This 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.resolvedPath("file:" + imageObjectSaveUrl); } }
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
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(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(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) |
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(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(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(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.
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 a given file, reading it as the specified format.
The url parameter
Url to load the image from.
The format parameter
Format to read the image using, e.g. 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, e.g. "/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, e.g. "/FullApplicationPath/Application/Images/RedCircle.png" for macOS or Linux.
The format parameter
Format of the image, e.g. 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.
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(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.
ImageObject rotated(angle) |
Rotates the image clockwise.
The angle parameter
The angle to rotate the image clockwise, in degrees.
ImageObject rotated(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(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(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.
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.
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.
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.
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.
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.
ImageObject scaled(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(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.
ImageObject scaled(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.
The transformationMode parameter
0 to be performed quickly with no smoothing, 1 to use bilinear filtering to smooth image.
ImageObject scaledToHeight(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(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.
ImageObject scaledToWidth(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(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.
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().