ArcGIS for Developers

ImageObject QML Type

The ImageObject component provides means to transform and manipulate images. More...

Import Statement: import ArcGIS.AppFramework 1.0

Properties

Signals

Methods

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.

NameValue
ImageObject.AspectRatioIgnore0
ImageObject.AspectRatioKeep1
ImageObject.AspectRatioKeepByExpanding2

TransformationMode enumeration

This enum describes whether the process of transforming an image will prioritize speed or smoothness of image.

NameValue
ImageObject.TransformationModeFast0
ImageObject.TransformationModeSmooth1

InvertMode enumeration

This enum type is used to describe how pixel values should be inverted in the invertPixels() function.

NameValue
ImageObject.InvertRgb0
ImageObject.InvertRgba1

ImageFormat enumeration

This enum describes the format of the image bieng made. This is called on in the convertToFormat(), convertedToFormat() and create() functions.

NameValue
ImageObject.ImageFormatInvalid0
ImageObject.ImageFormatMono1
ImageObject.ImageFormatMonoLSB2
ImageObject.ImageFormatIndexed83
ImageObject.ImageFormatRGB324
ImageObject.ImageFormatARGB325
ImageObject.ImageFormatARGB32_Premultiplied6
ImageObject.ImageFormatRGB167
ImageObject.ImageFormatARGB8565_Premultiplied8
ImageObject.ImageFormatRGB6669
ImageObject.ImageFormatARGB6666_Premultiplied10
ImageObject.ImageFormatRGB55511
ImageObject.ImageFormatARGB8555_Premultiplied12
ImageObject.ImageFormatRGB88813
ImageObject.ImageFormatRGB44414
ImageObject.ImageFormatARGB4444_Premultiplied15
ImageObject.ImageFormatRGBX888816
ImageObject.ImageFormatRGBA888817
ImageObject.ImageFormatRGBA8888_Premultiplied18
ImageObject.ImageFormatBGR3019
ImageObject.ImageFormatA2BGR30_Premultiplied20
ImageObject.ImageFormatRGB3021
ImageObject.ImageFormatA2RGB30_Premultiplied22
ImageObject.ImageFormatAlpha823
ImageObject.ImageFormatGrayscale824

Property Documentation

[read-only] availableReadFormats : QStringList

Returns the image formats supported by the image reader.


[read-only] availableWriteFormats : QStringList

Returns the image formats supported by the image writer.


[read-only] bitPlaneCount : int

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.


[read-only] byteCount : int

Returns the number of bytes occupied by the image data.


[read-only] canPasteFromClipboard : bool

Returns true if there is an image in the clipboard that can be pasted to the ImageObject instance. Otherwise, returns false.


[read-only] depth : int

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).


[read-only] empty : bool

Returns true if the given image file does not exist. Otherwise, returns false.


[read-only] exifInfo : ExifInfo

Returns the ExifInfo metadata of the image.


[read-only] format : ImageFormat

Returns the format of the image.


[read-only] hasAlphaChannel : bool

Returns true if the image has a format that supports the alpha channel.


[read-only] height : int

Returns the height of the image, in pixels.


image : QImage

Returns the image itself.


[read-only] size : size

Returns the width and height of the image, in pixels.


[read-only] textKeys : QStringList

Returns the text keys for the image.


[read-only] textValues : object

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.


[read-only] url : url

Returns the url of the image.


[read-only] width : int

Returns the width of the image, in pixels.


Signal Documentation

imageContentChanged()

Signal emitted when the content of the image has been changed.


textChanged()

Signal emitted when the embedded text in the image has been changed.


Method Documentation

clear()

Replaces the image with a blank image file.


clear(width)

Replaces the image with a blank image of the given width.

The width parameter

The width of the blank image to generate, in pixels.


clear(width, int height)

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.


clear(width, int height, imageformat format)

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.


clip(rect)

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.


clip(x, int y, int width, int height)

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.


convertToFormat(format)

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.


convertToFormat(format, imageconversionflags flags)

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.


bool copyToClipboard()

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.


fill(color)

Fills the entire image with the given color.

The color parameter

The hex value of the color to fill with.


invertPixels()

Inverts the color values for all pixels in an image.


invertPixels(invertMode)

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.


bool load(url)

Loads an image from the given url, in the format the file's header describes.

The url parameter

Url to load the image from.


bool load(url, string format)

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.


bool load(path)

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.


bool load(path, string format)

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


bool loadFromData(data)

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.


bool loadFromData(data, string format)

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.


mirror(horizontal, bool vertical)

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.


bool pasteFromClipboard()

Pastes the image in the clipboard to the ImageObject instance, replacing the entire image.


color pixel(x, int y)

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().


rotate(angle)

Rotates the image clockwise.

The angle parameter

The angle to rotate the image, in degrees.


rotate(angle, int x)

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.


rotate(angle, int x, int y)

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.


rotate(angle, int x, int y, transformationmode transformationMode)

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.


bool save(url)

Saves the image to the given file url.

The url parameter

Url of the saved file's location.


bool save(url, string format)

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.


bool save(url, string format, int quality)

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.


bool save(path)

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.


bool save(path, string format)

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.


bool save(path, string format, int quality)

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.


scale(width, int height)

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.


scale(width, int height, aspectratiomode aspectRatioMode)

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.


scale(width, int height, aspectratiomode aspectRatioMode, transformationmode transformationMode)

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.


scaleToHeight(height)

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.


scaleToHeight(height, transformationmode transformationMode)

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.


scaleToWidth(width)

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.


scaleToWidth(width, transformationmode transformationMode)

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.


setPixel(x, int y, color color)

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().


setText(key, string text)

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().


sync()

Emits the ImageContentChanged signal without changing anything. This function is intended to 'remind' the application of programs it may not have picked up.


string text()

Returns a given text string.


string text(key)

Returns the image text associated with the given key.

The key parameter

Key that the text will be called from.

See also setText().


var toArrayBuffer()


var toArrayBuffer(format)

The format parameter


var toArrayBuffer(format, int quality)

The format parameter

The quality parameter