Skip to main content
Inspiring
June 19, 2023
Question

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

  • June 19, 2023
  • 1 reply
  • 901 views

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 has been closed for replies.

1 reply

Legend
June 19, 2023

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.

Inspiring
June 19, 2023

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.
Legend
June 19, 2023

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