ImageObject QML Type

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

Import Statement: import ArcGIS.AppFramework 1.0

Properties

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.

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. Informs the rotate, rotated, scale, scaled, and scaleToWidth methods.

NameValue
ImageObject.TransformationModeFast0
ImageObject.TransformationModeSmooth1

InvertMode enumeration

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

NameValue
ImageObject.InvertRgb0
ImageObject.InvertRgba1

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.

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

asynchronous : bool

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);
    }
}

autoTransform : bool

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);
        }
    }
}

[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. Informed by the ImageFormat enum.


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

Note: The corresponding handler is onImageContentChanged.


loaded()

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.


textChanged()

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

Note: The corresponding handler is onTextChanged.


Method Documentation

clear()

Replaces the image with a blank image file.


clear(int 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(int 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(int 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 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(int 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(imageformat 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(imageformat 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(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.


bool copyToClipboard()

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.


fill(color 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 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. Informed by the InvertMode enum.


bool load(url 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 url, string format)

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


bool load(string 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, for example "/FullApplicationPath/Application/Images/RedCircle.png" for macOS or Linux.


bool load(string path, string format)

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


bool loadFromData(var 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(var 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, e.g. PNG, JPG


mirror(bool 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(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.


bool pasteFromClipboard()

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


color pixel(int 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(double angle)

Rotates the image clockwise.

The angle parameter

The angle to rotate the image, in degrees.


rotate(double 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(double 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(double 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. 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.


bool save(url url)

Saves the image to the given file url.

The url parameter

Url of the saved file's location.


bool save(url 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 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(string 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(string 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(string 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(int 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(int 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. Informed by the AspectRatioMode enum.


scale(int 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. 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.


scaleToHeight(int 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(int 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. Informed by the TransformationMode enum.


scaleToWidth(int 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(int 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. 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.


setPixel(int 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(string 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(string 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()

Save an image directly into a byte array, which is returned as an array buffer.


var toArrayBuffer(string format)

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.


var toArrayBuffer(string format, int quality)

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.


Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.