Clipping drawing to memory context

Hello,
I’m drawing to a memory context, so I can composite two images togther.
It’s working fine, except that I cannot seem to add a clipping path, the
following is what I am doing, and it get run twice, one time for
different pictures.


PmMemStart(context);
gc = PgCreateGC(0);
previous_gc = PgSetGCCx(Stage_Context,gc);

PgSetUserClip(&clipping);
PgDrawPhImagemx(&position, image, NULL);
PmMemFlush(context, context_image); // get the image
PgFlush();
PgDestroyGC(gc);
PgSetGC(previous_gc);
PmMemStop(context);

What I end up with is one image slapped on top of another, which is
exactly what I want, but the clipping seems to make no difference at
all. Is there any examples of how to do this? I’ve tried PgSetClipping
too, but it just segfaults.

Cheers

Garry