Convert Clipping Path To TGA

TGA Clipping Paths Drawing Pipeline

Reads image in JPEG format, converts clipping path to alpha channel and saves to TARGA 32 format.

Сode Snippet

using (var reader = ImageReader.Create("Apple.jpg"))
using (var alpha = new Bitmap(reader.Width, reader.Height, PixelFormat.Format8bppGrayscale, RgbColor.Black))
using (var writer = ImageWriter.Create("ConvertClippingPathToTga.tga"))
{
    using (var graphics = alpha.GetAdvancedGraphics())
    {
        var path = reader.ClippingPaths[0];
        using (var graphicsPath = Path.Create(path, alpha.Width, alpha.Height))
        {
            graphics.FillPath(new SolidBrush(RgbColor.White), graphicsPath);
        }
    }

    using (var setAlpha = new Aurigma.GraphicsMill.Transforms.SetAlpha(alpha))
    {
        Pipeline.Run(reader + setAlpha + writer);
    }
}

Input

Apple.jpg

Output

ConvertClippingPathToTga.tga

Download

For AI-assisted development: Download Graphics Mill Code Samples XML Catalog