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
PDF::Image::SetMask()?
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();
mask_arr.PushBackNumber(10);
mask_arr.PushBackNumber(180);
...
image.SetMask(mask_arr)?

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");
mask_arr.PushBackNumber(10);
mask_arr.PushBackNumber(180);
...

From PDF Reference (8.9.6.4 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."