2D Nurbs Surface Trimming with Textures

I’m having great trouble finding sample code for 2D surface trimmming, and cannot find anything on Nurbs Curves with Textures.

I’m trying to create a routine that allows the user to create a free-form region on top of a texture image with mouse clicks, creating a closed surface, and then translate that 2D surface into to an alpha channel onto that texture for compositing.

If anyone could provide me with some sample source code or pointers, I’d be grateful.

Best regards,
Rennie