Assign a soft mask to the image.




void SetMask(XImage mask, bool invert)

[Visual Basic]
Sub SetMask(mask As XImage, invert As Boolean)

Throws Exceptions may throw Exception()



Name Description
mask The image containing the soft mask.
invert Whether to invert the mask.




Assign a soft mask or alpha channel. Soft masks are used to assign levels of transparency to an image.

The mask provided will be converted to a grayscale intensity map and may be scaled to ensure that the dimensions of the mask match those of the image. The assigned mask applies to all frames of the current image.

If the Invert parameter is set then the mask will be inverted - making transparent areas opaque and opaque areas transparent.

Different images within the mask can be accessed using the Frame property. Different portions of the mask can be selected using the Selection property.

Note that transparency is only applied to an Image if the Indirect property is true (which is generally the case).




Here we read a TIFF file and present the data to the Image object. We then read a mask image and assign that to our Image. Finally we add the image to our document and then save the PDF.


using (Doc doc = new Doc()) {   XImage theImg = new XImage();   XImage theMsk = new XImage();   theImg.SetFile(Server.MapPath("../mypics/mypic.jpg"));   theMsk.SetFile(Server.MapPath("../mypics/mymask.jpg"));   theImg.SetMask(theMsk, true);   theMsk.Clear();   doc.Color.String = "0 0 0";   doc.FillRect();   doc.Rect.Inset(20, 20);   doc.AddImageObject(theImg, true);   theImg.Clear();   doc.Save(Server.MapPath("imagesetmask.pdf")); }

Given the following input images.



This is the kind of output you might expect.