---
title: "Tint Using Alpha (Memory Friendly)"
canonical: https://www.graphicsmill.com/samples/Transforms/Tint/TintUsingAlphaMemoryFriendly_cs
product: "Graphics Mill"
source: "Transforms/Tint/TintUsingAlphaMemoryFriendly.cs"
---

# Tint Using Alpha (Memory Friendly)

Tints using alpha channel and memory-friendly Pipeline API.

## Instruction

Apply tint using alpha channel and invert colors in a memory-friendly way.

## Usings

```csharp
using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Transforms;
```

## Code Snippet

```csharp
// reader  --->  converter  ---> invert  -----\
//                            generator  --->  setAlpha  --->  removeAlpha  --->  writer
using (var reader = ImageReader.Create("Chicago.jpg"))
using (var converter = new Aurigma.GraphicsMill.Transforms.ColorConverter(PixelFormat.Format8bppGrayscale))
using (var invert = new Invert())
using (var generator = new ImageGenerator(reader.Width, reader.Height, PixelFormat.Format24bppRgb, RgbColor.OrangeRed))
using (var setAlpha = new SetAlpha())
using (var removeAlpha = new RemoveAlpha(RgbColor.White))
using (var writer = ImageWriter.Create("TintUsingAlphaMemoryFriendly.jpg"))
{
    setAlpha.AlphaSource = reader + converter + invert;

    Pipeline.Run(generator + setAlpha + removeAlpha + writer);
}
```

## Explanation

The code:

- Reads the image from "Chicago.jpg".
- Converts the image to 8bpp grayscale format and inverts the colors.
- Creates an orange-red background image generator with the same size as the input.
- Sets the alpha channel from the processed image (grayscale and inverted).
- Removes the white color from the alpha channel for transparency.
- Saves the result to "TintUsingAlphaMemoryFriendly.jpg".

## Tags

- [Channels](<https://www.graphicsmill.com/samples/tags/channels_md>): Reading and combining image channels
- [Color Conversion](<https://www.graphicsmill.com/samples/tags/color-conversion_md>): Converting colors between color spaces
- [Pipeline](<https://www.graphicsmill.com/samples/tags/pipeline_md>): Working with images via the Pipeline API
- [Transform](<https://www.graphicsmill.com/samples/tags/transform_md>): Image transforms and effects

## Input

- [Chicago.jpg](<https://www.graphicsmill.com/samples/Transforms/compiled/Debug/Chicago_jpg>) (preview)

## Output

- [TintUsingAlphaMemoryFriendly.jpg](<https://www.graphicsmill.com/samples/Transforms/compiled/Debug/TintUsingAlphaMemoryFriendly_jpg>) (preview)

## Used APIs

- [Aurigma.GraphicsMill.Codecs.ImageReader](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Codecs_ImageReader.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.ImageGenerator](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_ImageGenerator.htm.md>)
- [Aurigma.GraphicsMill.Transforms.ColorConverter](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Transforms_ColorConverter.htm.md>)
- [Aurigma.GraphicsMill.Transforms.Invert](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Transforms_Invert.htm.md>)
- [Aurigma.GraphicsMill.Transforms.RemoveAlpha](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Transforms_RemoveAlpha.htm.md>)
- [Aurigma.GraphicsMill.Transforms.SetAlpha](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Transforms_SetAlpha.htm.md>)
- [Aurigma.GraphicsMill.Transforms.SetAlpha.AlphaSource](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Transforms_SetAlpha_AlphaSource.htm.md>)
