This forum contains outdated content and is available for reading only. Please contact technical support if you have any questions.

Adding a clipping path to tif

WalterM#33316
Hello
I'm test driving the library and so far it's pretty great, but I'm stuck on this one issue:
There are complete examples on how to copy over existing clipping paths from one TIF (or jpg) to another, but what if you need to draw and add a completely new clipping path from scratch to the AdobeResources?
How can i create a new Aurigma.GraphicsMill.Codecs.ClippingPath.Path given a series of points, and add it to the adobeResources of a new file?
Thanks for any insights!
Eugene Kosmin#33317
Hello,

Please check this code:
using (var bitmap = new Bitmap(400, 300, PixelFormat.Format24bppRgb, RgbColor.Red))
using (var path = new Aurigma.GraphicsMill.AdvancedDrawing.Path())
{
    path.DrawEllipse(0, 0, bitmap.Width, bitmap.Height);

    // 2000-2997 Clipping path information
    // http://www.adobe.com/devnet-apps/photoshop/fileformatashtml/
    const int firstPathId = 2000;

    // Inside of Adobe Resource, all points are stored in relative values to the image dimensions, so you need to provide image with/height for conversion.
    var pathData = AdobeResourceBlock.CreatePath(path, bitmap.Width, bitmap.Height);
                
    var ar = new AdobeResourceDictionary();
    ar.Add(firstPathId, new AdobeResourceBlock("MyPath", pathData));

    bitmap.Save("out.jpg", new JpegSettings() { AdobeResources = ar });
}
WalterM#33318
That works perfectly, thanks!