User Tools

Site Tools


Image

DAZScript wrapper for QImage.

More...

Inherits :

Enumerations

Properties

Constructors

DAZ Script
Image ()
Image ( Number width, Number height, Format format )
Image ( Image image )
Image ( String filename )

Methods

DAZ Script
Colorcolor ( Number index )
ImagecompositeAtop ( Image other, int x=0, int y=0 )
ImagecompositeColorBurn ( Image other, int x=0, int y=0 )
ImagecompositeColorDodge ( Image other, int x=0, int y=0 )
ImagecompositeDarken ( Image other, int x=0, int y=0 )
ImagecompositeDifference ( Image other, int x=0, int y=0 )
ImagecompositeExclusion ( Image other, int x=0, int y=0 )
ImagecompositeHardLight ( Image other, int x=0, int y=0 )
ImagecompositeIn ( Image other, int x=0, int y=0 )
ImagecompositeLighten ( Image other, int x=0, int y=0 )
ImagecompositeMultiply ( Image other, int x=0, int y=0 )
ImagecompositeOut ( Image other, int x=0, int y=0 )
ImagecompositeOver ( Image other, Number x=0, Number y=0 )
ImagecompositeOverlay ( Image other, int x=0, int y=0 )
ImagecompositePlus ( Image other, int x=0, int y=0 )
ImagecompositeScreen ( Image other, int x=0, int y=0 )
ImagecompositeSoftLight ( Image other, int x=0, int y=0 )
ImagecompositeXor ( Image other, int x=0, int y=0 )
ImageconvertDepth ( Number depth )
Imagecopy ( Number x, Number y, Number w, Number h )
Imagecopy ()
Imagecopy ( Rect rect )
voidcreate ( Size size, Number depth, Number numColors=0 )
voidcreate ( Number w, Number h, Number depth, Number numColors=0 )
RectdrawText ( Number x, Number y, String text, Font font, Color color, Number flags=0 )
voidfill ( Color color )
ImagegetColorMask ( Color maskColor, Boolean invert=false, Number tolerance=0 )
voidinvertPixels ( Boolean invertAlpha=true )
BooleanisNull ()
voidload ( String filename )
BooleanloadFromData ( ByteArray data, String format=“” )
Imagemirror ()
Imagemirror ( bool horizontal, bool vertical )
Colorpixel ( Number x, Number y )
voidsave ( String filename )
Imagescale ( Number width, Number height )
Imagescale ( Size size )
BooleansetAlphaFromImage ( Image img )
voidsetColor ( Number index, Color color )
voidsetPixel ( Number x, Number y, Color color )
voidsetText ( String key, String text )
ImagesmoothScale ( Size size )
ImagesmoothScale ( Number width, Number height )
ImageswapRGB ()
voidtext ( String key=“” )
ArraytextKeys ()

Detailed Description

This is the DAZScript counterpart to the QImage type used in the DAZ Studio SDK.

Attention:

  • Inheritance will change to Object in a pending update.

Enumerations


: Format

Supported image formats.

Since:

  • 4.9.4.4
  • Format_Invalid - The image is invalid.
  • Format_Mono - The image is stored using 1-bit per pixel. Bytes are packed with the most significant bit (MSB) first.
  • Format_MonoLSB - The image is stored using 1-bit per pixel. Bytes are packed with the less significant bit (LSB) first.
  • Format_Indexed8 - The image is stored using 8-bit indexes into a colormap.
  • Format_RGB32 - The image is stored using a 32-bit RGB format (0xffRRGGBB).
  • Format_ARGB32 - The image is stored using a 32-bit ARGB format (0xAARRGGBB).
  • Format_ARGB32_Premultiplied - The image is stored using a premultiplied 32-bit ARGB format (0xAARRGGBB), i.e. the red, green, and blue channels are multiplied by the alpha component divided by 255. (If RR, GG, or BB has a higher value than the alpha channel, the results are undefined.) Certain operations (such as image composition using alpha blending) are faster using premultiplied ARGB32 than with plain ARGB32.
  • Format_RGB16 - The image is stored using a 16-bit RGB format (5-6-5).
  • Format_ARGB8565_Premultiplied - The image is stored using a premultiplied 24-bit ARGB format (8-5-6-5).
  • Format_RGB666 - The image is stored using a 24-bit RGB format (6-6-6). The unused most significant bits is always zero.
  • Format_ARGB6666_Premultiplied - The image is stored using a premultiplied 24-bit ARGB format (6-6-6-6).
  • Format_RGB555 - The image is stored using a 16-bit RGB format (5-5-5). The unused most significant bit is always zero.
  • Format_ARGB8555_Premultiplied - The image is stored using a premultiplied 24-bit ARGB format (8-5-5-5).
  • Format_RGB888 - The image is stored using a 24-bit RGB format (8-8-8).
  • Format_RGB444 - The image is stored using a 16-bit RGB format (4-4-4). The unused bits are always zero.
  • Format_ARGB4444_Premultiplied - The image is stored using a premultiplied 16-bit ARGB format (4-4-4-4).

Properties


Boolean : alphaBuffer

Holds whether or not the image has an alpha channel.


Number : depth

Holds the color depth of the image. (Read-Only)


Number : dotsPerMeterX

Holds the X resolution of the image.


Number : dotsPerMeterY

Holds the Y resolution of the image.


Format : format

Holds the format of the image.

Since:

  • 4.9.4.4

Number : height

Holds the height of the image. (Read-Only)


Number : numColors

Holds the number of colors in the image.


Point : offset

Holds the number of pixels to offset the image when positioning it.


Size : size

Holds the number of pixels to offset the image when positioning it.


Number : width

Holds the width of the image. (Read-Only)

Constructors


Image()

Default Constructor.


Image( Number width, Number height, Format format )

Parameter(s):

  • width - The width of the image.
  • height - The height of the image.
  • format - The format of the image.

Since:

  • 4.9.4.4

Image( Image image )

Copy Constructor.

Parameter(s):

  • image - The image to copy.

Image( String filename )

Parameter(s):

  • filename - The name of the file to load the image's data from.

Methods


Color : color( Number index )

Gets a color value from the color table for the image only valid for.

Parameter(s):

  • index - The index of the color to look up in the table.

Return Value:

  • The RGB value of the color at the given index.

Image : compositeAtop( Image other, int x=0, int y=0 )

Parameter(s):

  • other - The image to composite this image with.
  • x - The offset, in the horizontal direction, from the top left corner of other.
  • y - The offset, in the vertical direction, from the top left corner of other.

Return Value:

  • A copy of this image, where the pixels of this image are blended on top of other and the alpha of this image is reduced by the alpha of other.

Since:

  • 4.10.0.120

Image : compositeColorBurn( Image other, int x=0, int y=0 )

Parameter(s):

  • other - The image to composite this image with.
  • x - The offset, in the horizontal direction, from the top left corner of other.
  • y - The offset, in the vertical direction, from the top left corner of other.

Return Value:

  • An image where the other color is darkened to reflect the color of this image. White in this image leaves the other color unchanged.

Since:

  • 4.10.0.120

Image : compositeColorDodge( Image other, int x=0, int y=0 )

Parameter(s):

  • other - The image to composite this image with.
  • x - The offset, in the horizontal direction, from the top left corner of other.
  • y - The offset, in the vertical direction, from the top left corner of other.

Return Value:

  • An image where the other color is brightened to reflect the color of this image. Black in this image leaves the other color unchanged.

Since:

  • 4.10.0.120

Image : compositeDarken( Image other, int x=0, int y=0 )

Parameter(s):

  • other - The image to composite this image with.
  • x - The offset, in the horizontal direction, from the top left corner of other.
  • y - The offset, in the vertical direction, from the top left corner of other.

Return Value:

  • An image where the darker color of this image and other is selected.

Since:

  • 4.10.0.120

Image : compositeDifference( Image other, int x=0, int y=0 )

Parameter(s):

  • other - The image to composite this image with.
  • x - The offset, in the horizontal direction, from the top left corner of other.
  • y - The offset, in the vertical direction, from the top left corner of other.

Return Value:

  • An image where the darker of this image and other is subtracted from the lighter. White in this image inverts the color in other, whereas black leaves the color of other unchanged.

Since:

  • 4.10.0.120

Image : compositeExclusion( Image other, int x=0, int y=0 )

Parameter(s):

  • other - The image to composite this image with.
  • x - The offset, in the horizontal direction, from the top left corner of other.
  • y - The offset, in the vertical direction, from the top left corner of other.

Return Value:

  • An image where the darker of this image and other is subtracted from the lighter. White in this image inverts the color in other, whereas black leaves the color of other unchanged.

Since:

  • 4.10.0.120

Image : compositeHardLight( Image other, int x=0, int y=0 )

Parameter(s):

  • other - The image to composite this image with.
  • x - The offset, in the horizontal direction, from the top left corner of other.
  • y - The offset, in the vertical direction, from the top left corner of other.

Return Value:

  • An image where the color of this image and other are multiplied or screened depending on the color of this image. A light color in this image will lighten the other color, whereas a dark color in this image will darken the other color.

Since:

  • 4.10.0.120

Image : compositeIn( Image other, int x=0, int y=0 )

Parameter(s):

  • other - The image to composite this image with.
  • x - The offset, in the horizontal direction, from the top left corner of other.
  • y - The offset, in the vertical direction, from the top left corner of other.

Return Value:

  • A copy of this image, where the alpha of this image is reduced by the alpha of other.

Since:

  • 4.10.0.120

Image : compositeLighten( Image other, int x=0, int y=0 )

Parameter(s):

  • other - The image to composite this image with.
  • x - The offset, in the horizontal direction, from the top left corner of other.
  • y - The offset, in the vertical direction, from the top left corner of other.

Return Value:

  • An image where the lighter color of this image and other is selected.

Since:

  • 4.10.0.120

Image : compositeMultiply( Image other, int x=0, int y=0 )

Parameter(s):

  • other - The image to composite this image with.
  • x - The offset, in the horizontal direction, from the top left corner of other.
  • y - The offset, in the vertical direction, from the top left corner of other.

Return Value:

  • An image where the color of this image and other are multiplied together.

Attention:

  • Multiplying a color with white (1) leaves the color unchanged, while multiplying a color with black (0) produces black.

Since:

  • 4.10.0.120

Image : compositeOut( Image other, int x=0, int y=0 )

Parameter(s):

  • other - The image to composite this image with.
  • x - The offset, in the horizontal direction, from the top left corner of other.
  • y - The offset, in the vertical direction, from the top left corner of other.

Return Value:

  • A copy of this image, where the alpha of this image is reduced by the inverse of the alpha of other.

Since:

  • 4.10.0.120

Image : compositeOver( Image other, Number x=0, Number y=0 )

Parameter(s):

  • other - The image to composite this image with.
  • x - The offset, in the horizontal direction, from the top left corner of other.
  • y - The offset, in the vertical direction, from the top left corner of other.

Return Value:

  • A copy of this image, where the alpha of this image is used to blend it on top of other.

Since:

  • 4.10.0.120

Image : compositeOverlay( Image other, int x=0, int y=0 )

Parameter(s):

  • other - The image to composite this image with.
  • x - The offset, in the horizontal direction, from the top left corner of other.
  • y - The offset, in the vertical direction, from the top left corner of other.

Return Value:

  • An image where the color of this image and other are multiplied or screened depending on other color. The other color is mixed with this color to reflect the lightness or darkness of other.

Since:

  • 4.10.0.120

Image : compositePlus( Image other, int x=0, int y=0 )

Parameter(s):

  • other - The image to composite this image with.
  • x - The offset, in the horizontal direction, from the top left corner of other.
  • y - The offset, in the vertical direction, from the top left corner of other.

Return Value:

  • An image where the alpha/color of this image and other are added together.

Since:

  • 4.10.0.120

Image : compositeScreen( Image other, int x=0, int y=0 )

Parameter(s):

  • other - The image to composite this image with.
  • x - The offset, in the horizontal direction, from the top left corner of other.
  • y - The offset, in the vertical direction, from the top left corner of other.

Return Value:

  • An image where the inverse color of this image and other are multiplied together.

Attention:

  • Screening a color with white (1) produces white, while screening a with black (0) leaves the color unchanged.

Since:

  • 4.10.0.120

Image : compositeSoftLight( Image other, int x=0, int y=0 )

Parameter(s):

  • other - The image to composite this image with.
  • x - The offset, in the horizontal direction, from the top left corner of other.
  • y - The offset, in the vertical direction, from the top left corner of other.

Return Value:

  • An image where the color of this image and other are darkened or lightened depending on the color of this image.

Since:

  • 4.10.0.120

Image : compositeXor( Image other, int x=0, int y=0 )

Parameter(s):

  • other - The image to composite this image with.
  • x - The offset, in the horizontal direction, from the top left corner of other.
  • y - The offset, in the vertical direction, from the top left corner of other.

Return Value:

  • A copy of this image, where the alpha is reduced by the inverse of the alpha of other, is merged with other, and whose alpha is reduced by the inverse of this image alpha.

Since:

  • 4.10.0.120

Image : convertDepth( Number depth )

Creates a copy of the image with the given color depth.

Parameter(s):

  • depth - The color depth to convert the image to.

Return Value:

  • The image converted to the new color depth.

Image : copy( Number x, Number y, Number w, Number h )

Creates a copy of a portion of the image.

Parameter(s):

  • x - The x position of the area to copy.
  • y - The y position of the area to copy.
  • w - The width of the area to copy.
  • h - The height of the area to copy.

Return Value:

  • A new copy of the specified area of the image.

Image : copy()

Creates a copy of the image.

Return Value:

  • A new copy of the image.

Image : copy( Rect rect )

Creates a copy of a portion of the image.

Parameter(s):

  • rect - The area to copy.

Return Value:

  • A new copy of the specified area of the image.

void : create( Size size, Number depth, Number numColors=0 )

Clears the image data and creates a new image with the given settings.

Parameter(s):

  • size - The new size for the image.
  • depth - The new color depth for the image.
  • numColors - The number of colors for the new image.

void : create( Number w, Number h, Number depth, Number numColors=0 )

Clears the image data and creates a new image with the given settings.

Parameter(s):

  • w - The new width for the image.
  • h - The new height for the image.
  • depth - The new color depth for the image.
  • numColors - The number of colors for the new image.

Rect : drawText( Number x, Number y, String text, Font font, Color color, Number flags=0 )

Parameter(s):

Return Value:

  • A bounding rectangle that encloses the drawn text.

Since:

  • 4.10.0.121

void : fill( Color color )

Fills the image with color.

Parameter(s):

  • color - The color to set the pixels of the image.

Image : getColorMask( Color maskColor, Boolean invert=false, Number tolerance=0 )

Parameter(s):

  • maskColor - The color to mask from this image.
  • invert - If true, the mask is inverted.
  • tolerance - The allowable amount of variation from the value of maskColor to consider as maskColor.

Return Value:

  • An image mask for the specified color.

Since:

  • 4.10.0.120

void : invertPixels( Boolean invertAlpha=true )

Inverts all pixels in the image.

Parameter(s):

  • invertAlpha - If the image has a 32 bit depth, and this is true, the alpha channel will also be inverted, otherwise the alpha channel is unaffected.

Boolean : isNull()

Gets whether or not the image is Null.

Return Value:

  • true if the image is Null (empty), otherwise .

void : load( String filename )

Loads data for the image from a file.

Parameter(s):

  • filename - The name of the file to load into the image.

Boolean : loadFromData( ByteArray data, String format=“” )

Loads data into the image from a byte array using the specified format.

Parameter(s):

  • data - The binary data to load into the image.
  • format - The file format of the bytes in data; i.e. “PNG”.

Return Value:

  • true if the data was loaded, otherwise false.

Since:

  • 4.10.0.88

Image : mirror()

Creates a copy of this image that has been mirrored vertically.

Return Value:

  • The mirrored copy of the image.

Image : mirror( bool horizontal, bool vertical )

Creates a copy of this image that has been mirrored.

Parameter(s):

  • horizontal - If true, the image will be mirrored horizontally.
  • vertical - If true, the image will be mirrored vertically.

Return Value:

  • The mirrored copy of the image.

Color : pixel( Number x, Number y )

Gets the color value of an individual pixel.

Parameter(s):

  • x - The x position of the pixel.
  • y - The y position of the pixel.

Return Value:

  • The value of the pixel at the given location.

void : save( String filename )

Saves the image to a file.

Parameter(s):

  • filename - The name of the file to save the image to.

Image : scale( Number width, Number height )

Creates a new image that is a scaled version of this image.

Parameter(s):

  • width - The width of the new image.
  • height - The height of the new image.

Return Value:

  • The new scaled image.

Image : scale( Size size )

Creates a new image that is a scaled version of this image.

Parameter(s):

  • size - The size of the new image.

Return Value:

  • The new scaled image.

Boolean : setAlphaFromImage( Image img )

Parameter(s):

  • img - The image to set the alpha of this image from.

Return Value:

  • false if img is null, otherwise true.

Since:

  • 4.10.0.120

void : setColor( Number index, Color color )

Sets the color value of a color in the color table.

Parameter(s):

  • index - The index of the color in the color table to change.
  • color - The new value for the color.

void : setPixel( Number x, Number y, Color color )

Sets the color value of the given pixel.

Parameter(s):

  • x - The x position of the pixel to change.
  • y - The y position of the pixel to change.
  • color - The new value for the pixel.

void : setText( String key, String text )

Sets the image text to text and associates it with key.

If you want to store a single text block (i.e., a “comment” or description), you can either pass an empty key, or use a generic key like “Description”.

The image text is embedded into the image data when you call save(). Not all image formats support embedded text.

Parameter(s):

  • key - The name of the key to associate the embedded text with.
  • text - The text to embedd and associate with the key.

See Also:

Since:

  • 4.9.3.78

Image : smoothScale( Size size )

Creates a new image that is a scaled version of this image.

Parameter(s):

  • size - The size of the new image.

Return Value:

  • The new scaled image.

Image : smoothScale( Number width, Number height )

Creates a new image that is a scaled version of this image.

Parameter(s):

  • width - The width of the new image.
  • height - The height of the new image.

Return Value:

  • The new scaled image.

Image : swapRGB()

Creates a copy of the image in which the Red and Blue values have been swapped.

Return Value:

  • A BGR version of the image.

void : text( String key=“” )

Parameter(s):

  • key - The name of the key to get the associated text of.

Return Value:

  • The embedded text associated with key. If key is an empty string, the whole embedded text is returned, with each key-text pair separated by a newline.

See Also:

Since:

  • 4.9.3.78

Array : textKeys()

Return Value:

  • The text keys for this image.

See Also:

Since:

  • 4.9.3.78