How do I set a color mask on a PDF image?

Q: how can I create (for a new image) the array to be passed to
If I use SDF::ObjSet, I'll get an exception:

Objects cannot belong to different documents; Conditional expression:
this_doc == obj->GetDoc(); Filename : Dict.cpp; Function : Put;
Linenumber : 103

I'd like to avoid using an indirect object.
A: You can set a color key mask as follows steps:

Obj mask_arr = doc.CreateIndirectArray();

In case you would like to avoid the use of indirect object, you could
set the mask as follows:

Obj mask_arr = image.GetSDFObj().PutArray("Mask");

From PDF Reference ( Colour Key Masking): "The value of the

Mask entry shall be an array of 2xn integers,
[ min1 max1 … minn maxn ], where n is the number of colour components
in the image’s colour space. Each integer shall be in the range 0 to
2BitsPerComponent - 1, representing colour values before decoding with
the Decode array."