Convert Clipping Path To TGA
View as MarkdownReads image in JPEG format, converts clipping path to alpha channel and saves to TARGA 32 format.
Code 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.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);
}
}
Input
Apple.jpg
Output
ConvertClippingPathToTga.tga
DownloadUsed APIs
- Aurigma.GraphicsMill.Bitmap.GetGraphics
- Aurigma.GraphicsMill.Codecs.ImageReader
- Aurigma.GraphicsMill.Codecs.ImageReader.ClippingPaths
- Aurigma.GraphicsMill.Codecs.ImageReader.Create(String)
- Aurigma.GraphicsMill.Codecs.ImageWriter
- Aurigma.GraphicsMill.Codecs.ImageWriter.Create(String)
- Aurigma.GraphicsMill.Drawing.Graphics.FillPath(Brush,Path)
- Aurigma.GraphicsMill.Drawing.Path
- Aurigma.GraphicsMill.Drawing.Path.Create(Path,Int32,Int32)
- Aurigma.GraphicsMill.Drawing.SolidBrush
- Aurigma.GraphicsMill.Transforms.SetAlpha