---
title: "Write Extra Channel With Display Info"
canonical: https://www.graphicsmill.com/samples/Codecs/Tiff/WriteExtraChannelWithDisplayInfo_cs
product: "Graphics Mill"
source: "Codecs/Tiff/WriteExtraChannelWithDisplayInfo.cs"
---

# Write Extra Channel With Display Info

Saves extra channels with display info to Adobe Resources.

## Instruction

Create a TIFF image with multiple extra channels, each representing a different color space, and save display information into Adobe resources.

## Usings

```csharp
using System.Collections.Generic;
using Aurigma.GraphicsMill;
using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Drawing;
```

## Code Snippet

```csharp
public enum DisplayInfoMode
{
    Alpha = 0,
    InvertedAlpha = 1,
    Spot = 2,
}

public enum AdobeColorSpace
{
    RGB = 0,
    CMYK = 2,
    LAB = 7,
    Grayscale = 8,
}

public static void Run()
{
    var imageSize = new System.Drawing.Size(1000, 1000);

    using (var bitmap = new Bitmap(imageSize.Width, imageSize.Height, PixelFormat.Format8bppGrayscale, RgbColor.White))
    using (var tiffWriter = new TiffWriter("AdobeResourcesWithDisplayInfo.tif"))
    {
        var colors = new Color[]
        {
            RgbColor.Violet,
            new CmykColor(255, 0, 0, 0),
            new LabColor(140, 62, -39),
            new GrayscaleColor(222),
        };

        foreach (var color in colors)
        {
            tiffWriter.ExtraChannels.Add(new TiffExtraChannelEntry(CreateEllipse(imageSize), TiffChannelType.Color));
        }

        const byte solidity = 50;

        var displayInfoBlock = CreateDisplayInfoBlock(colors, solidity);

        tiffWriter.AdobeResources = new AdobeResourceDictionary();

        // https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/
        const int displayInfo = 0x0435;

        tiffWriter.AdobeResources.Add(displayInfo, displayInfoBlock);

        Pipeline.Run(bitmap + tiffWriter);
    }
}

public static Bitmap CreateEllipse(System.Drawing.Size size)
{
    var bitmap = new Bitmap(size.Width, size.Height, PixelFormat.Format8bppGrayscale);

    var fillRect = new System.Drawing.Rectangle(new System.Drawing.Point(0, 0), size);

    using (var gr = bitmap.GetGraphics())
    {
        bitmap.Fill(RgbColor.White);
        gr.FillEllipse(new SolidBrush(RgbColor.Black), fillRect);
    }

    return bitmap;
}

public static AdobeResourceBlock CreateDisplayInfoBlock(Color[] colors, byte solidity)
{
    if (solidity < 0 || solidity > 100)
    {
        throw new System.ArgumentOutOfRangeException("solidity");
    }

    List<byte> blockData = new List<byte>();
    blockData.AddRange(new byte[] { 0, 0, 0, 1 });

    foreach (var c in colors)
    {
        switch (c.ColorSpace)
        {
            case ColorSpace.Rgb:
                {
                    var color = c as RgbColor;
                    blockData.AddRange(new byte[] { 0, (byte)AdobeColorSpace.RGB });
                    blockData.AddRange(new byte[] { color.R, 0 });
                    blockData.AddRange(new byte[] { color.G, 0 });
                    blockData.AddRange(new byte[] { color.B, 0 });
                    blockData.AddRange(new byte[] { 0, 0 });
                    break;
                }

            case ColorSpace.Cmyk:
                {
                    var color = c as CmykColor;
                    blockData.AddRange(new byte[] { 0, (byte)AdobeColorSpace.CMYK });
                    blockData.AddRange(new byte[] { (byte)(255 - color.C), 0 });
                    blockData.AddRange(new byte[] { (byte)(255 - color.M), 0 });
                    blockData.AddRange(new byte[] { (byte)(255 - color.Y), 0 });
                    blockData.AddRange(new byte[] { (byte)(255 - color.K), 0 });
                    break;
                }

            case ColorSpace.Lab:
                {
                    var color = c as LabColor;
                    blockData.AddRange(new byte[] { 0, (byte)AdobeColorSpace.LAB });

                    var l = (ushort)(color.L / 2.55f * 100f);
                    blockData.AddRange(new byte[] { (byte)(l >> 8), (byte)(l & 255) });

                    var a = (ushort)(short)(color.A * 100);
                    blockData.AddRange(new byte[] { (byte)(a >> 8), (byte)(a & 255) });

                    var b = (ushort)(short)(color.B * 100);
                    blockData.AddRange(new byte[] { (byte)(b >> 8), (byte)(b & 255) });

                    blockData.AddRange(new byte[] { 0, 0 });
                    break;
                }

            case ColorSpace.Grayscale:
                {
                    var gray = c as GrayscaleColor;
                    blockData.AddRange(new byte[] { 0, (byte)AdobeColorSpace.Grayscale });

                    var l = (ushort)((255 - gray.L) / 2.55f * 100f);
                    blockData.AddRange(new byte[] { (byte)(l >> 8), (byte)(l & 255) });

                    blockData.AddRange(new byte[] { 0, 0 });
                    blockData.AddRange(new byte[] { 0, 0 });
                    blockData.AddRange(new byte[] { 0, 0 });

                    break;
                }

            default:
                throw new System.ArgumentException("Invalid color space");
        }

        blockData.AddRange(new byte[] { solidity, 0 });
        blockData.Add((byte)DisplayInfoMode.Spot);
    }

    return new AdobeResourceBlock(string.Empty, blockData.ToArray());
}
```

## Explanation

The following code:

- Creates a TIFF with four spot color channels (RGB, CMYK, LAB, Grayscale).
- Each extra channel is represented by an ellipse shape.
- Adds display information to Adobe resources using the `0x0435` DisplayInfo tag.
- Sets the spot solidity to 50% for each color.
This allows compatible applications to interpret and visualize spot colors properly.

## Tags

- [Adobe Resources](<https://www.graphicsmill.com/samples/tags/adobe-resources_md>): Working with Adobe image resource blocks
- [Extra Channels](<https://www.graphicsmill.com/samples/tags/extra-channels_md>): Working with TIFF extra channels
- [Pipeline](<https://www.graphicsmill.com/samples/tags/pipeline_md>): Working with images via the Pipeline API
- [TIFF](<https://www.graphicsmill.com/samples/tags/tiff_md>): Reading and writing TIFF images
- [Write](<https://www.graphicsmill.com/samples/tags/write_md>): Writing images with codecs

## Output

- [AdobeResourcesWithDisplayInfo.tif](<https://www.graphicsmill.com/samples/Codecs/compiled/Debug/AdobeResourcesWithDisplayInfo_tif>) (download)

## Used APIs

- [Aurigma.GraphicsMill.Bitmap.Fill(Color)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Bitmap_Fill_1_929597d9.htm.md>)
- [Aurigma.GraphicsMill.Bitmap.GetGraphics](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Bitmap_GetGraphics.htm.md>)
- [Aurigma.GraphicsMill.CmykColor](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_CmykColor.htm.md>)
- [Aurigma.GraphicsMill.CmykColor.C](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_CmykColor_C.htm.md>)
- [Aurigma.GraphicsMill.CmykColor.K](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_CmykColor_K.htm.md>)
- [Aurigma.GraphicsMill.CmykColor.M](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_CmykColor_M.htm.md>)
- [Aurigma.GraphicsMill.CmykColor.Y](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_CmykColor_Y.htm.md>)
- [Aurigma.GraphicsMill.Codecs.AdobeResourceBlock](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Codecs_AdobeResourceBlock.htm.md>)
- [Aurigma.GraphicsMill.Codecs.AdobeResourceDictionary](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Codecs_AdobeResourceDictionary.htm.md>)
- [Aurigma.GraphicsMill.Codecs.MetadataDictionary.Add(Object,Object)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Codecs_MetadataDictionary_Add_2_df764941.htm.md>)
- [Aurigma.GraphicsMill.Codecs.TiffChannelType](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Codecs_TiffChannelType.htm.md>)
- [Aurigma.GraphicsMill.Codecs.TiffExtraChannelEntry](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Codecs_TiffExtraChannelEntry.htm.md>)
- [Aurigma.GraphicsMill.Codecs.TiffWriter](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Codecs_TiffWriter.htm.md>)
- [Aurigma.GraphicsMill.Codecs.TiffWriter.AdobeResources](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Codecs_TiffWriter_AdobeResources.htm.md>)
- [Aurigma.GraphicsMill.Codecs.TiffWriter.ExtraChannels](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Codecs_TiffWriter_ExtraChannels.htm.md>)
- [Aurigma.GraphicsMill.Color](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Color.htm.md>)
- [Aurigma.GraphicsMill.Color.ColorSpace](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Color_ColorSpace.htm.md>)
- [Aurigma.GraphicsMill.ColorSpace](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_ColorSpace.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Graphics.FillEllipse(Brush,RectangleF)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Drawing_Graphics_FillEllipse_2_9763ccb2.htm.md>)
- [Aurigma.GraphicsMill.Drawing.SolidBrush](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_SolidBrush.htm.md>)
- [Aurigma.GraphicsMill.GrayscaleColor](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_GrayscaleColor.htm.md>)
- [Aurigma.GraphicsMill.GrayscaleColor.L](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_GrayscaleColor_L.htm.md>)
- [Aurigma.GraphicsMill.LabColor](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_LabColor.htm.md>)
- [Aurigma.GraphicsMill.LabColor.A](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_LabColor_A.htm.md>)
- [Aurigma.GraphicsMill.LabColor.B](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_LabColor_B.htm.md>)
- [Aurigma.GraphicsMill.LabColor.L](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_LabColor_L.htm.md>)
- [Aurigma.GraphicsMill.RgbColor.B](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_RgbColor_B.htm.md>)
- [Aurigma.GraphicsMill.RgbColor.G](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_RgbColor_G.htm.md>)
- [Aurigma.GraphicsMill.RgbColor.R](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_RgbColor_R.htm.md>)
