---
title: "Convert Clipping Path To TGA"
canonical: https://www.graphicsmill.com/samples/Codecs/Tga/ConvertClippingPathToTga_cs
product: "Graphics Mill"
source: "Codecs/Tga/ConvertClippingPathToTga.cs"
---

# Convert Clipping Path To TGA

Reads image in JPEG format, converts clipping path to alpha channel and saves to TARGA 32 format.

## Instruction

Write a C# program that reads a JPEG image, extracts the clipping path, converts it to an alpha channel, and saves the result in TARGA 32 format.

## Usings

```csharp
using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Drawing;
```

## Code Snippet

```csharp
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.GetGraphics())
    {
        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);
    }
}
```

## Explanation

Below is a C# code sample that demonstrates how to read a JPEG image, create an alpha channel from the clipping path, and save the result in the TARGA 32 format.
It uses the Aurigma.GraphicsMill library to handle the image processing.

This code reads a JPEG image, converts the clipping path to an alpha channel, and writes the output in the TGA format with 32-bit color depth.

## Tags

- [Clipping Paths](<https://www.graphicsmill.com/samples/tags/clipping-paths_md>): Reading and writing Adobe resources clipping path
- [Drawing](<https://www.graphicsmill.com/samples/tags/drawing_md>): Drawing vector shapes and text
- [Pipeline](<https://www.graphicsmill.com/samples/tags/pipeline_md>): Working with images via the Pipeline API
- [TGA](<https://www.graphicsmill.com/samples/tags/tga_md>): Reading and writing TGA images

## Input

- [Apple.jpg](<https://www.graphicsmill.com/samples/Codecs/compiled/Debug/Apple_jpg>) (preview)

## Output

- [ConvertClippingPathToTga.tga](<https://www.graphicsmill.com/samples/Codecs/compiled/Debug/ConvertClippingPathToTga_tga>) (download)

## Used APIs

- [Aurigma.GraphicsMill.Bitmap.GetGraphics](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Bitmap_GetGraphics.htm.md>)
- [Aurigma.GraphicsMill.Codecs.ImageReader](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Codecs_ImageReader.htm.md>)
- [Aurigma.GraphicsMill.Codecs.ImageReader.ClippingPaths](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Codecs_ImageReader_ClippingPaths.htm.md>)
- [Aurigma.GraphicsMill.Codecs.ImageReader.Create(String)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Codecs_ImageReader_Create_1_bb3a7a4f.htm.md>)
- [Aurigma.GraphicsMill.Codecs.ImageWriter](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Codecs_ImageWriter.htm.md>)
- [Aurigma.GraphicsMill.Codecs.ImageWriter.Create(String)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Codecs_ImageWriter_Create_1_bb3a7a4f.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Graphics.FillPath(Brush,Path)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Drawing_Graphics_FillPath_2_3cee1596.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Path](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_Path.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Path.Create(Path,Int32,Int32)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Drawing_Path_Create_3_302ad613.htm.md>)
- [Aurigma.GraphicsMill.Drawing.SolidBrush](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_SolidBrush.htm.md>)
- [Aurigma.GraphicsMill.Transforms.SetAlpha](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Transforms_SetAlpha.htm.md>)
