ImageGrayscaleMask Class

Summary: Describes a grayscale image mask.

Module: aspose.imaging.magicwand.imagemasks

Full Name: aspose.imaging.magicwand.imagemasks.ImageGrayscaleMask

Inheritance: IImageMask

Aspose.Imaging Version: 24.7.0

Constructors

NameDescription
ImageGrayscaleMask(image)Initializes a new instance of the ImageGrayscaleMask class with the size of the specified existing RasterImage.
Specified RasterImage will be stored as source image.
ImageGrayscaleMask(width, height)Initializes a new instance of the ImageGrayscaleMask class with the specified width and height.

Properties

NameTypeAccessDescription
boundsRectanglerGets the bounds, in pixels, of this mask.
heightintrGets the height, in pixels, of this mask.
selection_boundsRectanglerGets the bounds of the selected part of the mask, in pixels.
sourceRasterImagerGets the source image used to create this mask, if exists.
widthintrGets the width, in pixels, of this mask.

Methods

NameDescription
apply()Applies current mask to the RasterImage source, if exists.
apply_to(image)Applies current mask to the specified RasterImage.
clone()Creates a new object that is a copy of the current instance.
crop(rectangle)Crops mask with the specified rectangle.
crop(size)Crops mask with the specified size.
crop(width, height)Crops mask with the specified width and height.
exclusive_disjunction(mask)Gets the exclusive disjunction of current mask with provided.
get(x, y)Gets or sets the opacity of the specified pixel.
get_byte_opacity(x, y)Gets the opacity of the specified pixel with byte precision.
intersect(mask)Gets the intersection of current mask with provided.
invert()Gets the inversion of the current mask.
is_opaque(x, y)Checks if the specified pixel is opaque.
is_transparent(x, y)Checks if the specified pixel is transparent.
set(x, y, value)Sets the opacity of the specified pixel.
subtract(mask)Gets the subtraction of the provided mask from current.
union(mask)Union of two masks.

Constructor: ImageGrayscaleMask(image)

 ImageGrayscaleMask(image) 

Initializes a new instance of the ImageGrayscaleMask class with the size of the specified existing RasterImage.
Specified RasterImage will be stored as source image.

Parameters:

ParameterTypeDescription
imageRasterImageSource image.

Constructor: ImageGrayscaleMask(width, height)

 ImageGrayscaleMask(width, height) 

Initializes a new instance of the ImageGrayscaleMask class with the specified width and height.

Parameters:

ParameterTypeDescription
widthintWidth of the mask.
heightintHeight of the mask.

Method: apply_to(image)

 apply_to(image) 

Applies current mask to the specified RasterImage.

Parameters:

ParameterTypeDescription
imageRasterImageImage to apply mask to.

Method: clone()

 clone() 

Creates a new object that is a copy of the current instance.

Returns

TypeDescription
objectA new object that is a copy of this instance.

Method: crop(rectangle)

 crop(rectangle) 

Crops mask with the specified rectangle.

Parameters:

ParameterTypeDescription
rectangleRectangleThe specified rectangle.

Returns

TypeDescription
ImageGrayscaleMaskA cropped ImageGrayscaleMask.

Method: crop(size)

 crop(size) 

Crops mask with the specified size.

Parameters:

ParameterTypeDescription
sizeSizeThe specified size.

Returns

TypeDescription
ImageGrayscaleMaskAn cropped ImageGrayscaleMask.

Method: crop(width, height)

 crop(width, height) 

Crops mask with the specified width and height.

Parameters:

ParameterTypeDescription
widthintThe specified width.
heightintThe specified height.

Returns

TypeDescription
ImageGrayscaleMaskAn cropped ImageGrayscaleMask.

Method: exclusive_disjunction(mask)

 exclusive_disjunction(mask) 

Gets the exclusive disjunction of current mask with provided.

Parameters:

ParameterTypeDescription
maskImageGrayscaleMaskProvided mask

Returns

TypeDescription
ImageGrayscaleMaskNew ImageGrayscaleMask.

Method: get(x, y)

 get(x, y) 

Gets or sets the opacity of the specified pixel.

Parameters:

ParameterTypeDescription
xintThe x-coordinate of the pixel.
yintThe y-coordinate of the pixel.

Returns

TypeDescription
byteByte value; 0 if transparent; 255 if opaque.

Method: get_byte_opacity(x, y)

 get_byte_opacity(x, y) 

Gets the opacity of the specified pixel with byte precision.

Parameters:

ParameterTypeDescription
xintThe x-coordinate of the pixel.
yintThe y-coordinate of the pixel.

Returns

TypeDescription
byteByte value, representing the opacity of the specified pixel.

Method: intersect(mask)

 intersect(mask) 

Gets the intersection of current mask with provided.

Parameters:

ParameterTypeDescription
maskImageGrayscaleMaskProvided mask

Returns

TypeDescription
ImageGrayscaleMaskNew ImageGrayscaleMask.

Method: invert()

 invert() 

Gets the inversion of the current mask.

Returns

TypeDescription
ImageGrayscaleMaskNew ImageGrayscaleMask.

Method: is_opaque(x, y)

 is_opaque(x, y) 

Checks if the specified pixel is opaque.

Parameters:

ParameterTypeDescription
xintThe x-coordinate of the pixel.
yintThe y-coordinate of the pixel.

Returns

TypeDescription
booltrue if the specified pixel is opaque; otherwise, false.

Method: is_transparent(x, y)

 is_transparent(x, y) 

Checks if the specified pixel is transparent.

Parameters:

ParameterTypeDescription
xintThe x-coordinate of the pixel.
yintThe y-coordinate of the pixel.

Returns

TypeDescription
booltrue if the specified pixel is transparent; otherwise, false.

Method: set(x, y, value)

 set(x, y, value) 

Sets the opacity of the specified pixel.

Parameters:

ParameterTypeDescription
xintThe x-coordinate of the pixel.
yintThe y-coordinate of the pixel.
valuebyteByte value; 0 if transparent; 255 if opaque.

Method: subtract(mask)

 subtract(mask) 

Gets the subtraction of the provided mask from current.

Parameters:

ParameterTypeDescription
maskImageGrayscaleMaskProvided mask

Returns

TypeDescription
ImageGrayscaleMaskNew ImageGrayscaleMask.

Method: union(mask)

 union(mask) 

Union of two masks.

Parameters:

ParameterTypeDescription
maskImageGrayscaleMaskProvided mask

Returns

TypeDescription
ImageGrayscaleMaskNew ImageGrayscaleMask.