Skip to main content
Inspiring
Jun 19, 2023 12:35 PM UTC
Question

C++ SDK - image mask for transparency; special requirements?

I have a PDEImage that I assign to a PDEImage with the simple call:

PDEImageSetSMask(pdeImage, pdeImageMask);

and then I get an error in Acrobat that says something is wrong and the page may not display correctly and the image does not show. Don't do the assignment and it is fine. But I can change my code so that I use the image mask I ceate as the image and that displays fine; it is a grayscale rendering of the same image. So it is a valid PDImage but I assume it must not meet some special requirement to be a mask. I am having trouble finding any concise information on image masks. Is there somewhere it is documented. It's another case where I am using a working sample as the basis for my code. As mentioned, my own experiemnt of just using the generated mask as teh image demonstrates that it is a properly formed PDImage. but something makes it fail when used a s a mask.

This topic is closed to new replies. Start a new post to keep the conversation going.

4 replies

Legend
Jun 19, 2023 1:46 PM UTC

The only significant restriction I can find is that the SMask image must have color space DeviceGrey. It is not enough to just be a greyscale rendering.

Translate
Inspiring
Jun 19, 2023 1:52 PM UTC

Hmm... It does have that as the colorspace. All other arguments are the same as the original and this image can be output and works fine.

 

PDEColorSpace MaskColorSpace = PDEColorSpaceCreateFromName(ASAtomFromString("DeviceGray"));
PDEImage pdeImageMask = PDEImageCreate(&pdeImageAttrs, sizeof(pdeImageAttrs), &imageMatrix,
kPDEImageEncodedData, MaskColorSpace, NULL, &filterArray,
NULL, pJPG, lLen);
 
Can you tell me where it is documented? I only knew to do the DeviceGrey from the sample.
Translate
Legend
Jun 19, 2023 2:01 PM UTC

It's in the PDF specification (ISO 32000-1), under Transparency > Specifying transparency in PDF > Specifying soft masks.

Translate