<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<samples generated="2025-12-01T08:09:03.6607282Z" root="PackedSamples">
  <sample path="ColorManagement/Channels/AddAlphaChannel.cs">
    <title>Add Alpha Channel</title>
    <description>Generates an elliptical alpha channel and applies it to the source image.</description>
    <instruction>Adds an alpha channel to an image by creating a grayscale bitmap and setting it as the alpha channel.</instruction>
    <output><![CDATA[The following code:

- Loads the image from the file `Chicago.jpg`.
- Creates a grayscale `alpha` bitmap with a fully transparent alpha channel.
- Draws a filled ellipse with full opacity onto the `alpha` bitmap.
- Sets the `alpha` bitmap as the alpha channel of the original image.
- Saves the resulting image as a PNG file `AddAlphaChannel.png`.]]></output>
    <tags>
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
      <tag id="channels" title="Channels" description="Reading and combining image channels" />
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;]]></usings>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Chicago.jpg"))
using (var alpha = new Bitmap(bitmap.Width, bitmap.Height, PixelFormat.Format8bppGrayscale, new GrayscaleColor(0)))
using (var graphics = alpha.GetAdvancedGraphics())
{
    graphics.FillEllipse(
        new SolidBrush(new GrayscaleColor(255)),
        0,
        0,
        bitmap.Width,
        bitmap.Height);

    bitmap.Channels.SetAlpha(alpha);

    bitmap.Save("AddAlphaChannel.png");
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>AddAlphaChannel.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="ColorManagement/Channels/AddAlphaChannelMemoryFriendly.cs">
    <title>Add Alpha Channel (Memory Friendly)</title>
    <description>Generates an elliptical alpha channel and applies it to the source image using memory-friendly Pipeline API.</description>
    <instruction>Demonstrates how to add an alpha channel to an image using a memory-friendly Pipeline API.</instruction>
    <output><![CDATA[The following code:

- Loads the image from `Chicago.jpg` using `ImageReader`.
- Creates an empty alpha channel (grayscale image with transparent background) using `ImageGenerator`.
- Sets up a `Drawer` to draw a filled ellipse on the alpha channel.
- Uses `SetAlpha` to set the created alpha channel onto the image.
- Writes the resulting image (with the added alpha channel) to `AddAlphaChannelMemoryFriendly.png`.]]></output>
    <tags>
      <tag id="channels" title="Channels" description="Reading and combining image channels" />
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;
using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[// reader --------------->  setAlpha  --->  writer
// alpha  --->  drawer  ---/
using (var reader = ImageReader.Create("Chicago.jpg"))
using (var alpha = new ImageGenerator(reader.Width, reader.Height, PixelFormat.Format8bppGrayscale, new GrayscaleColor(0)))
using (var drawer = new Drawer())
using (var setAlpha = new SetAlpha())
using (var writer = ImageWriter.Create("AddAlphaChannelMemoryFriendly.png"))
{
    drawer.Draw += (sender, e) =>
    {
        e.Graphics.FillEllipse(
            new SolidBrush(new GrayscaleColor(255)),
            0,
            0,
            reader.Width,
            reader.Height);
    };

    setAlpha.AlphaSource = alpha + drawer;

    Pipeline.Run(reader + setAlpha + writer);
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>AddAlphaChannelMemoryFriendly.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Transforms/ColorAdjustment/AdjustColorsUsingLab.cs">
    <title>Adjust Colors Using Lab</title>
    <description>Adjusts hue modifying [a] component of Lab color space.</description>
    <instruction>Adjust colors of an image using Lab channels. The `b` channel (blue/yellow) is modified to increase yellow.</instruction>
    <output><![CDATA[The code:

- Splits the image into Lab channels (`L`, `A`, `B`) using a `LabChannelSplitter`.
- The yellow in the `b` channel is increased by applying a channel balance adjustment.
- Combines the channels back together using a `LabChannelCombiner` and converts the result back to RGB format.
- Saves the adjusted image.]]></output>
    <tags>
      <tag id="color-adjustment" title="Color Adjustment" description="Adjusting brightness, contrast and color" />
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[// L - lightness
// a - green/red
// b - blue/yellow

using (var lChannel = new Bitmap())
using (var aChannel = new Bitmap())
using (var bChannel = new Bitmap())
{
    using (var reader = ImageReader.Create("Chicago.jpg"))
    using (var labConverter = new Aurigma.GraphicsMill.Transforms.ColorConverter(PixelFormat.Format24bppLab))
    using (var splitter = new LabChannelSplitter())
    {
        splitter.L = lChannel;
        splitter.A = aChannel;
        splitter.B = bChannel;

        Pipeline.Run(reader + labConverter + splitter);
    }

    // Increase yellow
    bChannel.ColorAdjustment.ChannelBalance(new float[] { 0.1f }, new float[] { 1f });

    using (var combiner = new LabChannelCombiner())
    using (var rgbConverter = new Aurigma.GraphicsMill.Transforms.ColorConverter(PixelFormat.Format24bppRgb))
    using (var writer = ImageWriter.Create("AdjustColorsUsingLab.jpg"))
    {
        combiner.L = lChannel;
        combiner.A = aChannel;
        combiner.B = bChannel;

        rgbConverter.DestinationProfile = ColorProfile.FromSrgb();

        Pipeline.Run(combiner + rgbConverter + writer);
    }
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>AdjustColorsUsingLab.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Transforms/ColorAdjustment/AdjustHsl.cs">
    <title>Adjust HSL</title>
    <description>Adjusts HSL (Hue-Saturation-Lightness) balance.</description>
    <instruction>Adjust the hue, saturation, and lightness (HSL) of an image.</instruction>
    <output><![CDATA[The code:

- Adjusts the hue by 0.2f, saturation by -0.1f, and lightness by 0.1f using the `AdjustHsl` method.
- Saves the image with the HSL adjustments applied.]]></output>
    <tags>
      <tag id="color-adjustment" title="Color Adjustment" description="Adjusting brightness, contrast and color" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Chicago.jpg"))
{
    bitmap.ColorAdjustment.AdjustHsl(0.2f, -0.1f, 0.1f);

    bitmap.Save("AdjustHsl.jpg");
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>AdjustHsl.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="ColorManagement/LabColorSpace/AdjustLightnessRgb.cs">
    <title>Adjust Lightness (RGB)</title>
    <description>Adjusts brightness modifying all channels of RGB color space.</description>
    <instruction>Adjusts the brightness (lightness) of an image directly in the RGB color space using the Pipeline API.</instruction>
    <output><![CDATA[The code:

- Reads the "Chicago.jpg" image using `ImageReader`.
- Applies brightness adjustment using the `Brightness` transform with the specified `brightnessAmount`.
- Writes the modified image to "AdjustLightnessRgb.jpg" using `ImageWriter`.]]></output>
    <tags>
      <tag id="channels" title="Channels" description="Reading and combining image channels" />
      <tag id="transform" title="Transform" description="Image transforms and effects" />
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[using (var reader = ImageReader.Create("Chicago.jpg"))
using (var brightness = new Brightness(brightnessAmount))
using (var writer = ImageWriter.Create("AdjustLightnessRgb.jpg"))
{
    Pipeline.Run(reader + brightness + writer);
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>AdjustLightnessRgb.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="ColorManagement/LabColorSpace/AdjustLightnessLab.cs">
    <title>Adjust Lightness Lab</title>
    <description>Adjusts brightness modifying lightness channel of Lab color space.</description>
    <instruction>Adjusts the lightness of an image using the LAB color space.</instruction>
    <output><![CDATA[The code:

- Reads the "Chicago.jpg" image using `ImageReader`.
- Converts the image to LAB color space (`PixelFormat.Format24bppLab`) with `ColorConverter`.
- Splits the LAB channels (L, A, B) using `LabChannelSplitter` and stores them in separate `Bitmap` objects (`lChannel`, `aChannel`, `bChannel`).
- Adjusts the brightness of the L channel using `ColorAdjustment.Brightness`.
- Combines the modified LAB channels (L, A, B) back together using `LabChannelCombiner`.
- Converts the resulting LAB image back to RGB color space with `ColorConverter`, applying an sRGB color profile.
- Saves the adjusted image as "AdjustLightnessLab.jpg" using `ImageWriter`.]]></output>
    <tags>
      <tag id="channels" title="Channels" description="Reading and combining image channels" />
      <tag id="transform" title="Transform" description="Image transforms and effects" />
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var lChannel = new Bitmap())
using (var aChannel = new Bitmap())
using (var bChannel = new Bitmap())
{
    using (var reader = ImageReader.Create("Chicago.jpg"))
    using (var labConverter = new Aurigma.GraphicsMill.Transforms.ColorConverter(PixelFormat.Format24bppLab))
    using (var splitter = new LabChannelSplitter())
    {
        splitter.L = lChannel;
        splitter.A = aChannel;
        splitter.B = bChannel;

        Pipeline.Run(reader + labConverter + splitter);
    }

    lChannel.ColorAdjustment.Brightness(brightnessAmount);

    using (var combiner = new LabChannelCombiner())
    using (var rgbConverter = new Aurigma.GraphicsMill.Transforms.ColorConverter(PixelFormat.Format24bppRgb))
    using (var writer = ImageWriter.Create("AdjustLightnessLab.jpg"))
    {
        combiner.L = lChannel;
        combiner.A = aChannel;
        combiner.B = bChannel;

        rgbConverter.DestinationProfile = ColorProfile.FromSrgb();

        Pipeline.Run(combiner + rgbConverter + writer);
    }
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>AdjustLightnessLab.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Transforms/AdvancedToneCorrection/ApplyLut.cs">
    <title>Apply LUT</title>
    <description>Applies LUT (look-up table) correction.</description>
    <instruction>Apply a custom LUT (Look-Up Table) to an image for color adjustment.</instruction>
    <output><![CDATA[The code:

- Creates a LUT and sets specific points for the color mapping (50 -> 70, 100 -> 150).
- Uses cubic interpolation for smoother transitions between points.
- Applies the LUT to the image's color adjustment using `ApplyLut`.
- Saves the color-adjusted image to an output file.]]></output>
    <tags>
      <tag id="color-adjustment" title="Color Adjustment" description="Adjusting brightness, contrast and color" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Chicago.jpg"))
using (var lut = new Lut())
{
    lut.SetPoint(50, 70);
    lut.SetPoint(100, 150);
    lut.InterpolationMode = LutInterpolationMode.Cubic;

    bitmap.ColorAdjustment.ApplyLut(lut);

    bitmap.Save("ApplyLut.jpg");
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>ApplyLut.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Text/TextLayout/ArtTexts.cs">
    <title>Art text</title>
    <description>Shows different types of art texts.</description>
    <instruction>This code demonstrates how to create and apply different text effects (Bridge, Bulge, Pinch, Roof, Valley, Wedge, Round) using the GraphicsMill library.
Each text effect modifies the text shape or appearance based on the specified parameters such as center position, bend, scaling, tilt, and additional effects like shadow and glow.</instruction>
    <output><![CDATA[The code:

- Creates a 600x400 pixel bitmap with a white background.
- Defines a set of seven different text effects (Bridge, Bulge, Pinch, Roof, Valley, Wedge, Round) using various font and brush styles.
- Each text effect is drawn at a different position on the bitmap with varying parameters (e.g., bend, tilt, shadow, and glow).
- The final result is saved to "ArtText.png".]]></output>
    <tags>
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="art-text" title="Art Text" description="Creating artistic text" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;
using Aurigma.GraphicsMill.AdvancedDrawing.Art;
using Aurigma.GraphicsMill.AdvancedDrawing.Effects;]]></usings>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap(600, 400, PixelFormat.Format24bppRgb, new RgbColor(0xff, 0xff, 0xff, 0xff)))
using (var graphics = bitmap.GetAdvancedGraphics())
{
    var font = graphics.CreateFont("Arial", 48);
    var brush = new SolidBrush(new RgbColor(0x41, 0x41, 0x41));

    var texts = new Aurigma.GraphicsMill.AdvancedDrawing.Text[]
    {
        new BridgeText("Bridge Text", font, brush)
        {
            Center = new System.Drawing.PointF(150f, 50f),
            Bend = 0.2f,
        },
        new BulgeText("Bulge Text", font, brush)
        {
            Center = new System.Drawing.PointF(150f, 150f),
            Bend = 0.2f,
        },
        new PinchText("Pinch Text", font, brush)
        {
            Center = new System.Drawing.PointF(150f, 250f),
            Bend = 0.2f,
        },
        new RoofText("Roof Text", font, brush)
        {
            Center = new System.Drawing.PointF(150f, 350f),
            Bend = -0.2f,
        },
        new ValleyText("Valley Text", font)
        {
            Brush = new SolidBrush(RgbColor.Yellow),
            Pen = new Pen(RgbColor.Red, 2f),
            Center = new System.Drawing.PointF(450f, 50f),
            Bend = 0.2f,
        },
        new WedgeText("Wedge Text", font, brush)
        {
            Center = new System.Drawing.PointF(450f, 150f),
            LeftScale = 2.0f,
            RightScale = 0.7f,
            Tilt = -0.3f,
            Effect = new Shadow(new RgbColor(80, 80, 80), 5, 4, 4),
        },
        new RoundText("Round Text", font, brush)
        {
            Center = new System.Drawing.PointF(450f, 300f),
            Bend = 1,
            Effect = new Glow(new RgbColor(0x66, 0xaf, 0xe9), 5),
        },
    };

    foreach (var text in texts)
    {
        graphics.DrawText(text);
    }

    bitmap.Save("ArtText.png");
}]]></code>
    <io>
      <out_preview>
        <file>ArtText.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Drawing/DrawingImages/ArtisticFrame.cs">
    <title>Artistic Frame</title>
    <description>Draws artistic frame.</description>
    <instruction>Write a C# program that creates an artistic photo frame by loading a main image "Copenhagen_Rgb.jpg", matt pattern "Matt.png", and frame pattern "Frame.png", then composes them using AdvancedGraphics with tiled matt background, rotated and clipped frame borders on all four sides using Path clipping, centered image placement with double light gray border, and saves the result as "DrawArtisticFrame.png".</instruction>
    <output><![CDATA[Below is a C# code sample that creates a complex artistic frame composition:

The code demonstrates advanced GraphicsMill drawing techniques including: lambda-based bitmap tiling for repeating patterns, DPI synchronization between layers, frame border construction using 90-degree rotations with triangular Path clipping for corners, centered image placement with offset double border using Pen drawing, and comprehensive using statement resource management. The composition creates professional photo frame effects with seamless matt background, properly mitered frame corners via clipping paths, and decorative borders around the centered subject image.]]></output>
    <tags>
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <usings><![CDATA[using System;
using Aurigma.GraphicsMill.AdvancedDrawing;]]></usings>
    <code language="csharp"><![CDATA[var repeatBitmap = (Bitmap bitmap, int minWidth, int minHeight) =>
{
    int tileXCount = ((minWidth - 1) / bitmap.Width) + 1;
    int tileYCount = ((minHeight - 1) / bitmap.Height) + 1;

    var repeated = new Bitmap(tileXCount * bitmap.Width, tileYCount * bitmap.Height, PixelFormat.Format24bppRgb);

    using (var graphics = repeated.GetAdvancedGraphics())
    {
        for (var i = 0; i < tileXCount; i++)
        {
            for (var j = 0; j < tileYCount; j++)
            {
                graphics.DrawImage(bitmap, bitmap.Width * i, bitmap.Height * j);
            }
        }
    }

    return repeated;
};

int padding = 200;

using (var source = new Bitmap("Copenhagen_Rgb.jpg"))
{
    int width = source.Width + (padding * 2);
    int height = source.Height + (padding * 2);

    var mattPath = "Matt.png";
    var framePath = "Frame.png";

    using (var result = new Bitmap(width, height, PixelFormat.Format24bppRgb))
    using (var graphics = result.GetAdvancedGraphics())
    {
        // Draw matt
        using (var matt = new Bitmap(mattPath))
        {
            matt.DpiX = graphics.DpiX;
            matt.DpiY = graphics.DpiY;
            using (var mattRepeated = repeatBitmap(matt, result.Width, result.Height))
            {
                // Draw centered
                graphics.DrawImage(mattRepeated, 0, 0);
            }

            // Draw frame
            using (var frame = new Bitmap(framePath))
            {
                frame.DpiX = graphics.DpiX;
                frame.DpiY = graphics.DpiY;
                using (var frameRepeated = repeatBitmap(frame, frame.Width, Math.Max(result.Height, result.Width)))
                {
                    // Right border
                    graphics.DrawImage(frameRepeated, 0, 0);

                    // Left border
                    frameRepeated.Transforms.Rotate(180f);
                    graphics.DrawImage(frameRepeated, result.Width - frameRepeated.Width, 0);

                    // Top border
                    frameRepeated.Transforms.Rotate(270f);

                    var clippingPathTop = new Path();
                    clippingPathTop.MoveTo(0f, 0f);
                    clippingPathTop.LineTo((float)result.Width / 2f, (float)result.Width / 2f);
                    clippingPathTop.LineTo(result.Width, 0);
                    clippingPathTop.Close();

                    graphics.ClippingPaths.Add(clippingPathTop);

                    graphics.DrawImage(frameRepeated, 0, 0);

                    graphics.ClippingPaths.Clear();

                    // Bottom border
                    frameRepeated.Transforms.Rotate(180f);

                    var clippingPathBottom = new Path();
                    clippingPathBottom.MoveTo(0f, result.Height);
                    clippingPathBottom.LineTo((float)result.Width / 2f, (float)result.Height - ((float)result.Width / 2f));
                    clippingPathBottom.LineTo(result.Width, result.Height);
                    clippingPathBottom.Close();

                    graphics.ClippingPaths.Add(clippingPathBottom);

                    graphics.DrawImage(frameRepeated, 0, result.Height - frameRepeated.Height);

                    graphics.ClippingPaths.Clear();

                    // Draw image in the center
                    var rect1 = new System.Drawing.RectangleF(
                        (result.Width - source.Width) / 2,
                        (result.Height - source.Height) / 2,
                        source.Width,
                        source.Height);

                    graphics.DrawImage(source, rect1);

                    var pen = new Pen(RgbColor.LightGray, 4f);

                    graphics.DrawRectangle(pen, rect1);

                    float offset = 8f;

                    var rect2 = new System.Drawing.RectangleF(
                        rect1.X - offset,
                        rect1.Y - offset,
                        rect1.Width + (offset * 2),
                        rect1.Height + (offset * 2));

                    graphics.DrawRectangle(pen, rect2);
                }
            }
        }

        result.Save("DrawArtisticFrame.png");
    }
}]]></code>
    <io>
      <in_preview>
        <file>Copenhagen_Rgb.jpg</file>
        <file>Matt.png</file>
        <file>Frame.png</file>
      </in_preview>
      <out_preview>
        <file>DrawArtisticFrame.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="LargeImages/PipelineAPISyntax/BranchedPipeline.cs">
    <title>Assemble Pipeline manually</title>
    <description>In general, the Pipeline API assumes that each element may have several receivers, and each of them receives the same data to process. Here we illustrate how to implement the use case shown in the &lt;a href="https://www.graphicsmill.com/samples/1f5ac886-a760-4583-9223-cd254f5aa380"&gt;Create linear pipeline&lt;/a&gt; sample using the Pipeline class only for running, while constructing the data flow manually.&lt;br/&gt;&lt;br/&gt;
You can read more information about pipelines in the &lt;a href="https://www.graphicsmill.com/docs/gm/processing-large-images-using-pipelines.htm"&gt;documentation&lt;/a&gt;.</description>
    <instruction>Resize an image to a width of 320 while maintaining the aspect ratio and save the result. Assemble pipeline manually with .Receivers collections without using Pipeline class.</instruction>
    <output><![CDATA[The code:

- Reads the image "Venice.jpg".
- Constructs a simple pipeline manually by wiring .Receivers:
reader → resize → writer.
- Resizes the image to a width of 320, maintaining the original aspect ratio.
- Saves the resized image as "Venice_small.jpg".]]></output>
    <tags>
      <tag id="branched-pipeline" title="Branched Pipeline" description="Building branched processing pipelines" />
      <tag id="resize" title="Resize" description="Resizing images" />
      <tag id="advanced" title="Advanced" description="Demonstrating advanced usage scenarios" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[// reader --->  resize  --->  writer
using (var reader = ImageReader.Create("Venice.jpg"))
using (var resize = new Resize(320, 0, ResizeInterpolationMode.High))
using (var writer = ImageWriter.Create("Venice_small.jpg"))
{
    // Reader element sends data to resize element
    reader.Receivers.Add(resize);

    // Resize element sends data to writer element
    resize.Receivers.Add(writer);

    // Pass first element
    Pipeline.Run(reader);
}]]></code>
    <io>
      <in_preview>
        <file>Venice.jpg</file>
      </in_preview>
      <out_preview>
        <file>Venice_small.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="ColorManagement/ColorProfile/SetEmbeddedProfile.cs">
    <title>Assign a color profile to a bitmap</title>
    <description>Replaces the embedded color profile of an image with a new one.</description>
    <instruction>Sets the embedded color profile of an image to sRGB and saves it.</instruction>
    <output><![CDATA[The following code:

- Loads the image (`Chicago.jpg`).
- Assigns the embedded color profile to the image using `ColorProfile.FromSrgb()`.
- Saves the image (`SetEmbeddedProfile.jpg`) with the newly set embedded sRGB color profile.]]></output>
    <tags>
      <tag id="color-management" title="Color Management" description="Color management with ICC profiles" />
      <tag id="color-profile" title="Color Profile" description="Using ICC color profiles" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
      <tag id="write" title="Write" description="Writing images with codecs" />
    </tags>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Chicago.jpg"))
{
    bitmap.ColorProfile = ColorProfile.FromSrgb();

    bitmap.Save("SetEmbeddedProfile.jpg");
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>SetEmbeddedProfile.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Transforms/BrightnessAndContrast/AutoBrightness.cs">
    <title>Auto Brightness</title>
    <description>Adjusts brightness automatically.</description>
    <instruction>Apply automatic brightness adjustment to an image.</instruction>
    <output><![CDATA[The code:

- Uses the `AutoBrightness` method to adjust the brightness of the image automatically.
- Saves the modified image to a new file.]]></output>
    <tags>
      <tag id="color-adjustment" title="Color Adjustment" description="Adjusting brightness, contrast and color" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Chicago.jpg"))
{
    bitmap.ColorAdjustment.AutoBrightness();

    bitmap.Save("AutoBrightness.jpg");
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>AutoBrightness.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Transforms/BrightnessAndContrast/AutoContrast.cs">
    <title>Auto Contrast</title>
    <description>Adjusts contract automatically.</description>
    <instruction>Apply automatic contrast adjustment to an image.</instruction>
    <output><![CDATA[The code:

- Uses the `AutoContrast` method to automatically adjust the contrast of the image.
- Saves the processed image with enhanced contrast.]]></output>
    <tags>
      <tag id="color-adjustment" title="Color Adjustment" description="Adjusting brightness, contrast and color" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Chicago.jpg"))
{
    bitmap.ColorAdjustment.AutoContrast();

    bitmap.Save("AutoContrast.jpg");
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>AutoContrast.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Text/TextLayout/Autofit.cs">
    <title>Autofit</title>
    <description>Demonstrates how to fit the largest possible text inside a PathBoundedText area.</description>
    <instruction>This code demonstrates how to fit text inside a specified path, in this case, an ellipse, using the GraphicsMill library.
The `ShapeTextFrame` is used to place the text inside the path, ensuring it fills the area as much as possible while maintaining the desired text properties.
The process uses the `CopyfittingMode.Fill` to scale the text accordingly to fit the shape.</instruction>
    <output><![CDATA[The code:

- Creates a 400x400 pixel bitmap with a white background.
- Defines a `Text` object with a string and applies the "Verdana" font.
- Creates a `ShapeTextFrame` where the text is constrained within an elliptical path.
- The text is fitted to the elliptical area using the `Fill` copyfitting mode.
- A blue pen is used to outline the shape (ellipse) containing the text.
- The final result is saved to "FitTextToArea.png".]]></output>
    <tags>
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="text-layout" title="Text Layout" description="Controlling advanced text layout" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;]]></usings>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap(400, 400, PixelFormat.Format24bppRgb, RgbColor.White))
using (var graphics = bitmap.GetAdvancedGraphics())
{
    var text = new Text();

    text.String = "Since 2001, Aurigma have helped software developers add imaging functionality to their applications in a variety of industries. Our image processing Software Development Kit for .NET, Graphics Mill, is a truly powerful product we are proud to have developed.";
    text.CharStyle.PostScriptName = "Verdana";

    var shapeTextFrame = new ShapeTextFrame();

    shapeTextFrame.Shape = new Path();
    shapeTextFrame.Shape.DrawEllipse(0, 0, graphics.Width, graphics.Height);

    shapeTextFrame.CopyfittingMode = CopyfittingMode.Fill;

    text.Frames.Add(shapeTextFrame);

    graphics.DrawPath(new Pen(RgbColor.Blue), shapeTextFrame.Shape);
    graphics.DrawText(text);

    bitmap.Save("FitTextToArea.png");
}]]></code>
    <io>
      <out_preview>
        <file>FitTextToArea.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Transforms/RotateAndFlip/Autorotate.cs">
    <title>Autorotate</title>
    <description>Automatically rotates image based on EXIF orientation metadata.</description>
    <instruction>Write a C# program that automatically rotates an image "Gondola.jpg" based on EXIF orientation metadata using ImageReader to extract orientation value, then applies appropriate Rotate and Flip transforms via Pipeline API for non-JPEG formats or LosslessJpeg for JPEG files to preserve quality, updates metadata to reset orientation to 1, and saves as "Autorotate.jpg".</instruction>
    <output><![CDATA[Below is a C# code sample that implements automatic image rotation based on EXIF orientation:

The code demonstrates comprehensive EXIF-aware autorotation handling both JPEG (using LosslessJpeg for quality preservation via System.Drawing.RotateFlipType) and non-JPEG formats (using Rotate/Flip transforms in Pipeline). It extracts orientation from ExifDictionary, maps EXIF values 2-8 to rotation angles (90/180/270) and flip types (horizontal/vertical), preserves metadata (EXIF/IPTC/Adobe/XMP) while resetting orientation to 1, and uses JPEG quality 85 for recompressed formats. The dual-path approach optimizes quality and performance based on input codec type.]]></output>
    <tags>
      <tag id="rotate" title="Rotate" description="Rotating images" />
      <tag id="exif" title="EXIF" description="Managing EXIF metadata" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
      <tag id="transform" title="Transform" description="Image transforms and effects" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[public static void Run()
{
    Autorotate("Gondola.jpg", "Autorotate.jpg");
}

private static bool Autorotate(string pathIn, string pathOut)
{
    ushort orientation;

    using (var reader = ImageReader.Create(pathIn))
    {
        var exif = reader.Exif;

        if (exif == null || !exif.Contains(ExifDictionary.Orientation))
        {
            return false;
        }

        orientation = (ushort)exif[ExifDictionary.Orientation];

        // 1         2       3      4         5            6           7          8

        // ######  ######      ##  ##      ##########  ##                  ##  ##########
        // ##          ##      ##  ##      ##  ##      ##  ##          ##  ##      ##  ##
        // ####      ####    ####  ####    ##          ##########  ##########          ##
        // ##          ##      ##  ##
        // ##          ##  ######  ######

        if (orientation == 1)
        {
            return false;
        }

        using (var writer = ImageWriter.Create(pathOut))
        {
            if (!(reader is JpegReader) || !(writer is JpegWriter))
            {
                RotateWithRecompression(reader, writer, orientation);

                return true;
            }
        }
    }

    RotateJpegWithRecompression(pathIn, pathOut, orientation);

    return true;
}

private static void RotateWithRecompression(ImageReader reader, ImageWriter writer, uint orientation)
{
    using (var rotate = new Aurigma.GraphicsMill.Transforms.Rotate())
    using (var flip = new Aurigma.GraphicsMill.Transforms.Flip())
    {
        flip.Type = Aurigma.GraphicsMill.Transforms.FlipType.None;

        switch (orientation)
        {
            case 2:
                flip.Type = Aurigma.GraphicsMill.Transforms.FlipType.Vertical;
                break;

            case 3:
                rotate.Angle = 180f;
                break;

            case 4:
                flip.Type = Aurigma.GraphicsMill.Transforms.FlipType.Vertical;
                rotate.Angle = 180f;
                break;

            case 5:
                flip.Type = Aurigma.GraphicsMill.Transforms.FlipType.Horizontal;
                rotate.Angle = 270f;
                break;

            case 6:
                rotate.Angle = 90f;
                break;

            case 7:
                flip.Type = Aurigma.GraphicsMill.Transforms.FlipType.Horizontal;
                rotate.Angle = 90f;
                break;

            case 8:
                rotate.Angle = 270;
                break;
        }

        var jpegWriter = writer as JpegWriter;

        if (jpegWriter != null)
        {
            jpegWriter.Quality = 85;
        }

        var metadataWriter = writer as IMetadataWriter;

        if (metadataWriter != null)
        {
            metadataWriter.Exif = reader.Exif ?? new ExifDictionary();
            metadataWriter.Exif[ExifDictionary.Orientation] = 1;

            metadataWriter.Iptc = reader.Iptc;
            metadataWriter.AdobeResources = reader.AdobeResources;
            metadataWriter.Xmp = reader.Xmp;
        }

        if (flip.Type == Aurigma.GraphicsMill.Transforms.FlipType.None)
        {
            Aurigma.GraphicsMill.Pipeline.Run(reader + rotate + writer);
        }
        else if (rotate.Angle == 0)
        {
            Aurigma.GraphicsMill.Pipeline.Run(reader + flip + writer);
        }
        else
        {
            Aurigma.GraphicsMill.Pipeline.Run(reader + rotate + flip + writer);
        }
    }
}

private static void RotateJpegWithRecompression(string pathIn, string pathOut, uint orientation)
{
    using (var losslessJpeg = new LosslessJpeg(pathIn))
    {
        System.Drawing.RotateFlipType flipType;

        switch (orientation)
        {
            case 2:
                flipType = System.Drawing.RotateFlipType.RotateNoneFlipX;
                break;

            case 3:
                flipType = System.Drawing.RotateFlipType.Rotate180FlipNone;
                break;

            case 4:
                flipType = System.Drawing.RotateFlipType.Rotate180FlipX;
                break;

            case 5:
                flipType = System.Drawing.RotateFlipType.Rotate90FlipX;
                break;

            case 6:
                flipType = System.Drawing.RotateFlipType.Rotate90FlipNone;
                break;

            case 7:
                flipType = System.Drawing.RotateFlipType.Rotate270FlipX;
                break;

            case 8:
                flipType = System.Drawing.RotateFlipType.Rotate270FlipNone;
                break;

            default:
                flipType = System.Drawing.RotateFlipType.RotateNoneFlipNone;
                break;
        }

        losslessJpeg.Exif[ExifDictionary.Orientation] = 1;

        losslessJpeg.WriteRotated(pathOut, flipType);
    }
}]]></code>
    <io>
      <in_preview>
        <file>Gondola.jpg</file>
      </in_preview>
      <out_preview>
        <file>Autorotate.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Transforms/Bezier/Bezier.cs">
    <title>Bezier Transform</title>
    <description>Performs a Bezier transform on an image using the specified control points.</description>
    <instruction>Apply a Bezier transformation on an image based on the specified control points.</instruction>
    <output><![CDATA[The code:

- Defines a set of control points that determine the shape of the Bezier curve.
- Applies the Bezier transformation to the image, altering its content according to the curve.
- Saves the transformed image with the specified effect to a file.]]></output>
    <tags>
      <tag id="transform" title="Transform" description="Image transforms and effects" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[private static System.Drawing.PointF[] controlPoints = new[]
{
    new System.Drawing.PointF(0.0f, 0.0f),
    new System.Drawing.PointF(200.0f, 164.760284f),
    new System.Drawing.PointF(400.0f, -164.760284f),
    new System.Drawing.PointF(600.0f, 0.0f),
    new System.Drawing.PointF(0.0f, 150.0f),
    new System.Drawing.PointF(200.0f, 314.760284f),
    new System.Drawing.PointF(400.0f, -14.7602825f),
    new System.Drawing.PointF(600.0f, 150.0f),
    new System.Drawing.PointF(0.0f, 300.0f),
    new System.Drawing.PointF(200.0f, 464.760284f),
    new System.Drawing.PointF(400.0f, 135.239716f),
    new System.Drawing.PointF(600.0f, 300.0f),
    new System.Drawing.PointF(0.0f, 450.0f),
    new System.Drawing.PointF(200.0f, 614.760254f),
    new System.Drawing.PointF(400.0f, 285.239716f),
    new System.Drawing.PointF(600.0f, 450.0f),
};

public static void Run()
{
    using (var bitmap = new Bitmap("Chicago.jpg"))
    {
        bitmap.Transforms.ApplyBezier(controlPoints, RgbColor.Transparent, InterpolationMode.High);
        bitmap.Save("Bezier.jpg");
    }
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>Bezier.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Text/TextLayout/BoundedText.cs">
    <title>Bounded Text</title>
    <description>Demonstrates how to use bounded text.</description>
    <instruction>This code demonstrates how to draw bounded text inside a specific rectangular area.
It uses the `BoundedText` class to ensure that the text fits within the defined rectangle, and it draws the text using a specific font and brush.
A blue rectangle outlines the bounded text area to visually indicate the space allocated for the text.</instruction>
    <output><![CDATA[The code:

- Creates a 250x250 pixel bitmap with a white background.
- Defines a rectangle for bounding the text (20x20 to 180x150).
- Uses the `BoundedText` class to set the text inside this rectangle, using the "Verdana" font and a gray brush.
- The text is drawn inside the bounded area with automatic wrapping, if necessary.
- A blue rectangle is drawn around the area, highlighting the text's boundaries.
- The final image is saved as "BoundedText.png".]]></output>
    <tags>
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="text-layout" title="Text Layout" description="Controlling advanced text layout" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;]]></usings>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap(250, 250, PixelFormat.Format24bppRgb, new RgbColor(255, 255, 255, 255)))
using (var graphics = bitmap.GetAdvancedGraphics())
{
    var brush = new SolidBrush(new RgbColor(0x41, 0x41, 0x41));

    var boundedTextRect = new System.Drawing.RectangleF(20f, 20f, 180f, 150f);

    var text = new BoundedText(Texts.LoremIpsum, graphics.CreateFont("Verdana", 14f), brush)
    {
        Rectangle = boundedTextRect,
    };

    graphics.DrawText(text);

    graphics.DrawRectangle(new Pen(new RgbColor(0x4e, 0xb5, 0xe6)), boundedTextRect);

    bitmap.Save("BoundedText.png");
}]]></code>
    <io>
      <out_preview>
        <file>BoundedText.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Transforms/BrightnessAndContrast/Brightness.cs">
    <title>Brightness</title>
    <description>Adjusts brightness.</description>
    <instruction>Adjust the brightness of an image with a specific factor.</instruction>
    <output><![CDATA[The code:

- Applies a brightness adjustment with a factor of `0.1f` to the image.
- Saves the modified image with the adjusted brightness.]]></output>
    <tags>
      <tag id="color-adjustment" title="Color Adjustment" description="Adjusting brightness, contrast and color" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Chicago.jpg"))
{
    bitmap.ColorAdjustment.Brightness(0.1f);

    bitmap.Save("Brightness.jpg");
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>Brightness.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Transforms/BrightnessAndContrast/BrightnessContrast.cs">
    <title>Brightness Contrast</title>
    <description>Adjusts brightness/contrast.</description>
    <instruction>Adjust the brightness and contrast of an image with specific factors.</instruction>
    <output><![CDATA[The code:

- Applies a brightness adjustment with a factor of `0.1f` and a contrast adjustment with a factor of `0.2f` to the image.
- Saves the modified image with the adjusted brightness and contrast.]]></output>
    <tags>
      <tag id="color-adjustment" title="Color Adjustment" description="Adjusting brightness, contrast and color" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Chicago.jpg"))
{
    bitmap.ColorAdjustment.BrightnessContrast(0.1f, 0.2f);

    bitmap.Save("BrightnessContrast.jpg");
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>BrightnessContrast.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Transforms/ColorAdjustment/ChannelBalance.cs">
    <title>Channel Balance</title>
    <description>Modifies channel balance.</description>
    <instruction>Adjust the channel balance of an image by modifying specific color channels in a `Bitmap` object.</instruction>
    <output><![CDATA[The code:

- Applies a channel balance adjustment where the blue and green channels are unchanged (set to 0.0f) and
the red channel is increased by a factor of 0.3f.
- The result image is saved with the applied color channel adjustments.]]></output>
    <tags>
      <tag id="color-adjustment" title="Color Adjustment" description="Adjusting brightness, contrast and color" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Chicago.jpg"))
{
    // Pixel format specifies the order of channels
    // Example: Format24bppRgb - [Blue]|[Green]|[Red]
    // http://www.graphicsmill.com/docs/gm/accessing-pixel-data.htm#PixelsInMemory
    bitmap.ColorAdjustment.ChannelBalance(new float[] { 0.0f, 0.0f, 0.3f }, new float[] { 1f, 1f, 1f });

    bitmap.Save("ChannelBalance.jpg");
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>ChannelBalance.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="PSDFormat/ValidatePSD/CheckPsdFeatures.cs">
    <title>Check PSD Features</title>
    <description>Checks that PSD files contain only features from a predefined list.</description>
    <instruction>Write a C# program that validates multiple PSD files ("Mug.psd", "UnsupportedFeatures.psd") using PsdReader.CheckFeatures method against a predefined whitelist of supported features including raster layers, smart objects, normal blend mode, RGB color mode, and 8-bit channels, outputting validation status to console for each file to determine render compatibility.</instruction>
    <output><![CDATA[Below is a C# code sample that validates PSD feature compatibility for rendering:

The code demonstrates PSD feature validation using PsdReader.CheckFeatures with explicit whitelist of supported capabilities (LayerTypeRaster, LayerTypeSmartObject, BlendModeNormal, ColorModeRgb, ChannelSize8bit), enabling pre-processing quality assurance to identify PSD files compatible with specific rendering pipelines. The validation prevents runtime errors from unsupported features like advanced blend modes, 16-bit channels, CMYK color space, or complex layer types, supporting automated workflows where only validated PSD templates proceed to rendering, ensuring consistent output quality and preventing processing failures in batch production environments.]]></output>
    <tags>
      <tag id="psd" title="PSD" description="Importing layered PSD files" />
      <tag id="validation" title="Image Validation" description="Inspecting images for unsupported or problematic features" />
    </tags>
    <usings><![CDATA[using System;
using Aurigma.GraphicsMill.Codecs.Psd;]]></usings>
    <code language="csharp"><![CDATA[var filenames = new string[]
{
    "Mug.psd",
    "UnsupportedFeatures.psd",
};

// A list of features that can be correctly handled by a renderer
var renderSupportedFeatures = new PsdFeature[]
{
    PsdFeature.LayerTypeRaster,
    PsdFeature.LayerTypeSmartObject,
    PsdFeature.BlendModeNormal,
    PsdFeature.ColorModeRgb,
    PsdFeature.ChannelSize8bit,
};

foreach (var filename in filenames)
{
    using (var psdReader = new PsdReader(filename))
    {
        if (psdReader.CheckFeatures(renderSupportedFeatures))
        {
            Console.WriteLine("File {0} is valid", filename);
        }
        else
        {
            Console.WriteLine("File {0} is not valid", filename);
        }
    }
}]]></code>
    <io>
      <in_download>
        <file>Mug.psd</file>
        <file>UnsupportedFeatures.psd</file>
      </in_download>
      <out_preview>
        <file>CheckPsdFeatures.txt</file>
      </out_preview>
    </io>
  </sample>
  <sample path="PSDFormat/ValidatePSD/CheckPsdFeaturesWithOutput.cs">
    <title>Check PSD Features With Output</title>
    <description>Writes a message with a list of unsupported features.</description>
    <instruction>Write a C# program that validates "UnsupportedFeatures.psd" using PsdReader.CheckFeatures with output parameter to generate detailed string listing all unsupported features against the whitelist (raster layers, normal blend mode, RGB color, 8-bit channels), then displays the comprehensive validation report via Console.WriteLine showing specific PSD features that prevent rendering compatibility.</instruction>
    <output><![CDATA[Below is a C# code sample that generates detailed PSD feature validation report:

The code demonstrates PSD compatibility checking with detailed output generation using CheckFeatures(ref output) overload, which populates the output string with a comprehensive list of detected unsupported features (advanced blend modes, non-RGB color spaces, 16-bit channels, complex layer types) that violate the renderSupportedFeatures whitelist. This diagnostic reporting enables precise identification of PSD compatibility issues, supporting automated quality control, preprocessing workflows, and user feedback in design automation systems where specific PSD feature subsets must be validated before batch rendering or PDF export.]]></output>
    <tags>
      <tag id="psd" title="PSD" description="Importing layered PSD files" />
      <tag id="validation" title="Image Validation" description="Inspecting images for unsupported or problematic features" />
    </tags>
    <usings><![CDATA[using System;
using Aurigma.GraphicsMill.Codecs.Psd;]]></usings>
    <code language="csharp"><![CDATA[using (var psdReader = new PsdReader("UnsupportedFeatures.psd"))
{
    var renderSupportedFeatures = new PsdFeature[]
    {
        PsdFeature.LayerTypeRaster,
        PsdFeature.BlendModeNormal,
        PsdFeature.ColorModeRgb,
        PsdFeature.ChannelSize8bit,
    };

    string output = string.Empty;
    psdReader.CheckFeatures(renderSupportedFeatures, ref output);

    Console.WriteLine(output);
}]]></code>
    <io>
      <in_download>
        <file>UnsupportedFeatures.psd</file>
      </in_download>
      <out_preview>
        <file>CheckPsdFeaturesWithOutput.txt</file>
      </out_preview>
    </io>
  </sample>
  <sample path="ColorManagement/ColorProfile/CmykToCmykUsingDeviceLinkProfile.cs">
    <title>CMYK To CMYK Using Device Link Profile</title>
    <description>Converts one CMYK color space to another CMYK one using device link color profile.</description>
    <instruction>Converts a CMYK image using a device link profile and a destination profile.</instruction>
    <output><![CDATA[The code:

- Reads the "Copenhagen_CMYK.jpg" image using `ImageReader`.
- Uses `ColorConverter` to convert the image to CMYK format (`PixelFormat.Format32bppCmyk`) with the LittleCMS color management engine (`ColorManagementEngine.LittleCms`).
- A device link profile (`ISOcoated_v2_to_PSOcoated_v3_DeviceLink.icc`) is applied for color conversion.
- The destination profile (`PSOcoated_v3.icc`) is embedded into the result image, but it does not influence the conversion.
- The conversion is executed using `Pipeline.Run()` for memory-friendly processing and saving the result to "DeviceLinkProfile.jpg".]]></output>
    <tags>
      <tag id="color-management" title="Color Management" description="Color management with ICC profiles" />
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[// Source image with the "ISO Coated v2" color profile
using (var reader = ImageReader.Create("Copenhagen_CMYK.jpg"))
using (var converter = new ColorConverter(PixelFormat.Format32bppCmyk))
using (var writer = ImageWriter.Create("DeviceLinkProfile.jpg"))
{
    converter.ColorManagementEngine = ColorManagementEngine.LittleCms;

    // Device link profile is used for color conversion
    converter.DeviceLinkProfile = new ColorProfile("ISOcoated_v2_to_PSOcoated_v3_DeviceLink.icc");

    // Destination profile is just embedded into the result image. It is not used for color conversion.
    converter.DestinationProfile = new ColorProfile("PSOcoated_v3.icc");

    Pipeline.Run(reader + converter + writer);
}]]></code>
    <io>
      <in_preview>
        <file>Copenhagen_CMYK.jpg</file>
      </in_preview>
      <in_download>
        <file>ISOcoated_v2_to_PSOcoated_v3_DeviceLink.icc</file>
        <file>PSOcoated_v3.icc</file>
      </in_download>
      <out_preview>
        <file>DeviceLinkProfile.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="ColorManagement/ConvertingColorValues/CmykToRgbWithColorManagement.cs">
    <title>CMYK To RGB With Color Management</title>
    <description>Converts a color specified in CMYK color space to RGB color space.</description>
    <instruction>Converts a CMYK color to RGB using a specific color profile and prints the result.</instruction>
    <output><![CDATA[The code:

- Creates a `CmykColor` instance with values (20, 42, 211, 40) and assigns a color profile "ISOcoated_v2_eci.icc".
- Converts the CMYK color to RGB using the `sRGB` color profile as the destination profile.
- Outputs the CMYK to RGB conversion result in the console.]]></output>
    <tags>
      <tag id="color-management" title="Color Management" description="Color management with ICC profiles" />
      <tag id="color-conversion" title="Color Conversion" description="Converting colors between color spaces" />
    </tags>
    <usings><![CDATA[using System;
using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[public static class ColorExtension
{
    public static T To<T>(
        this Color color,
        ColorProfile destinationProfile = null,
        ColorManagementEngine engine = ColorManagementEngine.LittleCms,
        ColorProfile targetDeviceProfile = null,
        ColorTransformationIntent transformationIntent = ColorTransformationIntent.Perceptual)
        where T : Color, new() => ColorExtension.ConvertColor<T>(color, destinationProfile, engine, targetDeviceProfile, transformationIntent);

    internal static T ConvertColor<T>(
        Color color,
        ColorProfile destinationProfile,
        ColorManagementEngine engine = ColorManagementEngine.LittleCms,
        ColorProfile targetDeviceProfile = null,
        ColorTransformationIntent transformationIntent = ColorTransformationIntent.Perceptual)
        where T : Color, new()
    {
        if (destinationProfile == null)
        {
            Type colorType = typeof(T);
            if (colorType != typeof(LabColor) && colorType != typeof(Lab16Color))
            {
                throw new ArgumentException("Destination profile should be specified for converting to non-absolute color space (LabColor or Lab16Color)", "destinationProfile");
            }
        }

        using (var cc = new Aurigma.GraphicsMill.Transforms.ColorConverter())
        {
            cc.DestinationProfile = destinationProfile;
            cc.TargetDeviceProfile = targetDeviceProfile;
            cc.ColorManagementEngine = engine;
            cc.TransformationIntent = transformationIntent;

            T tempColor = new T();

            cc.DestinationPixelFormat = tempColor.PixelFormat;

            return (T)cc.ConvertColor(color, color.Profile);
        }
    }

    internal static T ConvertColor<T>(
        Color color,
        string destinationProfile,
        ColorManagementEngine engine = ColorManagementEngine.LittleCms,
        ColorProfile targetDeviceProfile = null,
        ColorTransformationIntent transformationIntent = ColorTransformationIntent.Perceptual)
        where T : Color, new()
    {
        return ConvertColor<T>(color, new ColorProfile(destinationProfile), engine, targetDeviceProfile, transformationIntent);
    }
}

public class ConvertCmykToRgbWithColorManagement
{
    public static void Run()
    {
        CmykColor cmykColor = new CmykColor(20, 42, 211, 40)
        {
            Profile = new ColorProfile("ISOcoated_v2_eci.icc"),
        };

        RgbColor rgbColor = cmykColor.To<RgbColor>(ColorProfile.FromSrgb());

        Console.WriteLine("With color management: {0} to {1}", cmykColor, rgbColor);
    }
}]]></code>
    <io>
      <in_download>
        <file>ISOcoated_v2_eci.icc</file>
      </in_download>
      <out_preview>
        <file>ConvertCmykToRgbWithColorManagement.txt</file>
      </out_preview>
    </io>
  </sample>
  <sample path="ColorManagement/ColorProfile/ColorProofing.cs">
    <title>Color Proofing</title>
    <description>Color proofing - CMYK to RGB using destination (screen) and target device profile.</description>
    <instruction>Converts an image using color profiles for proofing from CMYK to RGB with a specific destination and target device profile.</instruction>
    <output><![CDATA[The code:

- Reads the image "Copenhagen_CMYK.jpg" using `ImageReader`.
- Converts the color profile from CMYK to RGB, applying color management with the `ISOnewspaper26v4_gr.icc` profile as the target device profile, and `sRGB` as the destination profile.
- Saves the converted image as "ColorProofing.jpg" using `ImageWriter`.
- The color conversion uses LittleCMS, the default color management engine, which does not need explicit specification.]]></output>
    <tags>
      <tag id="color-management" title="Color Management" description="Color management with ICC profiles" />
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[using (var reader = ImageReader.Create("Copenhagen_CMYK.jpg"))
using (var converter = new ColorConverter())
using (var writer = ImageWriter.Create("ColorProofing.jpg"))
{
    // LittleCMS is a default color management engine, so no need to specify it
    // converter.ColorManagementEngine = ColorManagementEngine.LittleCms;
    converter.DestinationProfile = ColorProfile.FromSrgb();
    converter.TargetDeviceProfile = new ColorProfile("ISOnewspaper26v4_gr.icc");

    Pipeline.Run(reader + converter + writer);
}]]></code>
    <io>
      <in_preview>
        <file>Copenhagen_CMYK.jpg</file>
      </in_preview>
      <in_download>
        <file>ISOnewspaper26v4_gr.icc</file>
      </in_download>
      <out_preview>
        <file>ColorProofing.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Text/EnhancedText/ColoredText.cs">
    <title>Colored Text</title>
    <description>Renders formatted, multi-colored text onto a bitmap.</description>
    <instruction>This code demonstrates how to render formatted text with different styles (such as color, bold, italic, font, etc.) to a bitmap.</instruction>
    <output><![CDATA[The code:

- Creates a `Bitmap` with specified dimensions and a white background color.
- Initializes the graphics context to draw on the bitmap.
- Defines a string with HTML-style tags for styling parts of the text (e.g., red color, bold, italic, font customization).
- Uses `BoundedText` to specify the formatted text, applying the styles from the string.
- Draws the formatted text onto the bitmap.
- Saves the resulting image as a PNG file with the name `ColoredText.png`.]]></output>
    <tags>
      <tag id="text" title="Text" description="Rendering and formatting text" />
      <tag id="formatted-text" title="Formatted Text" description="XML-based formatted text syntax" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;]]></usings>
    <code language="csharp"><![CDATA[// Here one may find all possible tags
// https://www.graphicsmill.com/docs/gm/advanced-formatted-text.htm

using (var bitmap = new Bitmap(600, 400, PixelFormat.Format24bppRgb, new RgbColor(255, 255, 255, 255)))
using (var graphics = bitmap.GetAdvancedGraphics())
{
    var brush = new SolidBrush(RgbColor.Black);

    var dummyText = @"Lorem ipsum dolor sit <span style='color:red;'>amet</span>, consectetur adipiscing elit. " +
        @"<span style='bold:true;underline:true;color:rgb(0,0,255)'>Cras</span> elementum quam ac nisi varius gravida. Mauris ornare, " +
        @"<span style='font-name:Times New Roman;font-size:60pt;pen-color:green;pen-width:1px;color:yellow;'>dolor</span> et scelerisque " +
        @"volutpat, <span style='italic:true;color:gray;'>enim urna commodo odio, <span style='color:green;'>consequat</span> fermentum sem arcu</span> sit amet nisl. " +
        @"Aliquam tincidunt id neque in gravida. Mauris mollis est vulputate suscipit facilisis.";

    var boundedText = new BoundedText(dummyText, graphics.CreateFont("Verdana", 26f), brush)
    {
        Rectangle = new System.Drawing.RectangleF(20f, 20f, 560f, 360f),
    };

    graphics.DrawText(boundedText);

    bitmap.Save("ColoredText.png");
}]]></code>
    <io>
      <out_preview>
        <file>ColoredText.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Text/EnhancedText/ColoredWatermark.cs">
    <title>Colored Watermark</title>
    <description>Demonstrates how to apply a colored watermark to an image using a tiling brush with text rendering.</description>
    <instruction>This code demonstrates how to apply a colored watermark to an image using a tiling brush with text rendering.</instruction>
    <output><![CDATA[The code:

- Loads an image (`Venice.jpg`) into a `Bitmap` object.
- Initializes the graphics context for drawing on the bitmap.
- Calculates a font size based on the bitmap's DPI and height.
- Creates a `TilingBrush` with specified dimensions and DPI for tiling.
- Defines a formatted string with HTML-style tags for styling the watermark text (e.g., color, pen-width, and transparency).
- Creates a `PlainText` object with the formatted string and font, setting its position and brush (which is null for the text).
- Registers fonts and draws the text with the tiling brush applied at a 45-degree angle.
- Sets the graphics opacity to 0.5 for a semi-transparent effect.
- Fills the entire image with the watermark text using the tiling brush.
- Saves the modified image as a new file (`ColoredWatermark.jpg`).]]></output>
    <tags>
      <tag id="text" title="Text" description="Rendering and formatting text" />
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="formatted-text" title="Formatted Text" description="XML-based formatted text syntax" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;]]></usings>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Venice.jpg"))
using (var gr = bitmap.GetAdvancedGraphics())
{
    var fontSize = UnitConverter.ConvertPixelsToUnits(bitmap.DpiY, bitmap.Height, Unit.Point) / 20.0f;

    var brush = new TilingBrush(600, 300, bitmap.DpiX, bitmap.DpiY);

    var formattedString = @"<span style='color:red'>Colored</span><br/>
    <span style='color:rgb(0, 0, 0, 0);pen-color:rgb(200, 200, 200, 255);pen-width:5pt'>watermark</span>";

    var text = new PlainText(formattedString, gr.CreateFont("Arial", fontSize))
    {
        Position = new System.Drawing.Point(10, 100),
        Brush = null,
    };

    brush.Graphics.FontRegistry = FontRegistry.Installed;
    brush.Graphics.DrawText(text);
    brush.Transform = new System.Drawing.Drawing2D.Matrix();
    brush.Transform.Rotate(45);

    gr.Opacity = 0.5f;
    gr.FillRectangle(brush, 0, 0, bitmap.Width, bitmap.Height);

    bitmap.Save("ColoredWatermark.jpg");
}]]></code>
    <io>
      <in_preview>
        <file>Venice.jpg</file>
      </in_preview>
      <out_preview>
        <file>ColoredWatermark.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="ColorManagement/Channels/CombineChannels.cs">
    <title>Combine channels</title>
    <description>Combines image channels from multiple sources into a single image.</description>
    <instruction>Demonstrates how to combine image channels from multiple sources (C, M, Y, K) into a single image.</instruction>
    <output><![CDATA[The following code:

- Reads the individual CMYK channels (C, M, Y, K) from TIFF files (`Copenhagen_C.tif`, `Copenhagen_M.tif`, `Copenhagen_Y.tif`, `Copenhagen_K.tif`) using `TiffReader`.
- Combines these channels into a single image using `CmykChannelCombiner`.
- Writes the resulting image with the combined CMYK channels to a `Copenhagen_CMYK_Combined.jpg` file.]]></output>
    <tags>
      <tag id="channels" title="Channels" description="Reading and combining image channels" />
      <tag id="write" title="Write" description="Writing images with codecs" />
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var writer = ImageWriter.Create("Copenhagen_CMYK_Combined.jpg"))
using (var combiner = new CmykChannelCombiner())
using (var readerC = ImageReader.Create("Copenhagen_C.png"))
using (var readerM = ImageReader.Create("Copenhagen_M.png"))
using (var readerY = ImageReader.Create("Copenhagen_Y.png"))
using (var readerK = ImageReader.Create("Copenhagen_K.png"))
{
    combiner.C = readerC;
    combiner.M = readerM;
    combiner.Y = readerY;
    combiner.K = readerK;

    Pipeline.Run(combiner + writer);
}]]></code>
    <io>
      <in_preview>
        <file>Copenhagen_C.png</file>
        <file>Copenhagen_M.png</file>
        <file>Copenhagen_Y.png</file>
        <file>Copenhagen_K.png</file>
      </in_preview>
      <out_preview>
        <file>Copenhagen_CMYK_Combined.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="LargeImages/ChannelManipulations/CombineChannels.cs">
    <title>Combine Channels</title>
    <description>Merges separate image channels into a single RGB image using Pipeline API.</description>
    <instruction>Combine separate RGB channels from three images (red, green, and blue) to create a full-color image using Pipeline API.</instruction>
    <output><![CDATA[The code:

- Reads three images: "Chicago_R.png", "Chicago_G.png", and "Chicago_B.png" (representing the red, green, and blue channels).
- Combines these channels into a single full-color image using Pipeline API.
- Saves the result as "PipelineCombineChannels.jpg".]]></output>
    <tags>
      <tag id="branched-pipeline" title="Branched Pipeline" description="Building branched processing pipelines" />
      <tag id="channels" title="Channels" description="Reading and combining image channels" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var writer = ImageWriter.Create("PipelineCombineChannels.jpg"))
using (var combiner = new RgbChannelCombiner())
using (var readerR = new PngReader("Chicago_R.png"))
using (var readerG = new PngReader("Chicago_G.png"))
using (var readerB = new PngReader("Chicago_B.png"))
{
    combiner.R = readerR;
    combiner.G = readerG;
    combiner.B = readerB;
    Pipeline.Run(combiner + writer);
}]]></code>
    <io>
      <in_preview>
        <file>Chicago_R.png</file>
        <file>Chicago_G.png</file>
        <file>Chicago_B.png</file>
      </in_preview>
      <out_preview>
        <file>PipelineCombineChannels.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/WebP/CompareImageFormatCompressions.cs">
    <title>Compare Image Format Compressions</title>
    <description>Compares compression of WebP, JPEG and PNG image formats.</description>
    <instruction>Compares compression efficiency between WebP, JPEG, and PNG image formats.</instruction>
    <output><![CDATA[The following code:

- Reads an input JPEG image.
- Converts and saves it in three formats: WebP (90% quality), JPEG (90% quality), and PNG.
- Uses `Pipeline.Run()` for memory-friendly format conversion.
- Measures the size of each output file in bytes and prints the results to the console.]]></output>
    <tags>
      <tag id="webp" title="WEBP" description="Reading and writing WebP images" />
      <tag id="jpg" title="JPG" description="Reading and writing JPEG images" />
      <tag id="png" title="PNG" description="Reading and writing PNG images" />
      <tag id="format-conversion" title="Format Conversion" description="Converting images between formats" />
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
      <tag id="compression" title="Compression" description="Tuning image compression settings" />
    </tags>
    <usings><![CDATA[using System;
using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var reader = new JpegReader("Chicago.jpg"))
using (var writerWebP = new WebPWriter("CompareImageFormatCompressions.webp"))
using (var writerJpeg = new JpegWriter("CompareImageFormatCompressions.jpg"))
using (var writerPng = new PngWriter("CompareImageFormatCompressions.png"))
{
    writerWebP.Quality = 90f;
    writerJpeg.Quality = 90;

    Pipeline.Run(reader + writerWebP);
    Pipeline.Run(reader + writerJpeg);
    Pipeline.Run(reader + writerPng);
}

var webpFile = new System.IO.FileInfo("CompareImageFormatCompressions.webp");
var jpegFile = new System.IO.FileInfo("CompareImageFormatCompressions.jpg");
var pngFile = new System.IO.FileInfo("CompareImageFormatCompressions.png");

Console.WriteLine("WebP: {0} KB", webpFile.Length / 1024);
Console.WriteLine("JPEG: {0} KB", jpegFile.Length / 1024);
Console.WriteLine("PNG: {0} KB", pngFile.Length / 1024);]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>CompareImageFormatCompressions.txt</file>
        <file>CompareImageFormatCompressions.webp</file>
        <file>CompareImageFormatCompressions.jpg</file>
        <file>CompareImageFormatCompressions.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="LargeImages/PipelineAPISyntax/ConditionalElements.cs">
    <title>Conditionally adding pipeline elements</title>
    <description>This sample demonstrates how to conditionally add elements to a pipeline based on the properties of the input image.
It shows how to create thumbnails in the sRGB color space with a specified DPI value.&lt;br/&gt;&lt;br/&gt;
You can read more information about pipelines in the &lt;a href="https://www.graphicsmill.com/docs/gm/processing-large-images-using-pipelines.htm"&gt;documentation&lt;/a&gt;.</description>
    <instruction>Create thumbnail from the "Venice.jpg" image, converting to sRGB color space if necessary. Set the DPI to 72. Save result to "thumbnail_in_srgb.jpg".</instruction>
    <output><![CDATA[The code:

- Reads the image.
- Creates an empty pipeline.
- Adds ImageReader as the first element.
- Adds a resize transform.
- Conditionally adds a color converter if the image is not in sRGB color space.
- Conditionally adds a resolution modifier if the DPI is not 72.
- Adds ImageWriter as the last element.
- Runs the pipeline and disposes all elements.]]></output>
    <tags>
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
      <tag id="resize" title="Resize" description="Resizing images" />
      <tag id="advanced" title="Advanced" description="Demonstrating advanced usage scenarios" />
      <tag id="thumbnail" title="Thumbnail" description="Generating thumbnails from images" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[// Create an empty pipeline.
var pipeline = new Pipeline();

// Add a reader as the first element.
var reader = ImageReader.Create("Venice.jpg");
pipeline.Add(reader);

// Add a resize transform.
pipeline.Add(new Resize(320, 0, ResizeInterpolationMode.High));

// Assume that we want thumbnails only in RGB format.
// The order here affects performance because a color converter placed after the down-resizer has less data to process.
if (reader.PixelFormat != PixelFormat.Format24bppRgb)
{
    var colorConverter = new ColorConverter(PixelFormat.Format24bppRgb)
    {
        DestinationProfile = ColorProfile.FromSrgb(),
    };

    pipeline.Add(colorConverter);
}

// We also want the DPI to be equal to 72.
if (reader.DpiX != 72 || reader.DpiY != 72)
{
    pipeline.Add(new ResolutionModifier(72, 72));
}

// Add the JPEG writer.
pipeline.Add(ImageWriter.Create("thumbnail_in_srgb.jpg"));

try
{
    // Run the pipeline.
    pipeline.Run();
}
finally
{
    // Dispose all elements in the pipeline.
    pipeline.DisposeAllElements();
}]]></code>
    <io>
      <in_preview>
        <file>Venice.jpg</file>
      </in_preview>
      <out_preview>
        <file>thumbnail_in_srgb.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Transforms/BrightnessAndContrast/Contrast.cs">
    <title>Contrast</title>
    <description>Adjusts contrast.</description>
    <instruction>Apply a contrast adjustment to an image.</instruction>
    <output><![CDATA[The code:

- Adjusts the contrast of the image by `0.1f` using the `Contrast` transform.
- The transformation is applied directly to the image.
- Saves the image with the applied contrast adjustment.]]></output>
    <tags>
      <tag id="color-adjustment" title="Color Adjustment" description="Adjusting brightness, contrast and color" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Chicago.jpg"))
{
    bitmap.ColorAdjustment.Contrast(0.1f);

    bitmap.Save("Contrast.jpg");
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>Contrast.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/Jpeg/ConvertAndWriteJpeg.cs">
    <title>Convert And Write JPEG</title>
    <description>Converts to PixelFormat.Format24bppRgb to and saves to JPEG format.</description>
    <instruction>Load an image and convert it to 24bpp RGB pixel format if it is not already in that format. Then, save it as a JPEG file. Use an appropriate image processing library that supports color management.</instruction>
    <output><![CDATA[Here is a C# program that checks the pixel format of an image and converts it to 24bpp RGB before saving it as a JPEG:

This code loads the `Stamp.png` image, ensures it is in the `PixelFormat.Format24bppRgb` format (which is required for saving as a standard JPEG), and saves the result as `ConvertAndWriteJpeg.jpg`.]]></output>
    <tags>
      <tag id="jpg" title="JPG" description="Reading and writing JPEG images" />
      <tag id="read" title="Read" description="Reading images with codecs" />
      <tag id="write" title="Write" description="Writing images with codecs" />
      <tag id="color-conversion" title="Color Conversion" description="Converting colors between color spaces" />
      <tag id="filesystem" title="Filesystem" description="Loading and saving images from files" />
    </tags>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Stamp.png"))
{
    // JPEG format supports PixelFormat.Format32bppCmyk and PixelFormat.Format8bppGrayscale
    // for CMYK and grayscale images accordingly
    if (bitmap.PixelFormat != PixelFormat.Format24bppRgb)
    {
        bitmap.ColorManagement.Convert(PixelFormat.Format24bppRgb);
    }

    bitmap.Save("ConvertAndWriteJpeg.jpg");
}]]></code>
    <io>
      <in_preview>
        <file>Stamp.png</file>
      </in_preview>
      <out_preview>
        <file>ConvertAndWriteJpeg.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/WebP/ConvertAnimatedGifImageToWebP.cs">
    <title>Convert Animated GIF Image To WebP</title>
    <description>Converts animated GIF image to WebP format.</description>
    <instruction>Converts an animated GIF image to WebP format, preserving frame delay and positioning.</instruction>
    <output><![CDATA[The following code:

- Opens an animated GIF file.
- Iterates through each frame of the GIF.
- Sets WebP frame options including delay (converted from hundredths to milliseconds), disposal method, and frame position.
- Converts each frame to 24bpp RGB format.
- Saves the frames to a WebP animation using `Pipeline.Run()` for memory-efficient processing.]]></output>
    <tags>
      <tag id="webp" title="WEBP" description="Reading and writing WebP images" />
      <tag id="gif" title="GIF" description="Reading, writing and animating GIFs" />
      <tag id="format-conversion" title="Format Conversion" description="Converting images between formats" />
      <tag id="multi-frame" title="Multiple frames" description="Handling multi-frame image formats" />
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var gifReader = new GifReader("Sheep.gif"))
using (var writer = new WebPWriter("ConvertAnimatedGifImageToWebP.webp"))
{
    for (int i = 0; i < gifReader.Frames.Count; ++i)
    {
        writer.FrameOptions.Delay = gifReader.Frames[i].Delay * 10;

        var disposalMethod = gifReader.Frames[i].DisposalMethod;
        if (disposalMethod == DisposalMethod.None || disposalMethod == DisposalMethod.Background)
        {
            writer.FrameOptions.DisposalMethod = gifReader.Frames[i].DisposalMethod;
        }

        writer.FrameOptions.Left = gifReader.Frames[i].Left;
        writer.FrameOptions.Top = gifReader.Frames[i].Top;

        var bitmap = gifReader.Frames[i].GetBitmap();
        bitmap.ColorManagement.Convert(PixelFormat.Format24bppRgb);

        Pipeline.Run(bitmap + writer);
    }
}]]></code>
    <io>
      <in_preview>
        <file>Sheep.gif</file>
      </in_preview>
      <out_preview>
        <file>ConvertAnimatedGifImageToWebP.webp</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Metadata/ClippingPath/ConvertClippingPathToMask.cs">
    <title>Convert Clipping Path To Mask</title>
    <description>Converts clipping path to alpha channel mask.</description>
    <instruction>Convert a clipping path from an image into an alpha mask and save the result.</instruction>
    <output><![CDATA[The code:

- Reads a JPEG image and extracts its first frame.
- Creates an empty mask bitmap with a grayscale format.
- Uses the clipping path from the image to fill the mask bitmap with white color where the path exists.
- Sets the mask bitmap as the alpha channel of the original image.
- Saves the resulting image with the applied mask as a PNG file.]]></output>
    <tags>
      <tag id="metadata" title="Metadata" description="Reading and writing image metadata" />
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="channels" title="Channels" description="Reading and combining image channels" />
      <tag id="clipping-paths" title="Clipping Paths" description="Reading and writing Adobe resources clipping path" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;
using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var reader = new JpegReader("Apple.jpg"))
using (var bitmap = reader.Frames[0].GetBitmap())
using (var maskBitmap = new Bitmap(bitmap.Width, bitmap.Height, PixelFormat.Format8bppGrayscale, new GrayscaleColor(0)))
using (var graphics = maskBitmap.GetAdvancedGraphics())
{
    var graphicsPath = reader.ClippingPaths[0].CreateGraphicsPath(reader.Width, reader.Height);

    graphics.FillPath(new SolidBrush(new GrayscaleColor(255)), Path.Create(graphicsPath));

    bitmap.Channels.SetAlpha(maskBitmap);

    bitmap.Save("ConvertClippingPathToMask.png");
}]]></code>
    <io>
      <in_preview>
        <file>Apple.jpg</file>
      </in_preview>
      <out_preview>
        <file>ConvertClippingPathToMask.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/Tga/ConvertClippingPathToTga.cs">
    <title>Convert Clipping Path To TGA</title>
    <description>Reads image in JPEG format, converts clipping path to alpha channel and saves to TARGA 32 format.</description>
    <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.</instruction>
    <output><![CDATA[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.]]></output>
    <tags>
      <tag id="tga" title="TGA" description="Reading and writing TGA images" />
      <tag id="clipping-paths" title="Clipping Paths" description="Reading and writing Adobe resources clipping path" />
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;
using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[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);
    }
}]]></code>
    <io>
      <in_preview>
        <file>Apple.jpg</file>
      </in_preview>
      <out_download>
        <file>ConvertClippingPathToTga.tga</file>
      </out_download>
    </io>
  </sample>
  <sample path="ColorManagement/ConvertingPixelFormats/ConvertCmykToRgb.cs">
    <title>Convert CMYK to RGB</title>
    <description>Converts color space from CMYK to RGB with color management.</description>
    <instruction>Converts a CMYK image without a color profile to RGB using a default color profile and saves the result.</instruction>
    <output><![CDATA[The code:

- Loads the CMYK image ("Copenhagen_CMYK_NoColorProfile.jpg") into a `Bitmap`.
- If the image does not have a color profile, assigns a default color profile ("ISOcoated_v2_eci.icc").
- Sets the destination color profile to `sRGB` using `ColorProfile.FromSrgb()`.
- Converts the image from CMYK to RGB using `ColorManagement.Convert`.
- Saves the result as "PF_ConvertCmykToRgb.jpg" using the `Save` method with the new RGB format.]]></output>
    <tags>
      <tag id="color-management" title="Color Management" description="Color management with ICC profiles" />
      <tag id="color-conversion" title="Color Conversion" description="Converting colors between color spaces" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Copenhagen_CMYK_NoColorProfile.jpg"))
{
    // Assign some default color profile
    if (bitmap.ColorProfile == null)
    {
        bitmap.ColorProfile = new ColorProfile("ISOcoated_v2_eci.icc");
    }

    bitmap.ColorManagement.DestinationProfile = ColorProfile.FromSrgb();

    bitmap.ColorManagement.Convert(PixelFormat.Format24bppRgb);

    bitmap.Save("PF_ConvertCmykToRgb.jpg");
}]]></code>
    <io>
      <in_preview>
        <file>Copenhagen_CMYK_NoColorProfile.jpg</file>
      </in_preview>
      <in_download>
        <file>ISOcoated_v2_eci.icc</file>
      </in_download>
      <out_preview>
        <file>PF_ConvertCmykToRgb.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="ColorManagement/ColorManagementEngines/ConvertColorsLittleCms.cs">
    <title>Convert colors using LittleCMS</title>
    <description>Uses LittleCMS to convert the image's color space.</description>
    <instruction>Converts a CMYK image to RGB format using LittleCMS color management engine (default) and saves the result.</instruction>
    <output><![CDATA[The following code:

- Reads the CMYK image (`Copenhagen_CMYK.jpg`) using `Bitmap`.
- Sets the destination color profile to `sRGB` using `ColorProfile.FromSrgb()`.
- Converts the image to RGB format with color management applied through LittleCMS (default engine).
- Saves the resulting image as `ConvertColorsLittleCms.jpg` after the conversion.]]></output>
    <tags>
      <tag id="color-conversion" title="Color Conversion" description="Converting colors between color spaces" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Copenhagen_CMYK.jpg"))
{
    // LittleCMS is a default color management engine, so no need to specify it
    // bitmap.ColorManagement.ColorManagementEngine = ColorManagementEngine.LittleCms;
    bitmap.ColorManagement.DestinationProfile = ColorProfile.FromSrgb();
    bitmap.ColorManagement.Convert(PixelFormat.Format24bppRgb);
    bitmap.Save("ConvertColorsLittleCms.jpg");
}]]></code>
    <io>
      <in_preview>
        <file>Copenhagen_CMYK.jpg</file>
      </in_preview>
      <out_preview>
        <file>ConvertColorsLittleCms.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Interoperability/WPFInteroperability/ConvertFromWPF.cs">
    <title>Convert From WPF</title>
    <description>Converts WPF BitmapFrame to GraphicsMill Bitmap.</description>
    <instruction>Write a C# program that converts WPF BitmapFrame loaded from "Chicago.jpg" using BitmapFrame.Create with PreservePixelFormat to GraphicsMill Bitmap via custom extension method ToAurigmaBitmap, which creates matching PixelFormat bitmap, copies pixels directly using CopyPixels to Scan0 with stride handling, sets DPI from WPF source, and saves as TIFF "ChicagoSavedGotFromWPF.tif" while supporting BGR24/RGB24, BGR32/RGB32, BGRA32/ARGB32, and Grayscale8/16 format mappings via bidirectional dictionary conversion.</instruction>
    <output><![CDATA[Below is a C# code sample that demonstrates WPF BitmapFrame to GraphicsMill Bitmap conversion with direct pixel copying:

The code implements bidirectional extension methods for WPF-GraphicsMill interoperability using direct pixel memory copying via CopyPixels/Scan0 without format conversion overhead. It maps WPF PixelFormats (Bgr24→Format24bppRgb, Bgra32→Format32bppArgb, Gray8→Format8bppGrayscale) through dictionary lookups with UnsupportedPixelFormatException for incompatible formats, preserves DPI metadata, and uses BitmapCreateOptions.PreservePixelFormat with BitmapCacheOption.OnLoad for WPF-side format fidelity. This zero-copy approach enables WPF UI integration with GraphicsMill processing pipelines while maintaining pixel data integrity and performance.]]></output>
    <tags>
      <tag id="interoperability" title="Interoperability" description="Interop with GDI+ and other libraries" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
      <tag id="wpf" title="WPF" description="Interoperability and conversion with WPF images" />
    </tags>
    <usings><![CDATA[using System.Collections.Generic;
using System.IO;
using System.Windows.Media.Imaging;]]></usings>
    <code language="csharp"><![CDATA[public static class Extensions
{
    /// <summary>
    /// An extension to convert Graphics Mill Bitmap to WPF BitmapSource
    /// </summary>
    public static BitmapSource ToBitmapSource(this Bitmap bitmap)
    {
        return BitmapFrame.Create(
            bitmap.Width,
            bitmap.Height,
            bitmap.DpiX,
            bitmap.DpiY,
            ConvertFormat(bitmap.PixelFormat),
            null,
            bitmap.Scan0,
            bitmap.Stride * bitmap.Height,
            bitmap.Stride);
    }

    /// <summary>
    /// An extension to convert WPF BitmapFrame to Graphics Mill Bitmap
    /// </summary>
    public static Bitmap ToAurigmaBitmap(this BitmapFrame bitmapFrame)
    {
        var bitmap = new Bitmap(bitmapFrame.PixelWidth, bitmapFrame.PixelHeight, ConvertFormat(bitmapFrame.Format));

        bitmap.DpiX = (float)bitmapFrame.DpiX;
        bitmap.DpiY = (float)bitmapFrame.DpiY;

        bitmapFrame.CopyPixels(new System.Windows.Int32Rect(0, 0, bitmapFrame.PixelWidth, bitmapFrame.PixelHeight), bitmap.Scan0, bitmap.Stride * bitmap.Height, bitmap.Stride);

        return bitmap;
    }

    /// <summary>
    /// Converts WPF pixel format to corresponding one for Graphics Mill.
    /// </summary>
    private static PixelFormat ConvertFormat(System.Windows.Media.PixelFormat format)
    {
        var dict = new Dictionary<System.Windows.Media.PixelFormat, Aurigma.GraphicsMill.PixelFormat>
        {
            { System.Windows.Media.PixelFormats.Bgr24, Aurigma.GraphicsMill.PixelFormat.Format24bppRgb },
            { System.Windows.Media.PixelFormats.Bgr32, Aurigma.GraphicsMill.PixelFormat.Format32bppRgb },
            { System.Windows.Media.PixelFormats.Bgra32, Aurigma.GraphicsMill.PixelFormat.Format32bppArgb },
            { System.Windows.Media.PixelFormats.Gray8, Aurigma.GraphicsMill.PixelFormat.Format8bppGrayscale },
            { System.Windows.Media.PixelFormats.Gray16, Aurigma.GraphicsMill.PixelFormat.Format16bppGrayscale },
        };

        if (!dict.ContainsKey(format))
        {
            throw new Aurigma.GraphicsMill.UnsupportedPixelFormatException();
        }

        return dict[format];
    }

    /// <summary>
    /// Converts Graphics Mill pixel format to corresponding one for WPF.
    /// </summary>
    private static System.Windows.Media.PixelFormat ConvertFormat(Aurigma.GraphicsMill.PixelFormat format)
    {
        var dict = new Dictionary<Aurigma.GraphicsMill.PixelFormat, System.Windows.Media.PixelFormat>
    {
        { Aurigma.GraphicsMill.PixelFormat.Format24bppRgb, System.Windows.Media.PixelFormats.Bgr24 },
        { Aurigma.GraphicsMill.PixelFormat.Format32bppRgb, System.Windows.Media.PixelFormats.Bgr32 },
        { Aurigma.GraphicsMill.PixelFormat.Format32bppArgb, System.Windows.Media.PixelFormats.Bgra32 },
        { Aurigma.GraphicsMill.PixelFormat.Format8bppGrayscale, System.Windows.Media.PixelFormats.Gray8 },
        { Aurigma.GraphicsMill.PixelFormat.Format16bppGrayscale, System.Windows.Media.PixelFormats.Gray16 },
    };

        if (!dict.ContainsKey(format))
        {
            throw new Aurigma.GraphicsMill.UnsupportedPixelFormatException();
        }

        return dict[format];
    }
}

public class ConvertFromWpf
{
    public static void Run()
    {
        using (var fs = new FileStream("Chicago.jpg", FileMode.Open, FileAccess.Read, FileShare.Read))
        {
            /*
             There are not too many formats that can be converted with direct pixel copying.
             According to Microsoft documentation, with BitmapCreateOptions.None the PixelFormat
             of the image is chosen by the system depending on what the system determines will yield the best performance.
            */
            var bitmapFrame = BitmapFrame.Create(fs, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.OnLoad);

            using (var bitmap = bitmapFrame.ToAurigmaBitmap())
            {
                bitmap.Save("ChicagoSavedGotFromWPF.tif");
            }
        }
    }
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_download>
        <file>ChicagoSavedGotFromWPF.tif</file>
      </out_download>
    </io>
  </sample>
  <sample path="ColorManagement/ConvertingPixelFormats/ConvertToIndexed.cs">
    <title>Convert To Indexed</title>
    <description>Converts to indexed pixel format (optimized for Web).</description>
    <instruction>Converts an RGB image to an 8-bit indexed color format using dithering and custom color palette.</instruction>
    <output><![CDATA[The code:

- Loads the "Copenhagen_RGB.jpg" image using the `Bitmap` class.
- Applies Floyd-Steinberg dithering (`DitheringType.FloydSteinberg`) and generates a custom 64-color palette (`ColorPalette.Create`).
- Converts the image to an 8-bit indexed format (`PixelFormat.Format8bppIndexed`) using color management.
- Saves the converted image as a PNG file ("PF_ConvertToIndexed.png") using the `Save` method.]]></output>
    <tags>
      <tag id="color-conversion" title="Color Conversion" description="Converting colors between color spaces" />
      <tag id="indexed" title="Indexed format" description="Working with indexed-color images" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Copenhagen_RGB.jpg"))
{
    bitmap.ColorManagement.Dithering = DitheringType.FloydSteinberg;
    bitmap.ColorManagement.Palette = ColorPalette.Create(bitmap, 64);
    bitmap.ColorManagement.Convert(PixelFormat.Format8bppIndexed);

    bitmap.Save("PF_ConvertToIndexed.png");
}]]></code>
    <io>
      <in_preview>
        <file>Copenhagen_RGB.jpg</file>
      </in_preview>
      <out_preview>
        <file>PF_ConvertToIndexed.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Interoperability/WPFInteroperability/ConvertToWPF.cs">
    <title>Convert To WPF</title>
    <description>Converts Graphics Mill Bitmap to WPF BitmapSource.</description>
    <instruction>Write a C# program that converts GraphicsMill Bitmap loaded from "Chicago.jpg" to WPF BitmapSource using extension method ToBitmapSource which creates BitmapFrame with direct Scan0 access, matching WPF PixelFormat via conversion dictionary, and DPI preservation, then encodes to TIFF using TiffBitmapEncoder with Zip compression, adding the BitmapSource as a frame and saving to "ChicagoSavedWithWPF.tif" via FileStream.</instruction>
    <output><![CDATA[Below is a C# code sample that demonstrates GraphicsMill Bitmap to WPF BitmapSource conversion for encoding:

The code implements GraphicsMill to WPF pipeline using BitmapFrame.Create with direct Scan0 memory access for zero-copy pixel transfer, mapping GraphicsMill PixelFormats to WPF equivalents (Format24bppRgb→Bgr24, Format32bppArgb→Bgra32) via bidirectional dictionaries, and preserves DPI metadata. The WPF-side TiffBitmapEncoder with Zip compression enables GraphicsMill processing results to be saved in WPF-supported formats while maintaining pixel fidelity through direct memory access, supporting hybrid WPF/GraphicsMill workflows with TIFF output for archival or further WPF processing.]]></output>
    <tags>
      <tag id="interoperability" title="Interoperability" description="Interop with GDI+ and other libraries" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
      <tag id="wpf" title="WPF" description="Interoperability and conversion with WPF images" />
    </tags>
    <usings><![CDATA[using System.Collections.Generic;
using System.IO;
using System.Windows.Media.Imaging;]]></usings>
    <code language="csharp"><![CDATA[public static class Extensions
{
    /// <summary>
    /// An extension to convert Graphics Mill Bitmap to WPF BitmapSource
    /// </summary>
    public static BitmapSource ToBitmapSource(this Bitmap bitmap)
    {
        return BitmapFrame.Create(
            bitmap.Width,
            bitmap.Height,
            bitmap.DpiX,
            bitmap.DpiY,
            ConvertFormat(bitmap.PixelFormat),
            null,
            bitmap.Scan0,
            bitmap.Stride * bitmap.Height,
            bitmap.Stride);
    }

    /// <summary>
    /// An extension to convert WPF BitmapFrame to Graphics Mill Bitmap
    /// </summary>
    public static Bitmap ToAurigmaBitmap(this BitmapFrame bitmapFrame)
    {
        var bitmap = new Bitmap(bitmapFrame.PixelWidth, bitmapFrame.PixelHeight, ConvertFormat(bitmapFrame.Format));

        bitmap.DpiX = (float)bitmapFrame.DpiX;
        bitmap.DpiY = (float)bitmapFrame.DpiY;

        bitmapFrame.CopyPixels(new System.Windows.Int32Rect(0, 0, bitmapFrame.PixelWidth, bitmapFrame.PixelHeight), bitmap.Scan0, bitmap.Stride * bitmap.Height, bitmap.Stride);

        return bitmap;
    }

    /// <summary>
    /// Converts WPF pixel format to corresponding one for Graphics Mill.
    /// </summary>
    private static PixelFormat ConvertFormat(System.Windows.Media.PixelFormat format)
    {
        var dict = new Dictionary<System.Windows.Media.PixelFormat, Aurigma.GraphicsMill.PixelFormat>
        {
            { System.Windows.Media.PixelFormats.Bgr24, Aurigma.GraphicsMill.PixelFormat.Format24bppRgb },
            { System.Windows.Media.PixelFormats.Bgr32, Aurigma.GraphicsMill.PixelFormat.Format32bppRgb },
            { System.Windows.Media.PixelFormats.Bgra32, Aurigma.GraphicsMill.PixelFormat.Format32bppArgb },
            { System.Windows.Media.PixelFormats.Gray8, Aurigma.GraphicsMill.PixelFormat.Format8bppGrayscale },
            { System.Windows.Media.PixelFormats.Gray16, Aurigma.GraphicsMill.PixelFormat.Format16bppGrayscale },
        };

        if (!dict.ContainsKey(format))
        {
            throw new Aurigma.GraphicsMill.UnsupportedPixelFormatException();
        }

        return dict[format];
    }

    /// <summary>
    /// Converts Graphics Mill pixel format to corresponding one for WPF.
    /// </summary>
    private static System.Windows.Media.PixelFormat ConvertFormat(Aurigma.GraphicsMill.PixelFormat format)
    {
        var dict = new Dictionary<Aurigma.GraphicsMill.PixelFormat, System.Windows.Media.PixelFormat>
        {
            { Aurigma.GraphicsMill.PixelFormat.Format24bppRgb, System.Windows.Media.PixelFormats.Bgr24 },
            { Aurigma.GraphicsMill.PixelFormat.Format32bppRgb, System.Windows.Media.PixelFormats.Bgr32 },
            { Aurigma.GraphicsMill.PixelFormat.Format32bppArgb, System.Windows.Media.PixelFormats.Bgra32 },
            { Aurigma.GraphicsMill.PixelFormat.Format8bppGrayscale, System.Windows.Media.PixelFormats.Gray8 },
            { Aurigma.GraphicsMill.PixelFormat.Format16bppGrayscale, System.Windows.Media.PixelFormats.Gray16 },
        };

        if (!dict.ContainsKey(format))
        {
            throw new Aurigma.GraphicsMill.UnsupportedPixelFormatException();
        }

        return dict[format];
    }
}

public class ConvertToWpf
{
    public static void Run()
    {
        using (var bitmap = new Bitmap("Chicago.jpg"))
        {
            var bitmapSource = bitmap.ToBitmapSource();

            var encoder = new TiffBitmapEncoder();
            encoder.Compression = TiffCompressOption.Zip;
            encoder.Frames.Add(BitmapFrame.Create(bitmapSource));

            using (var fs = new FileStream("ChicagoSavedWithWPF.tif", FileMode.Create, FileAccess.ReadWrite, FileShare.Write))
            {
                encoder.Save(fs);
            }
        }
    }
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_download>
        <file>ChicagoSavedWithWPF.tif</file>
      </out_download>
    </io>
  </sample>
  <sample path="Metadata/ClippingPath/CopyClippingPath.cs">
    <title>Copy Clipping Path</title>
    <description>Copies all Adobe resources including clipping path.</description>
    <instruction>Copy the Adobe resources (including clipping paths) from one JPEG image and save it as a new JPEG.</instruction>
    <output><![CDATA[The code:

- Reads a JPEG image and extracts its first frame.
- Creates a `JpegSettings` object and assigns the Adobe resources (including clipping paths) from the original image.
- Saves the image with the same Adobe resources to a new JPEG file.]]></output>
    <tags>
      <tag id="adobe-resources" title="Adobe Resources" description="Working with Adobe image resource blocks" />
      <tag id="read" title="Read" description="Reading images with codecs" />
      <tag id="write" title="Write" description="Writing images with codecs" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var reader = new JpegReader("Apple.jpg"))
using (var bitmap = reader.Frames[0].GetBitmap())
{
    var jpegSettings = new JpegSettings();
    jpegSettings.AdobeResources = reader.AdobeResources;

    bitmap.Save("CopyClippingPath.jpg", jpegSettings);
}]]></code>
    <io>
      <in_preview>
        <file>Apple.jpg</file>
      </in_preview>
      <out_preview>
        <file>CopyClippingPath.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Metadata/ClippingPath/CopyClippingPathMemoryFriendly.cs">
    <title>Copy Clipping Path (Memory Friendly)</title>
    <description>Copies clipping path using memory-friendly Pipeline API.</description>
    <instruction>Copy specific Adobe resources (clipping paths) from a JPEG image and save it as a new JPEG using memory-friendly processing.</instruction>
    <output><![CDATA[The code:

- Reads a JPEG image and checks for Adobe resources (clipping paths).
- Copies the specified clipping path resources (from `FirstPathId` to `LastPathId`) to a new `AdobeResourceDictionary`.
- Saves the image with the copied Adobe resources to a new JPEG file using memory-friendly pipeline processing.]]></output>
    <tags>
      <tag id="adobe-resources" title="Adobe Resources" description="Working with Adobe image resource blocks" />
      <tag id="read" title="Read" description="Reading images with codecs" />
      <tag id="write" title="Write" description="Writing images with codecs" />
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[// 2000-2997 Clipping path information
// http://www.adobe.com/devnet-apps/photoshop/fileformatashtml/
const int FirstPathId = 2000;
const int LastPathId = 2997;

using (var reader = new JpegReader("Apple.jpg"))
using (var writer = new JpegWriter("CopyClippingPathMemoryFriendly.jpg"))
{
    if (reader.AdobeResources != null)
    {
        var adobeResources = new AdobeResourceDictionary();

        for (int i = FirstPathId; i <= LastPathId; i++)
        {
            if (reader.AdobeResources.Contains(i))
            {
                adobeResources[i] = reader.AdobeResources[i];
            }
        }

        writer.AdobeResources = adobeResources;
    }

    Pipeline.Run(reader + writer);
}]]></code>
    <io>
      <in_preview>
        <file>Apple.jpg</file>
      </in_preview>
      <out_preview>
        <file>CopyClippingPathMemoryFriendly.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/Pdf/CreateX4.cs">
    <title>Create a PDF/X-4 file with CMYK output intent</title>
    <description>This sample shows how to create a PDF/X-4 document with a CMYK output intent using GraphicsMill.
It demonstrates how to load a CMYK print profile, configure an &lt;c&gt;OutputIntent&lt;/c&gt;, initialize a
&lt;c&gt;PdfWriter&lt;/c&gt; with that intent, convert an RGB image to CMYK using color management, and draw it
onto a PDF page together with a solid CMYK-filled shape.</description>
    <instruction>Use the PDF API to create a PDF/X-4 file that targets a specific CMYK print profile:
load the output ICC profile, configure the PDF output intent, create a CMYK page background,
color-manage an input RGB image into CMYK, and draw both the image and a CMYK rectangle onto the page.</instruction>
    <output><![CDATA[The code:

- Loads the CMYK print profile from the file "ISOcoated_v2_eci.icc" into a <c>ColorProfile</c>.
- Creates an <c>OutputIntent</c> object and assigns the profile and metadata such as
<c>OutputConditionId</c>, <c>Info</c>, <c>OutputCondition</c>, and <c>Registry</c>.
- Initializes a <c>PdfWriter</c> with the output intent to produce a PDF/X-4-compatible file "x4_out.pdf".
- Gets a drawing <c>Graphics</c> object from the writer and loads the source image "Apple.jpg"
into a <c>Bitmap</c>.
- Adds a 500x500 page and sets its background to red converted to CMYK using <c>RgbColor.Red.Convert</c>.
- Draws a 100x100 CMYK rectangle in the bottom-right area of the page using <c>FillRectangle</c>
and a <c>CmykColor</c> brush.
- Resizes the bitmap to fit within 400x400 pixels while preserving aspect ratio using the
<c>Resize</c> transform in <c>ResizeMode.Fit</c> with <c>ResizeInterpolationMode.Anisotropic9</c>.
- Sets the bitmap’s <c>DestinationProfile</c> to the same CMYK profile and converts it to
<c>PixelFormat.Format32bppCmyk</c> with color management.
- Clears the embedded color profile from the bitmap (<c>bitmap.ColorProfile = null</c>) so the
page relies on the output intent profile.
- Draws the CMYK bitmap onto the page at position (0, 0) using <c>Graphics.DrawImage</c>.
- Closes the writer, finalizing the PDF/X-4 document as "x4_out.pdf" and produces a CMYK-ready file
suitable for coated-offset printing workflows.]]></output>
    <tags>
      <tag id="pdf" title="PDF" description="Importing and exporting PDF documents" />
      <tag id="color-management" title="Color Management" description="Color management with ICC profiles" />
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="write" title="Write" description="Writing images with codecs" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;
using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[using (var profile = new ColorProfile("ISOcoated_v2_eci.icc"))
{
    // Create the output intent
    var intent = new OutputIntent()
    {
        Profile = profile,
        OutputConditionId = "ISOcoated_v2_eci",
        Info = "ISO Coated v2 (ECI) CMYK output profile for sheetfed offset printing on coated paper",
        OutputCondition = "Offset printing on coated paper (ISO 12647-2:2004 / Amd 1)",
        Registry = "http://www.eci.org",
    };

    // Create the PDF writer with the output intent
    using (var writer = new PdfWriter("x4_out.pdf", intent))
    using (var gr = writer.GetGraphics())
    using (var bitmap = new Bitmap("Apple.jpg"))
    {
        // Add a new page with a red background
        writer.AddPage(500, 500, RgbColor.Red.Convert(PixelFormat.Format32bppCmyk));

        gr.FillRectangle(new SolidBrush(new CmykColor(0, 0, 0, 255, 100)), 350, 350, 100, 100);

        // Prepare the image
        bitmap.Transforms.Resize(400, 400, ResizeInterpolationMode.Anisotropic9, ResizeMode.Fit);

        bitmap.ColorManagement.DestinationProfile = profile;
        bitmap.ColorManagement.Convert(PixelFormat.Format32bppCmyk);

        // Remove the color profile from the image
        bitmap.ColorProfile = null;

        // Draw the image
        gr.DrawImage(bitmap, 0, 0);

        writer.Close();
    }
}]]></code>
    <io>
      <in_preview>
        <file>Apple.jpg</file>
      </in_preview>
      <in_download>
        <file>ISOcoated_v2_eci.icc</file>
      </in_download>
      <out_preview>
        <file>x4_out.png</file>
      </out_preview>
      <out_download>
        <file>x4_out.pdf</file>
      </out_download>
    </io>
  </sample>
  <sample path="Codecs/Pdf/CreateBusinessCard.cs">
    <title>Create Business Card</title>
    <description>Creates business card in PDF format.</description>
    <instruction>Write a C# program that creates a business card layout in a PDF format.</instruction>
    <output><![CDATA[Below is a C# code sample that demonstrates how to create a business card in PDF format. The code draws the front and back sides with text and graphics, such as circles and rectangles, using `PdfWriter`:

This code generates a business card with personal information, contact details, and two pages representing the front and back sides.]]></output>
    <tags>
      <tag id="pdf" title="PDF" description="Importing and exporting PDF documents" />
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="text" title="Text" description="Rendering and formatting text" />
      <tag id="write" title="Write" description="Writing images with codecs" />
      <tag id="filesystem" title="Filesystem" description="Loading and saving images from files" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;
using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var writer = new PdfWriter("CreateBusinessCard.pdf"))
{
    int width = 350;
    int height = 200;

    using (var graphics = writer.GetGraphics())
    {
        // Front side
        writer.AddPage(width, height, RgbColor.White);

        var blueBrush = new SolidBrush(RgbColor.DeepSkyBlue);

        // Draw circle
        graphics.DrawEllipse(new Pen(RgbColor.DeepSkyBlue, 2f), 15f, 20f, 30f, 30f);

        // Draw text
        var font = graphics.CreateFont("Arial", 18f);
        var text = new PlainText("Front side", font, new SolidBrush(RgbColor.Gray), 95f, 41f, TextAlignment.Center);
        graphics.DrawText(text);

        font = graphics.CreateFont("Arial", 16f);
        text = new PlainText("<span>John Doe</span><br/><span style='color:gray;font-size:16pt'>General Manager</span>", font, blueBrush, 335f, 100f, TextAlignment.Right);

        graphics.DrawText(text);

        graphics.FillRectangle(blueBrush, 0, height - 50, width, 50);

        font = graphics.CreateFont("Arial", 12f);
        text = new PlainText(@"<span>123.456.7890</span><br/><span>info@website.com</span>", font, new SolidBrush(RgbColor.White), 15f, 170f, TextAlignment.Left);

        graphics.DrawText(text);

        text = new PlainText("<span>335 Cloverfield Blvd</span><br/><span>Charlington, NY 10123</span>", font, new SolidBrush(RgbColor.White), 200f, 170f, TextAlignment.Left);

        graphics.DrawText(text);

        // Back side
        writer.AddPage(width, height, RgbColor.DeepSkyBlue);

        graphics.DrawEllipse(new Pen(RgbColor.White, 3f), 65f, 72f, 55f, 55f);

        font = graphics.CreateFont("Arial", 36);

        text = new PlainText("Back side", font, new SolidBrush(RgbColor.White), 140f, 112f, TextAlignment.Left);
        graphics.DrawText(text);
    }
}]]></code>
    <io>
      <out_preview>
        <file>CreateBusinessCard.png</file>
      </out_preview>
      <out_download>
        <file>CreateBusinessCard.pdf</file>
      </out_download>
    </io>
  </sample>
  <sample path="Metadata/ClippingPath/CreatePath.cs">
    <title>Create Clipping Path</title>
    <description>Demonstrates how to create Adobe resource block with path from SVG file and save it to JPEG format.</description>
    <instruction>Demonstrates how to create an Adobe resource block with a path from an SVG file and save it to a JPEG format.</instruction>
    <output><![CDATA[The code:

- Reads an SVG file and extracts its content using `SvgReader`.
- Combines shapes from the SVG into a single path.
- Creates an Adobe resource block that includes the combined path information.
- Draws the path onto a bitmap.
- Saves the bitmap as a JPEG file while embedding the Adobe resource block containing the path.]]></output>
    <tags>
      <tag id="write" title="Write" description="Writing images with codecs" />
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="clipping-paths" title="Clipping Paths" description="Reading and writing Adobe resources clipping path" />
    </tags>
    <usings><![CDATA[using System;
using System.ComponentModel;
using System.Linq;
using Aurigma.GraphicsMill.AdvancedDrawing;
using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[// Internally a shape may be presented in many different ways, so we need to do this processing.
public static void CombineShapes(GraphicsContainer container, Path accumulatePath)
{
    foreach (var shapeItem in container.Items.OfType<ShapeItem>())
    {
        shapeItem.Path.ApplyTransform(shapeItem.Transform);
        accumulatePath.DrawPath(shapeItem.Path);
    }

    foreach (var containerItem in container.Items.OfType<ContainerItem>())
    {
        CombineShapes(containerItem.GraphicsContainer, accumulatePath);
    }
}

public static void Run()
{
    using (var reader = new SvgReader("cat.svg"))
    using (var gc = reader.GetContent())
    using (var bitmap = new Bitmap((int)gc.Width, (int)gc.Height, PixelFormat.Format24bppRgb, RgbColor.White))
    using (var gr = bitmap.GetAdvancedGraphics())
    using (var shape = new Path())
    {
        // Read a path from the SVG file
        CombineShapes(gc, shape);

        // https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/
        const int pathInfoKey = 0x07D0;

        // Create an adobe resource block with image and save to the dictionary.
        var ar = new AdobeResourceDictionary();
        var arb = AdobeResourceBlock.CreatePath(shape, bitmap.Width, bitmap.Height);

        ar.Add(pathInfoKey, new AdobeResourceBlock("Path name", arb));

        // Draw the path we got on the bitmap.
        gr.FillPath(new SolidBrush(RgbColor.Black), shape);

        // Save the output
        bitmap.Save("cat.jpg", new JpegSettings() { AdobeResources = ar });
    }
}]]></code>
    <io>
      <in_preview>
        <file>cat.svg</file>
      </in_preview>
      <out_preview>
        <file>cat.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="LargeImages/PipelineAPISyntax/SimplifiedSyntax.cs">
    <title>Create linear pipeline</title>
    <description>This sample demonstrates how to create a linear pipeline using simplified syntax. This is the most common use case, when all elements are known and their order is straightforward.&lt;br/&gt;&lt;br/&gt;
You can read more information about pipelines in the &lt;a href="https://www.graphicsmill.com/docs/gm/processing-large-images-using-pipelines.htm"&gt;documentation&lt;/a&gt;.</description>
    <instruction>Resize an image to a specified width while maintaining the aspect ratio and save the result using the Pipeline API of Graphics Mill library.</instruction>
    <output><![CDATA[The code:

- Reads the image.
- Resizes the image to a specified width, maintaining the original aspect ratio.
- Saves the resized image.]]></output>
    <tags>
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
      <tag id="resize" title="Resize" description="Resizing images" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[// reader --->  resize  --->  writer
using (var reader = ImageReader.Create("Venice.jpg"))
using (var resize = new Resize(320, 0, ResizeInterpolationMode.High))
using (var writer = ImageWriter.Create("SimplifiedSyntax.jpg"))
{
    // In most cases pipeline elements are used in a linear order,
    // so you can just chain them and run the pipeline
    (reader + resize + writer).Run();

    // Here is an alternative syntax for better readability
    Pipeline.Run(reader + resize + writer);
}]]></code>
    <io>
      <in_preview>
        <file>Venice.jpg</file>
      </in_preview>
      <out_preview>
        <file>SimplifiedSyntax.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/Pdf/CreateMultipagePDF.cs">
    <title>Create Multipage PDF</title>
    <description>Creates multipage PDF with personalized wedding invitations.</description>
    <instruction>Write a C# program that generates personalized wedding invitations by replacing placeholder text with names from a list and saves the output as a PDF.</instruction>
    <output><![CDATA[Below is a C# code sample that demonstrates how to create personalized wedding invitations using variable data in a PDF. The program reads a template, replaces a placeholder with a list of names, and saves the output as a new PDF:

This code generates multiple wedding invitation PDFs, each personalized with one name from the list. The names are centered and printed in a specified font and color.]]></output>
    <tags>
      <tag id="pdf" title="PDF" description="Importing and exporting PDF documents" />
      <tag id="vdp" title="VDP" description="Variable data printing scenarios" />
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="text" title="Text" description="Rendering and formatting text" />
      <tag id="write" title="Write" description="Writing images with codecs" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;
using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[// A list of variable data
var names = new[]
{
    "NICK",
    "MICHAEL",
    "JOHN",
};

using (var reader = new PdfReader("wedding-invitation-5x7in-vdp.pdf"))
using (var template = reader.Frames[0].GetContent())
using (var writer = new PdfWriter("wedding-invitation-5x7in-vdp_out.pdf"))
using (var gr = writer.GetGraphics())
using (var fr = new CustomFontRegistry())
{
    var psName = fr.Add("Montserrat-Medium.ttf");

    foreach (var name in names)
    {
        writer.AddPage(template.Width, template.Height, template.DpiX, template.DpiY);

        gr.FontRegistry = fr;

        // The content of this container will be written only with the first call. All further calls will reference the existing content.
        gr.DrawContainer(template, 0, 0);

        // Let's draw the text at the specified point.
        var text = new PlainText(name, gr.CreateFont(psName, 10))
        {
            Position = new System.Drawing.PointF(250, 105),
        };

        text.ParagraphStyle.Alignment = TextAlignment.Center;
        text.Brush = new SolidBrush(CmykColor.FromPercentages(0.43f, 0.418f, 0.483f, 0.279f, 1));

        gr.DrawText(text);
    }
}]]></code>
    <io>
      <in_download>
        <file>wedding-invitation-5x7in-vdp.pdf</file>
        <file>Montserrat-Medium.ttf</file>
      </in_download>
      <out_preview>
        <file>wedding-invitation-5x7in-vdp_out.png</file>
      </out_preview>
      <out_download>
        <file>wedding-invitation-5x7in-vdp_out.pdf</file>
      </out_download>
    </io>
  </sample>
  <sample path="LargeImages/Transforms/CreateVignette.cs">
    <title>Create Vignette</title>
    <description>Creates a vignette with a specified color.</description>
    <instruction>Write a C# program that creates a vignette effect on "Venice.jpg" by generating an elliptical grayscale mask with blurred edges using GraphicsContainer and Blur transform, then applies it to the original image via dual Pipeline processing with ScaleAlpha and RemoveAlpha transforms to produce "VeniceVignette.jpg" with white vignette borders.</instruction>
    <output><![CDATA[Below is a C# code sample that creates a professional vignette effect using advanced Pipeline techniques:

The code demonstrates sophisticated vignette creation using dual Pipeline approach: first pipeline generates blurred elliptical alpha mask via GraphicsContainer.FillEllipse with SolidBrush, ImageGenerator to 8bpp grayscale, and Blur transform; second pipeline composites original image with ScaleAlpha mask application followed by RemoveAlpha with white background. The technique uses borderScale (5%) for vignette sizing and blurRadiusScale for smooth edge feathering, with proper resource cleanup via DisposeAllElements in try-finally block, suitable for large images without full bitmap loading.]]></output>
    <tags>
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="channels" title="Channels" description="Reading and combining image channels" />
      <tag id="vignette" title="Vignette" description="Applying a vignette effect" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;
using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[const float borderScale = 0.05f;
const float blurRadiusScale = borderScale / 2.0f;

using (var reader = ImageReader.Create("Venice.jpg"))
using (var gc = new GraphicsContainer(reader.Width, reader.Height, reader.DpiX, reader.DpiY))
using (var gr = gc.GetGraphics())
{
    int offset = (int)(reader.Width * borderScale);

    gr.FillEllipse(new SolidBrush(RgbColor.White), offset, offset, gc.Width - (2 * offset), gc.Height - (2 * offset));

    // One pipeline for generating an alpha channel
    var alphaPipeline = new Pipeline();
    alphaPipeline.Add(new ImageGenerator(gc, PixelFormat.Format8bppGrayscale, RgbColor.Black));
    alphaPipeline.Add(new Blur(reader.Width * blurRadiusScale));

    // And another one for getting a final content
    var pipeline = new Pipeline();
    pipeline.Add(reader);
    pipeline.Add(new ScaleAlpha(alphaPipeline));
    pipeline.Add(new RemoveAlpha(RgbColor.White));
    pipeline.Add(ImageWriter.Create("VeniceVignette.jpg"));

    try
    {
        pipeline.Run();
    }
    finally
    {
        pipeline.DisposeAllElements();
        alphaPipeline.DisposeAllElements();
}]]></code>
    <io>
      <in_preview>
        <file>Venice.jpg</file>
      </in_preview>
      <out_preview>
        <file>VeniceVignette.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="LargeImages/Transforms/Crop.cs">
    <title>Crop</title>
    <description>Crops image using memory-friendly Pipeline API.</description>
    <instruction>Crop an image to a specified rectangular area and save the result.</instruction>
    <output><![CDATA[The code:

- Reads the image.
- Crops the image to a rectangle with the specified dimensions (200, 150, 360, 270).
- Saves the cropped image to the specified file.]]></output>
    <tags>
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
      <tag id="crop" title="Crop" description="Cropping images" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[using (var reader = ImageReader.Create("Chicago.jpg"))
using (var crop = new Crop(200, 150, 360, 270))
using (var writer = ImageWriter.Create("PipelineCrop1.jpg"))
{
    Pipeline.Run(reader + crop + writer);
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>PipelineCrop1.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Transforms/Crop/Crop.cs">
    <title>Crop</title>
    <description>Crops image.</description>
    <instruction>Crop an image to a specific rectangular region.</instruction>
    <output><![CDATA[The code:

- Reads the image file.
- Crops the image to the specified rectangle (230, 170, 320, 240).
- Saves the cropped image to a new file.]]></output>
    <tags>
      <tag id="crop" title="Crop" description="Cropping images" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Chicago.jpg"))
{
    bitmap.Transforms.Crop(230, 170, 320, 240);
    bitmap.Save("Crop.jpg");
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>Crop.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Metadata/ClippingPath/CropImageAndPreserveClippingPath.cs">
    <title>Crop Image And Preserve Clipping Path</title>
    <description>Crops image and preserves clipping path.</description>
    <instruction>Crop the image and preserve the clipping path while saving the result as a JPEG file.</instruction>
    <output><![CDATA[The code:

- Reads the "Apple.jpg" image file.
- Crops the image using specified coordinates while preserving its clipping path.
- Saves the cropped image as "CropImageAndPreserveClippingPath.jpg" while retaining the Adobe resources (including clipping path).]]></output>
    <tags>
      <tag id="adobe-resources" title="Adobe Resources" description="Working with Adobe image resource blocks" />
      <tag id="read" title="Read" description="Reading images with codecs" />
      <tag id="write" title="Write" description="Writing images with codecs" />
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
      <tag id="crop" title="Crop" description="Cropping images" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[using (var reader = new JpegReader("Apple.jpg"))
using (var writer = new JpegWriter("CropImageAndPreserveClippingPath.jpg"))
using (var crop = new Crop(reader.Width / 6, 0, reader.Width / 2, reader.Height / 2))
{
    writer.AdobeResources = reader.AdobeResources;

    Pipeline.Run(reader + crop + writer);
}]]></code>
    <io>
      <in_preview>
        <file>Apple.jpg</file>
      </in_preview>
      <out_preview>
        <file>CropImageAndPreserveClippingPath.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/Jpeg/CropJpegLosslessly.cs">
    <title>Crop Jpeg Losslessly</title>
    <description>Crops JPEG image losslessly.</description>
    <instruction>Write a C# program that performs a lossless crop on a JPEG image and saves the result as a new JPEG file. Use an image processing library that supports direct manipulation of JPEG data without recompression.</instruction>
    <output><![CDATA[Here is a C# program that losslessly crops a JPEG image and saves it to a new file:

This code uses the `LosslessJpeg` class to crop `Chicago.jpg` without recompression and writes the cropped area to `CropJpegLosslessly.jpg`. The operation preserves original JPEG quality.]]></output>
    <tags>
      <tag id="jpg" title="JPG" description="Reading and writing JPEG images" />
      <tag id="lossless" title="Lossless JPEG" description="Applying lossless JPEG operations" />
      <tag id="read" title="Read" description="Reading images with codecs" />
      <tag id="write" title="Write" description="Writing images with codecs" />
      <tag id="filesystem" title="Filesystem" description="Loading and saving images from files" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var losslessJpeg = new LosslessJpeg("Chicago.jpg"))
{
    losslessJpeg.WriteCropped(
        "CropJpegLosslessly.jpg",
        new System.Drawing.Rectangle(270, 180, 250, 214));
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>CropJpegLosslessly.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Transforms/ColorAdjustment/Desaturate.cs">
    <title>Desaturate</title>
    <description>Desaturates image.</description>
    <instruction>Desaturate the colors of an image (convert to grayscale) using the `Desaturate` method.</instruction>
    <output><![CDATA[The code:

- Applies the desaturation to the image, removing its color, effectively converting it to grayscale.
- The resulting image is saved to a file.]]></output>
    <tags>
      <tag id="color-adjustment" title="Color Adjustment" description="Adjusting brightness, contrast and color" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Chicago.jpg"))
{
    bitmap.ColorAdjustment.Desaturate();

    bitmap.Save("Desaturate.jpg");
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>Desaturate.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Text/EnhancedText/DoubleOutline.cs">
    <title>Double Outline</title>
    <description>Demonstrates how to draw a text with double outline.</description>
    <instruction>This code creates a bitmap with custom text drawn using double outlines, and saves the result as an image.</instruction>
    <output><![CDATA[The code:

- Creates a `Bitmap` object with a custom background color (`RgbColor(23, 42, 88)`).
- Initializes a custom font registry and loads a font from a TrueType font file (`Jost-Regular.ttf`).
- Retrieves an `AdvancedGraphics` object from the bitmap for drawing.
- Defines the text "WOW" and sets the font to be used with a size of 190 points.
- The text is initially drawn with a white outline (pen) with rounded line joins, without a brush (so the text is hollow).
- The text is then drawn again, this time with a solid fill color (`RgbColor(254, 190, 16)`) and a background outline (pen) with a different color and thickness.
- The final result is saved as a new PNG file (`DoubleOutline.png`).]]></output>
    <tags>
      <tag id="text" title="Text" description="Rendering and formatting text" />
      <tag id="formatted-text" title="Formatted Text" description="XML-based formatted text syntax" />
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;]]></usings>
    <code language="csharp"><![CDATA[var bgColor = new RgbColor(23, 42, 88);
var fillColor = new RgbColor(254, 190, 16);

using (var bitmap = new Bitmap(600, 250, PixelFormat.Format24bppRgb, bgColor))
using (var fr = new CustomFontRegistry())
using (var gr = bitmap.GetAdvancedGraphics())
{
    var psName = fr.Add("Jost-Regular.ttf");

    gr.FontRegistry = fr;

    var text = new PlainText("WOW", gr.CreateFont(psName, 190))
    {
        Position = new System.Drawing.PointF(10, 220),
    };

    text.Brush = null;
    text.Pen = new Pen(RgbColor.White, 15);
    text.Pen.LineJoin = Aurigma.GraphicsMill.AdvancedDrawing.LineJoin.Round;

    gr.DrawText(text);

    text.Brush = new SolidBrush(fillColor);
    text.Pen = new Pen(bgColor, 5);
    text.Pen.LineJoin = Aurigma.GraphicsMill.AdvancedDrawing.LineJoin.Round;

    gr.DrawText(text);

    bitmap.Save("DoubleOutline.png");
}]]></code>
    <io>
      <in_download>
        <file>Jost-Regular.ttf</file>
      </in_download>
      <out_preview>
        <file>DoubleOutline.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Text/TextLayout/DoublePathText.cs">
    <title>Double Path Text</title>
    <description>Demonstrates how to use double path text.</description>
    <instruction>This code demonstrates how to draw text along two custom paths (top and bottom paths) using the `DoublePathText` class.
It creates a bitmap, sets up a top and bottom path, and positions the text along these paths, centering it between the two.
Additionally, the code draws both paths in blue and saves the result as an image file.</instruction>
    <output><![CDATA[The code:

- Creates a 400x250 pixel bitmap with a white background.
- Defines a `DoublePathText` object to display the text "Double Path Text" with an "Arial" font of size 36, and centers it.
- Configures the top and bottom paths with custom curves to define the shapes the text will follow.
- Draws the text along these paths using the `graphics.DrawText()` method.
- Draws the paths in blue using `graphics.DrawPath()`.
- Saves the final image as "DoublePathText.png".]]></output>
    <tags>
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="text-layout" title="Text Layout" description="Controlling advanced text layout" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;]]></usings>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap(400, 250, PixelFormat.Format24bppRgb, new RgbColor(255, 255, 255, 255)))
using (var graphics = bitmap.GetAdvancedGraphics())
{
    var doublePathText = new DoublePathText("Double Path Text", graphics.CreateFont("Arial", 36))
    {
        Brush = new SolidBrush(new RgbColor(0x41, 0x41, 0x41)),
        ParagraphStyle = new ParagraphStyle() { Alignment = TextAlignment.Center },
        MainPath = MainPath.Bottom,
        AutoExtend = false,
    };

    doublePathText.TopPath.MoveTo(26, 71);
    doublePathText.TopPath.CurveTo(128, 162, 186, 21, 367, 64);

    doublePathText.BottomPath.MoveTo(26, 152);
    doublePathText.BottomPath.CurveTo(121, 177, 183, 68, 368, 157);

    graphics.DrawText(doublePathText);
    graphics.DrawPath(new Pen(RgbColor.Blue), doublePathText.TopPath);
    graphics.DrawPath(new Pen(RgbColor.Blue), doublePathText.BottomPath);

    bitmap.Save("DoublePathText.png");
}]]></code>
    <io>
      <out_preview>
        <file>DoublePathText.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Text/FormattedText/DrawLists.cs">
    <title>Draw Lists</title>
    <description>Draws formatted text with ordered and unordered lists.</description>
    <instruction>This code demonstrates how to draw various types of ordered and unordered lists (including nested lists) on a bitmap using the GraphicsMill library.
It shows different types of list item markers (numbers, lowercase letters, uppercase letters, roman numerals, and custom bullet types).</instruction>
    <output><![CDATA[The code:

- Creates a 600x600 pixel bitmap with a white background.
- Defines and draws several types of ordered lists (ol) and unordered lists (ul) using different markers:
- Ordered lists with numbers, lowercase letters, uppercase letters, lowercase roman numerals, uppercase roman numerals, and custom start values.
- Unordered lists with circle and square bullet types.
- Nested ordered and unordered lists, showcasing how to handle list hierarchy.
- Each list is drawn inside a bounded area on the bitmap, and a red rectangle is drawn around each list for clarity.
- The final result is saved to "DrawLists.png".]]></output>
    <tags>
      <tag id="formatted-text" title="Formatted Text" description="XML-based formatted text syntax" />
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;]]></usings>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap(600, 600, PixelFormat.Format24bppRgb, RgbColor.White))
using (var graphics = bitmap.GetAdvancedGraphics())
{
    // Ordered list (number)
    {
        var dummyText =
            @"<ol>" + // <ol style='type:numbers;'>
                @"<li>First</li>" +
                @"<li>Second</li>" +
                @"<li>Third</li>" +
                @"<li>Fourth</li>" +
            @"</ol>";

        var boundedText = new BoundedText(dummyText, graphics.CreateFont("Verdana", 18f), new SolidBrush(RgbColor.Black))
        {
            Rectangle = new System.Drawing.RectangleF(20f, 20f, 160f, 160f),
        };

        graphics.DrawText(boundedText);

        graphics.DrawRectangle(new Pen(RgbColor.Red), boundedText.Rectangle);
    }

    // Ordered list (lowercase letters)
    {
        var dummyText =
            @"<ol style='type:lowerLetter;'>" +
                @"<li>First</li>" +
                @"<li>Second</li>" +
                @"<li>Third</li>" +
                @"<li>Fourth</li>" +
            @"</ol>";

        var boundedText = new BoundedText(dummyText, graphics.CreateFont("Verdana", 18f), new SolidBrush(RgbColor.Black))
        {
            Rectangle = new System.Drawing.RectangleF(220f, 20f, 160f, 160f),
        };

        graphics.DrawText(boundedText);

        graphics.DrawRectangle(new Pen(RgbColor.Red), boundedText.Rectangle);
    }

    // Ordered list (uppercase letter)
    {
        var dummyText =
            @"<ol style='type:upperLetter;'>" +
                @"<li>First</li>" +
                @"<li>Second</li>" +
                @"<li>Third</li>" +
                @"<li>Fourth</li>" +
            @"</ol>";

        var boundedText = new BoundedText(dummyText, graphics.CreateFont("Verdana", 18f), new SolidBrush(RgbColor.Black))
        {
            Rectangle = new System.Drawing.RectangleF(420f, 20f, 160f, 160f),
        };

        graphics.DrawText(boundedText);

        graphics.DrawRectangle(new Pen(RgbColor.Red), boundedText.Rectangle);
    }

    // Ordered list (lowercase roman numerals)
    {
        var dummyText =
            @"<ol style='type:lowerRoman;'>" +
                @"<li>First</li>" +
                @"<li>Second</li>" +
                @"<li>Third</li>" +
                @"<li>Fourth</li>" +
            @"</ol>";

        var boundedText = new BoundedText(dummyText, graphics.CreateFont("Verdana", 18f), new SolidBrush(RgbColor.Black))
        {
            Rectangle = new System.Drawing.RectangleF(20f, 220f, 160f, 160f),
        };

        graphics.DrawText(boundedText);

        graphics.DrawRectangle(new Pen(RgbColor.Red), boundedText.Rectangle);
    }

    // Ordered list (uppercase roman numerals)
    {
        var dummyText =
            @"<ol style='type:upperRoman;'>" +
                @"<li>First</li>" +
                @"<li>Second</li>" +
                @"<li>Third</li>" +
                @"<li>Fourth</li>" +
            @"</ol>";

        var boundedText = new BoundedText(dummyText, graphics.CreateFont("Verdana", 18f), new SolidBrush(RgbColor.Black))
        {
            Rectangle = new System.Drawing.RectangleF(220f, 220f, 160f, 160f),
        };

        graphics.DrawText(boundedText);

        graphics.DrawRectangle(new Pen(RgbColor.Red), boundedText.Rectangle);
    }

    // Ordered list (start from 10)
    {
        var dummyText =
            @"<ol style='start:10;'>" +
                @"<li>Tenth</li>" +
                @"<li>Eleventh</li>" +
                @"<li>Twelfth</li>" +
                @"<li>Thirteenth</li>" +
            @"</ol>";

        var boundedText = new BoundedText(dummyText, graphics.CreateFont("Verdana", 18f), new SolidBrush(RgbColor.Black))
        {
            Rectangle = new System.Drawing.RectangleF(420f, 220f, 160f, 160f),
        };

        graphics.DrawText(boundedText);

        graphics.DrawRectangle(new Pen(RgbColor.Red), boundedText.Rectangle);
    }

    // Unordered list (circle)
    {
        var dummyText =
            @"<ul style='type: #9675;'>" +
                @"<li>First</li>" +
                @"<li>Second</li>" +
                @"<li>Third</li>" +
                @"<li>Fourth</li>" +
            @"</ul>";

        var boundedText = new BoundedText(dummyText, graphics.CreateFont("Arial", 18f), new SolidBrush(RgbColor.Black))
        {
            Rectangle = new System.Drawing.RectangleF(20f, 420f, 160f, 160f),
        };

        graphics.DrawText(boundedText);

        graphics.DrawRectangle(new Pen(RgbColor.Red), boundedText.Rectangle);
    }

    // Unordered list (square)
    {
        var dummyText =
            @"<ul style='type: #9632;'>" +
                @"<li>First</li>" +
                @"<li>Second</li>" +
                @"<li>Third</li>" +
                @"<li>Fourth</li>" +
            @"</ul>";

        var boundedText = new BoundedText(dummyText, graphics.CreateFont("Arial", 18f), new SolidBrush(RgbColor.Black))
        {
            Rectangle = new System.Drawing.RectangleF(220f, 420f, 160f, 160f),
        };

        graphics.DrawText(boundedText);

        graphics.DrawRectangle(new Pen(RgbColor.Red), boundedText.Rectangle);
    }

    // Nested lists
    {
        var dummyText =
            @"<ol>" +
                @"<li>First" +
                    @"<ul style='type: #9679;'>" +
                        @"<li>First</li>" +
                        @"<li>Second</li>" +
                        @"<li>Third</li>" +
                        @"<li>Fourth</li>" +
                    @"</ul>" +
                @"</li>" +
                @"<li>Second</li>" +
                @"<li>Third</li>" +
            @"</ol>";

        var boundedText = new BoundedText(dummyText, graphics.CreateFont("Arial", 18f), new SolidBrush(RgbColor.Black))
        {
            Rectangle = new System.Drawing.RectangleF(420f, 420f, 160f, 160f),
        };

        graphics.DrawText(boundedText);

        graphics.DrawRectangle(new Pen(RgbColor.Red), boundedText.Rectangle);
    }

bitmap.Save("DrawLists.png");]]></code>
    <io>
      <out_preview>
        <file>DrawLists.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/SpotColors/DrawOnPdfWithSpotColor.cs">
    <title>Draw On PDF With Spot Color</title>
    <description>Fills a rectangle with a PANTONE color.</description>
    <instruction>Write a C# program that fills a rectangle with a PANTONE color in a PDF document.</instruction>
    <output><![CDATA[Below is a C# code sample that demonstrates how to fill a rectangle with a PANTONE color in a PDF document using `PdfWriter`:

This code creates a PDF file where a rectangle is filled with a specified PANTONE color (in this case, PANTONE Red 032 C).]]></output>
    <tags>
      <tag id="pdf" title="PDF" description="Importing and exporting PDF documents" />
      <tag id="spot" title="Spot Color" description="Using spot colors in images" />
      <tag id="write" title="Write" description="Writing images with codecs" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;
using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var pdfWriter = new PdfWriter("VectorSpot.pdf"))
using (var gr = pdfWriter.GetGraphics())
{
    var ink = new Ink("PANTONE Red 032 C", new RgbColor(243, 40, 55));
    var spotColor = new SpotColor(ink, 255);

    pdfWriter.AddPage(500, 500, 72, 72);

    gr.FillRectangle(new SolidBrush(spotColor), 10, 10, 400, 400);

    pdfWriter.Close();
}]]></code>
    <io>
      <out_preview>
        <file>VectorSpot.png</file>
      </out_preview>
      <out_download>
        <file>VectorSpot.pdf</file>
      </out_download>
    </io>
  </sample>
  <sample path="Text/FormattedText/DrawParagraphs.cs">
    <title>Draw Paragraphs</title>
    <description>Draws formatted text with several paragraphs.</description>
    <instruction>This code demonstrates how to draw multiple paragraphs with custom text formatting (including first-line indentation and spacing before and after paragraphs) using the GraphicsMill library.
It includes the use of HTML-like inline styling for formatting each paragraph.</instruction>
    <output><![CDATA[The code:

- Creates a 600x400 pixel bitmap with a white background.
- Defines three paragraphs of text with custom styles:
- The first paragraph has a first-line indentation of 30pt, space before 50pt, and space after 20pt.
- The second paragraph has a first-line indentation of 50pt, space before 15pt, and space after 5pt.
- The third paragraph has a first-line indentation of 20pt and space before 20pt.
- The paragraphs are drawn within a bounded rectangle.
- A red rectangle is drawn around the text to highlight the bounded area.
- The final result is saved to "DrawParagraphs.png".]]></output>
    <tags>
      <tag id="formatted-text" title="Formatted Text" description="XML-based formatted text syntax" />
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;]]></usings>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap(600, 400, PixelFormat.Format24bppRgb, RgbColor.White))
using (var graphics = bitmap.GetAdvancedGraphics())
{
    var dummyText = @"<p style='first-line-indent:30pt;space-before:50pt;space-after:20pt;'>" +
        @"Lorem ipsum dolor sit amet, consectetur adipiscing elit, " +
        @"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut " +
        @"enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi " +
        @"ut aliquip ex ea commodo consequat." +
        @"</p>" +

        @"<p style='first-line-indent:50pt;space-before:15pt;space-after:5pt;'>" +
        @"Duis aute irure dolor in reprehenderit " +
        @"in voluptate velit esse cillum dolore eu fugiat nulla pariatur." +
        @"</p>" +

        @"<p style='first-line-indent:20pt;space-before:20pt;'>" +
        @"Excepteur " +
        @"sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt " +
        @"mollit anim id est laborum." +
        @"</p>";

    var boundedText = new BoundedText(dummyText, graphics.CreateFont("Verdana", 18f), new SolidBrush(RgbColor.Black))
    {
        Rectangle = new System.Drawing.RectangleF(20f, 20f, 560f, 360f),
    };

    graphics.DrawText(boundedText);

    graphics.DrawRectangle(new Pen(RgbColor.Red), boundedText.Rectangle);

    bitmap.Save("DrawParagraphs.png");
}]]></code>
    <io>
      <out_preview>
        <file>DrawParagraphs.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Drawing/DrawingPrimitives/DrawPath.cs">
    <title>Draw Path</title>
    <description>Draws path on Graphics.</description>
    <instruction>Draw vector shapes and styled text using a custom path, then transform and draw it again with rotation and translation.</instruction>
    <output><![CDATA[The code:

- Creates a vector path containing an ellipse and centered text.
- Draws the path in red on a blank image.
- Applies a transformation matrix to translate and rotate the path.
- Draws the transformed path in green.
- Saves the final result to an output file.]]></output>
    <tags>
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="text" title="Text" description="Rendering and formatting text" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;]]></usings>
    <code language="csharp"><![CDATA[var createPath = (Graphics graphics) =>
{
    var path = new Path();

    var font = graphics.CreateFont("Arial", "Bold", 40f);

    var text = new PlainText("GraphicsMill", font)
    {
        Alignment = TextAlignment.Center,
    };

    var blackBox = text.GetBlackBox(graphics.FontRegistry, graphics.DpiX, graphics.DpiY);
    text.Position = new System.Drawing.PointF(blackBox.Width, blackBox.Height * 2.3f);

    path.DrawEllipse(0, 0, blackBox.Width * 2, blackBox.Height * 4);
    path.DrawText(text, graphics.FontRegistry, graphics.DpiX, graphics.DpiY);

    return path;
};

using (var bitmap = new Bitmap(640, 480, PixelFormat.Format24bppRgb, RgbColor.White))
using (var graphics = bitmap.GetAdvancedGraphics())
{
    var path = createPath(graphics);

    graphics.DrawPath(new Pen(RgbColor.Red, 2f), path);

    // Translate coordinates and rotate
    var matrix = new System.Drawing.Drawing2D.Matrix();
    matrix.Translate(bitmap.Width / 3, bitmap.Height / 3);
    matrix.Rotate(30);
    graphics.Transform = matrix;

    graphics.DrawPath(new Pen(RgbColor.Green, 2f), path);

    bitmap.Save("DrawPath.png");
}]]></code>
    <io>
      <out_preview>
        <file>DrawPath.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/SpotColors/DrawSpotOnCmyk.cs">
    <title>Draw Spot On CMYK</title>
    <description>Draws a text and an image on the spot channel, using the existing CMYK image as a background.</description>
    <instruction>Write a C# program that draws text and an image on the spot channel using a CMYK background in a PDF.</instruction>
    <output><![CDATA[Below is a C# code sample that demonstrates how to draw text and an image on the spot channel in a PDF document,
using an existing CMYK image as the background. It uses `PdfWriter` and `ImageReader` to work with the background and spot colors:

This code creates a PDF where text and an image are drawn with a PANTONE spot color on top of a CMYK background image.]]></output>
    <tags>
      <tag id="pdf" title="PDF" description="Importing and exporting PDF documents" />
      <tag id="spot" title="Spot Color" description="Using spot colors in images" />
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="text" title="Text" description="Rendering and formatting text" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;
using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var bgImageReader = ImageReader.Create("Copenhagen_CMYK.jpg"))
using (var pdfWriter = new PdfWriter("SpotWithProcessColors.pdf"))
{
    Pipeline.Run(bgImageReader + pdfWriter);

    using (var gr = pdfWriter.GetGraphics())
    using (var spotImage = new Bitmap("Sheep.gif"))
    {
        var ink = new Ink("PANTONE Red 032 C", new RgbColor(243, 40, 55));
        var spotColor = new SpotColor(ink, 255);
        var text = new PlainText("Spot color text", gr.CreateFont("Arial", 150))
        {
            Position = new System.Drawing.PointF(gr.Width / 2, gr.Height / 2),
            Alignment = TextAlignment.Center,
            Brush = new SolidBrush(spotColor),
        };

        gr.DrawText(text);

        // After these operations, the loaded image reflects a spot color
        spotImage.ColorManagement.Ink = ink;
        spotImage.ColorManagement.Convert(PixelFormat.Format16bppAspot);

        spotImage.Transforms.Resize(400, 400, Aurigma.GraphicsMill.Transforms.ResizeInterpolationMode.Linear, Aurigma.GraphicsMill.Transforms.ResizeMode.Fit);

        gr.DrawImage(spotImage, gr.Width - spotImage.Width, gr.Height - (spotImage.Height / 3));
    }

    pdfWriter.Close();
}]]></code>
    <io>
      <in_preview>
        <file>Copenhagen_CMYK.jpg</file>
        <file>Sheep.gif</file>
      </in_preview>
      <out_preview>
        <file>SpotWithProcessColors.png</file>
      </out_preview>
      <out_download>
        <file>SpotWithProcessColors.pdf</file>
      </out_download>
    </io>
  </sample>
  <sample path="LargeImages/Transforms/TextWatermarkOnThumnail.cs">
    <title>Draw text watermark on thumbnail image</title>
    <description>This sample shows how to create a thumbnail image and draw a semi-transparent text watermark on top of it using the GraphicsMill transforms and advanced drawing APIs.
It demonstrates how to resize the source image with the &lt;a href="https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Transforms_Resize.htm"&gt;Resize&lt;/a&gt; transform, register a custom font, and render text with &lt;a href="https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_AdvancedDrawing_Drawer.htm"&gt;Drawer&lt;/a&gt; and &lt;a href="https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_AdvancedDrawing_PlainText.htm"&gt;PlainText&lt;/a&gt;.
You can read more information about drawing in the &lt;a href="https://www.graphicsmill.com/docs/gm/advanced-drawing.htm"&gt;documentation&lt;/a&gt;.</description>
    <instruction>Use the Pipeline API to create a thumbnail from an input image and overlay
a semi-transparent text watermark in the bottom-left corner, using a custom
font and the drawing subsystem.</instruction>
    <output><![CDATA[The code:

- Reads the source image "Venice.jpg" using <c>ImageReader</c>.
- Resizes the image to fit within 500x500 pixels while preserving aspect ratio
using the <c>Resize</c> transform in <c>ResizeMode.Fit</c> with
<c>ResizeInterpolationMode.Anisotropic9</c>.
- Registers a custom TrueType font (<c>Jost-Regular.ttf</c>) in a
<c>CustomFontRegistry</c>.
- Uses a <c>Drawer</c> element with a <c>Draw</c> event handler to:
- Configure the graphics context to use the custom font registry.
- Create a <c>PlainText</c> object with the string "WATERMARK TEXT" and
a 50 pt font size.
- Apply a semi-transparent white brush (<c>RgbColor.White.ScaleAlpha(0.7f)</c>).
- Position the text with a 10-pixel margin from the left and bottom edges
of the thumbnail.
- Draw the text onto the resized image.
- Runs the pipeline <c>reader + resize + drawer + writer</c> with
<c>Pipeline.Run</c>.
- Saves the resulting watermarked thumbnail as "TextWatermark.jpg" using
<c>JpegWriter</c>.]]></output>
    <tags>
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
      <tag id="resize" title="Resize" description="Resizing images" />
      <tag id="thumbnail" title="Thumbnail" description="Generating thumbnails from images" />
      <tag id="text" title="Text" description="Rendering and formatting text" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;
using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[// Read the source image and prepare pipeline elements.
using (var reader = ImageReader.Create("Venice.jpg"))
using (var resize = new Resize(500, 500, ResizeInterpolationMode.Anisotropic9, ResizeMode.Fit))
using (var drawer = new Drawer())
using (var writer = new JpegWriter("TextWatermark.jpg"))
using (var fr = new CustomFontRegistry())
{
    // Add font to the custom font registry and get its PostScript name.
    var psName = fr.Add("Jost-Regular.ttf");

    // Configure the Drawer to render the watermark text.
    drawer.Draw += (sender, e) =>
    {
        // Set the custom font registry to the current graphics context.
        e.Graphics.FontRegistry = fr;

        // Create the font to be used for the watermark text.
        var font = e.Graphics.CreateFont(psName, 50);

        // Create the  text object with semi-transparent white brush.
        var text = new PlainText("WATERMARK TEXT", font)
        {
            Brush = new SolidBrush(RgbColor.White.ScaleAlpha(0.7f)),
            Alignment = TextAlignment.Left,
        };

        // Place the text with a small margin from the left/bottom edges.
        var margin = 10;

        text.Position = new System.Drawing.PointF(margin, e.Height - margin);

        // Draw the watermark text onto the image.
        e.Graphics.DrawText(text);
    };

    // Run the pipeline.
    Pipeline.Run(reader + resize + drawer + writer);
}]]></code>
    <io>
      <in_preview>
        <file>Venice.jpg</file>
      </in_preview>
      <out_preview>
        <file>TextWatermark.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="LargeImages/Drawing/DrawUsingAdvancedGraphics.cs">
    <title>Draw Using Advanced Graphics</title>
    <description>Performs drawing with AdvancedDrawing in the Pipeline API.</description>
    <instruction>Draw a green-yellow rectangle around the edges of an image using advanced graphics in Pipeline API and save it.</instruction>
    <output><![CDATA[The code:

- Reads the image "Venice.jpg".
- Draws a green-yellow rectangle around the edges using advanced graphics.
- Saves the result to "DrawUsingAdvancedGraphics.jpg".]]></output>
    <tags>
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;
using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var reader = ImageReader.Create("Venice.jpg"))
using (var drawer = new Drawer())
using (var writer = ImageWriter.Create("DrawUsingAdvancedGraphics.jpg"))
{
    drawer.Draw += (sender, e) =>
    {
        var pen = new Pen(System.Drawing.Color.GreenYellow, 30);

        e.Graphics.DrawRectangle(pen, new System.Drawing.RectangleF(15, 15, e.Width - 30, e.Height - 30));
    };

    Aurigma.GraphicsMill.Pipeline.Run(reader + drawer + writer);
}]]></code>
    <io>
      <in_preview>
        <file>Venice.jpg</file>
      </in_preview>
      <out_preview>
        <file>DrawUsingAdvancedGraphics.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="LargeImages/Drawing/DrawUsingGdiPlusGraphics.cs">
    <title>Draw Using GDI+ Graphics</title>
    <description>Performs GDI+ drawing within the processing pipeline.</description>
    <instruction>Draw a blue dashed rectangle around the edges of a white image using GDI+ graphics and save it.</instruction>
    <output><![CDATA[The code:

- Creates a white 640x480 image.
- Draws a blue dashed rectangle around the edges using GDI+ graphics.
- Saves the result to "DrawUsingGdiPlusGraphics.jpg".]]></output>
    <tags>
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Drawing;]]></usings>
    <code language="csharp"><![CDATA[using (var generator = new ImageGenerator(640, 480, PixelFormat.Format24bppRgb, RgbColor.White))
using (var drawer = new GdiPlusGraphicsDrawer())
using (var writer = ImageWriter.Create("DrawUsingGdiPlusGraphics.jpg"))
{
    drawer.Draw += (sender, e) =>
    {
        var pen = new System.Drawing.Pen(System.Drawing.Color.Blue, 20);
        pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;

        e.Graphics.DrawRectangle(pen, new System.Drawing.Rectangle(20, 20, e.Width - 40, e.Height - 40));
    };

    Pipeline.Run(generator + drawer + writer);
}]]></code>
    <io>
      <out_preview>
        <file>DrawUsingGdiPlusGraphics.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Drawing/ClippingPaths/DrawWithClippingPath.cs">
    <title>Draw With Clipping Path</title>
    <description>Draws an image onto a Graphics object using a clipping path.</description>
    <instruction>Restrict the drawing region to an elliptical area using clipping paths, and draw an image within this restricted area.</instruction>
    <output><![CDATA[The code:

- Creates a white background bitmap with specified dimensions.
- Initializes advanced graphics and defines an elliptical clipping path covering the entire background.
- Loads a source image and draws it, constrained to the elliptical region.
- Saves the result to an output image file.]]></output>
    <tags>
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;]]></usings>
    <code language="csharp"><![CDATA[using (var background = new Bitmap(600, 450, PixelFormat.Format24bppRgb, RgbColor.White))
using (var graphics = background.GetAdvancedGraphics())
using (var bitmap = new Bitmap("Chicago.jpg"))
{
    var path = new Path();
    path.DrawEllipse(0f, 0f, background.Width, background.Height);

    graphics.ClippingPaths.Add(path);
    graphics.DrawImage(bitmap, 0f, 0f);

    background.Save("RestrictDrawingRegion.png");
}]]></code>
    <io>
      <out_preview>
        <file>RestrictDrawingRegion.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/VectorFormats/EnumContainerElements.cs">
    <title>Enum Container Elements</title>
    <description>Enumerates the elements of a graphics container.</description>
    <instruction>Enumerate and print the content of a graphics container extracted from a PDF file.</instruction>
    <output><![CDATA[The following code:

- Defines an extension method `PrintContent` for `GraphicsContainer`.
- Iterates over the container’s items, printing info about shapes, images, and text.
- Recursively enumerates nested `ContainerItem` instances.
- The `Run()` method reads a PDF file and prints the contents of the first frame’s graphics container to the console.]]></output>
    <tags>
      <tag id="pdf" title="PDF" description="Importing and exporting PDF documents" />
      <tag id="read" title="Read" description="Reading images with codecs" />
      <tag id="container" title="Graphics Container" description="Using graphics containers for grouped items" />
    </tags>
    <usings><![CDATA[using System;
using System.Linq;
using Aurigma.GraphicsMill.AdvancedDrawing;
using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[public static class Extensions
{
    public static void PrintContent(this GraphicsContainer container)
    {
        foreach (var shapeItem in container.Items.OfType<ShapeItem>())
        {
            Console.WriteLine("Shape:");

            if (shapeItem.Brush != null)
            {
                Console.WriteLine($"  {shapeItem.Brush.ToString()}");
            }

            if (shapeItem.Pen != null)
            {
                Console.WriteLine($"  {shapeItem.Pen.ToString()}");
            }
        }

        foreach (var imageItem in container.Items.OfType<ImageItem>())
        {
            Console.WriteLine($"Image: {imageItem.Bitmap.Width}x{imageItem.Bitmap.Height}");
        }

        foreach (var textItem in container.Items.OfType<TextItem>())
        {
            Console.WriteLine($"Text: {textItem.Text.String}");
        }

        foreach (var containerItem in container.Items.OfType<ContainerItem>())
        {
            containerItem.GraphicsContainer.PrintContent();
        }
    }
}

internal class EnumGraphicsContainerContent
{
    public static void Run()
    {
        using (var reader = new PdfReader("GraphicsContainer.pdf"))
        using (var gc = reader.Frames[0].GetContent())
        {
            gc.PrintContent();
        }
    }
}]]></code>
    <io>
      <in_download>
        <file>GraphicsContainer.pdf</file>
      </in_download>
      <out_preview>
        <file>EnumGraphicsContainerContent.txt</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Transforms/RotateAndFlip/Flip.cs">
    <title>Flip</title>
    <description>Flips image.</description>
    <instruction>Flip the image vertically and save the result to a new file.</instruction>
    <output><![CDATA[The code:

- Reads the image from file using the Bitmap constructor.
- Applies the "Flip" transform with the FlipType.Vertical option to flip the image vertically.
- Saves the flipped image to a new file, "Flip.jpg".]]></output>
    <tags>
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
      <tag id="transform" title="Transform" description="Image transforms and effects" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Chicago.jpg"))
{
    bitmap.Transforms.Flip(FlipType.Vertical);
    bitmap.Save("Flip.jpg");
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>Flip.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/Jpeg/FlipJpegLosslessly.cs">
    <title>Flip Jpeg Losslessly</title>
    <description>Flips JPEG image losslessly.</description>
    <instruction>Write a C# program that flips a JPEG image horizontally without recompression and saves the result as a new JPEG file. Use an image processing library capable of performing lossless JPEG transformations.</instruction>
    <output><![CDATA[Here is a C# program that performs a lossless horizontal flip on a JPEG image and saves it to a new file:

This code uses the `LosslessJpeg` class to flip `Chicago.jpg` horizontally and writes the result to `FlipJpegLosslessly.jpg`. Since it’s a lossless operation, image quality remains unchanged.]]></output>
    <tags>
      <tag id="jpg" title="JPG" description="Reading and writing JPEG images" />
      <tag id="lossless" title="Lossless JPEG" description="Applying lossless JPEG operations" />
      <tag id="read" title="Read" description="Reading images with codecs" />
      <tag id="write" title="Write" description="Writing images with codecs" />
      <tag id="filesystem" title="Filesystem" description="Loading and saving images from files" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var losslessJpeg = new LosslessJpeg("Chicago.jpg"))
{
    losslessJpeg.WriteRotated(
        "FlipJpegLosslessly.jpg",
        System.Drawing.RotateFlipType.RotateNoneFlipX);
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>FlipJpegLosslessly.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Text/FontRegistry/FontAPI.cs">
    <title>Font API</title>
    <description>Draws text without text objects, only with getting char info + simple metrics.</description>
    <instruction>This code demonstrates how to render each character of a text string using a custom font and apply individual character outlines.</instruction>
    <output><![CDATA[The code:

- Creates a `Bitmap` object with a white background (`RgbColor.White`) and dimensions of 200x200 pixels.
- Initializes an `AdvancedGraphics` object for drawing on the bitmap and uses a custom font registry (`CustomFontRegistry`) to add a font (`Lobster.ttf`).
- Sets the font registry for the graphics object and creates a font using the custom font (`Lobster.ttf`) at 40 points size.
- Defines an array of strings (`lines`) containing the text to render: "SOME", "TEXT", "TO ADD".
- Iterates through each line and each character of the line to obtain character information using `font.GetCharacterInfo`.
- Translates and draws the character outlines on the bitmap using `gr.FillPath` with black color (`RgbColor.Black`).
- Adjusts the X and Y positions for each character and each line to properly space them.
- Saves the resulting image with outlined characters as a PNG file (`FontAPI.png`).]]></output>
    <tags>
      <tag id="text" title="Text" description="Rendering and formatting text" />
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="font" title="Font" description="Managing fonts and font metrics" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;]]></usings>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap(200, 200, PixelFormat.Format24bppRgb, RgbColor.White))
using (var gr = bitmap.GetAdvancedGraphics())
using (var fr = new CustomFontRegistry())
{
    var psName = fr.Add("Lobster.ttf");

    gr.FontRegistry = fr;

    var font = gr.CreateFont(psName, 40);

    string[] lines = new string[] { "SOME", "TEXT", "TO ADD" };

    float x = 10f;
    float y = 50f;

    float offsetY = 0f;

    foreach (string line in lines)
    {
        float offsetX = 0f;

        for (int i = 0; i < line.Length; i++)
        {
            using (var charInfo = font.GetCharacterInfo(line[i]))
            {
                charInfo.Outline.Translate(x + offsetX, y + offsetY);

                gr.FillPath(new SolidBrush(RgbColor.Black), charInfo.Outline);

                offsetX += charInfo.AdvanceX;
            }
        }

        offsetY += font.Metrics.Height;
    }

    bitmap.Save("FontAPI.png");
}]]></code>
    <io>
      <in_download>
        <file>Lobster.ttf</file>
      </in_download>
      <out_preview>
        <file>FontAPI.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Text/FontRegistry/FontFallback.cs">
    <title>Font Fallback</title>
    <description>Draws multilanguage text with font fallback support.</description>
    <instruction>This code demonstrates how to use a custom font registry and implement font fallback when rendering text that includes characters not available in the primary font.</instruction>
    <output><![CDATA[The code:

- Creates a `Bitmap` object with a white background (`RgbColor.White`) and dimensions of 400x200 pixels.
- Initializes a custom `FontRegistry` (`CustomFontRegistry`) and adds two fonts: `Lobster.ttf` and `ARIALUNI.TTF` (Arial Unicode).
- Configures the `FontRegistry` to include `ARIALUNI.TTF` as a fallback font in case certain characters (such as non-Latin characters) cannot be rendered with the primary font.
- Creates an `AdvancedGraphics` object to draw on the bitmap and sets the font registry.
- Defines a string (`dummyText`) containing both Latin and non-Latin characters (Chinese text).
- Creates a `BoundedText` object for the text using the `Lobster.ttf` font and specifies the rectangle where the text should be drawn.
- Draws the text inside the defined bounds using the graphics object (`graphics.DrawText`).
- Saves the resulting image as a PNG file (`FontFallback.png`).]]></output>
    <tags>
      <tag id="text" title="Text" description="Rendering and formatting text" />
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="font" title="Font" description="Managing fonts and font metrics" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;]]></usings>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap(400, 200, PixelFormat.Format24bppRgb, RgbColor.White))
using (var graphics = bitmap.GetAdvancedGraphics())
{
    var fontRegistry = new CustomFontRegistry();

    var lobsterPsName = fontRegistry.Add("Lobster.ttf");
    var arialUnicodePsName = fontRegistry.Add("ARIALUNI.TTF");

    fontRegistry.FallbackFonts.Add(arialUnicodePsName);

    graphics.FontRegistry = fontRegistry;

    var dummyText = "Lorem ipsum dolor sit amet, ex mel latine pertinax. 載自大制節規信兵著旋避漂。";

    var boundedText = new BoundedText(dummyText, graphics.CreateFont(lobsterPsName, 32f), new SolidBrush(RgbColor.Black))
    {
        Rectangle = new System.Drawing.RectangleF(20f, 20f, 360f, 360f),
    };

    graphics.DrawText(boundedText);

    bitmap.Save("FontFallback.png");
}]]></code>
    <io>
      <in_download>
        <file>Lobster.ttf</file>
        <file>ARIALUNI.TTF</file>
      </in_download>
      <out_preview>
        <file>FontFallback.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Text/FontRegistry/FontMetrics.cs">
    <title>Font Metrics</title>
    <description>Adds font to FontRegistry from file and shows its metrics.</description>
    <instruction>This code demonstrates how to load a custom OpenType font, retrieve font metrics, and display font properties like size, ascender, descender, and more.</instruction>
    <output><![CDATA[The code:

- Creates a `CustomFontRegistry` to manage fonts.
- Loads a custom OpenType font (`Amburegul.otf`) using the font registry's `Add` method, and sets a font size of 30pt and DPI of 150 for rendering.
- Creates a font object using the `CreateFont` method from the registry, with the given size and DPI values.
- Prints various font metrics and properties to the console, such as:
- The font family and style
- DPI for both X and Y axis
- Font size in points
- Ascender and descender values (height from the baseline for the highest and lowest characters)
- Total height of the font
- Underline position and thickness
- The metrics are printed out in a human-readable format to help analyze the font characteristics.]]></output>
    <tags>
      <tag id="text" title="Text" description="Rendering and formatting text" />
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="font" title="Font" description="Managing fonts and font metrics" />
    </tags>
    <usings><![CDATA[using System;
using Aurigma.GraphicsMill.AdvancedDrawing;]]></usings>
    <code language="csharp"><![CDATA[using (var fontRegistry = new CustomFontRegistry())
{
    var fontSize = 30f;
    var dpi = 150f;

    // Load custom OpenType font
    var postscriptName = fontRegistry.Add("Amburegul.otf");

    var font = fontRegistry.CreateFont(postscriptName, fontSize, dpi, dpi);

    // Font metrics
    Console.WriteLine("Font: {0} {1}", font.Family, font.Style);
    Console.WriteLine("  DPI (X,Y):             {0},{0}", dpi);
    Console.WriteLine("  Size:                  {0}pt", fontSize);
    Console.WriteLine("  Ascender:              {0}px", font.Metrics.Ascender);
    Console.WriteLine("  Descender:             {0}px", font.Metrics.Descender);
    Console.WriteLine("  Height:                {0}px", font.Metrics.Height);
    Console.WriteLine("  Underline position:    {0}px", font.Metrics.UnderlinePosition);
    Console.WriteLine("  Underline thickness:   {0}px", font.Metrics.UnderlineThickness);
    Console.WriteLine();
}]]></code>
    <io>
      <in_download>
        <file>Amburegul.otf</file>
      </in_download>
      <out_preview>
        <file>FontMetrics.txt</file>
      </out_preview>
    </io>
  </sample>
  <sample path="ColorManagement/ColorProfile/GetEmbeddedProfile.cs">
    <title>Get embedded profile</title>
    <description>Gets and displays information about the embedded profile.</description>
    <instruction>Reads the ICC profile description from a CMYK image and displays it.</instruction>
    <output><![CDATA[The following code:

- Reads the CMYK image (`Copenhagen_CMYK.jpg`) using `Bitmap`.
- Accesses the embedded ICC profile from the image using `ColorProfile`.
- Displays the description of the ICC profile in the console.]]></output>
    <tags>
      <tag id="color-management" title="Color Management" description="Color management with ICC profiles" />
      <tag id="color-profile" title="Color Profile" description="Using ICC color profiles" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <usings><![CDATA[using System;]]></usings>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Copenhagen_CMYK.jpg"))
{
    // Display the description of the embedded profile
    Console.WriteLine("ICC Profile description:" + bitmap.ColorProfile.Description);
}]]></code>
    <io>
      <in_preview>
        <file>Copenhagen_CMYK.jpg</file>
      </in_preview>
      <out_preview>
        <file>GetEmbeddedProfile.txt</file>
      </out_preview>
    </io>
  </sample>
  <sample path="ColorManagement/ColorProfile/GetEmbeddedProfileMemoryFriendly.cs">
    <title>Get embedded profile using memory-friendly Pipeline API</title>
    <description>Gets and displays information about the embedded profile using the memory-friendly Pipeline API.</description>
    <instruction>Retrieves and displays the embedded ICC profile description from a CMYK image using the memory-friendly Pipeline API.</instruction>
    <output><![CDATA[The following code:

- Reads the CMYK image (`Copenhagen_CMYK.jpg`) using the `ImageReader` without loading the bitmap into memory.
- Accesses and displays the embedded ICC profile description using `reader.ColorProfile.Description`.]]></output>
    <tags>
      <tag id="color-management" title="Color Management" description="Color management with ICC profiles" />
      <tag id="color-profile" title="Color Profile" description="Using ICC color profiles" />
      <tag id="read" title="Read" description="Reading images with codecs" />
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
    </tags>
    <usings><![CDATA[using System;
using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var reader = ImageReader.Create("Copenhagen_CMYK.jpg"))
{
    // Bitmap isn't loaded to memory
    Console.WriteLine("ICC Profile description:" + reader.ColorProfile.Description);
}]]></code>
    <io>
      <in_preview>
        <file>Copenhagen_CMYK.jpg</file>
      </in_preview>
      <out_preview>
        <file>GetEmbeddedProfileMemoryFriendly.txt</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Metadata/EXIFAndIPTC/GetExifThumbnail.cs">
    <title>Get EXIF Thumbnail</title>
    <description>Gets thumbnail of image from its EXIF metadata.</description>
    <instruction>Extract and save the EXIF thumbnail from a JPEG image.</instruction>
    <output><![CDATA[The code:

- Reads the EXIF metadata from the input JPEG image.
- Extracts the thumbnail from the EXIF metadata.
- Writes the extracted thumbnail image to a new JPEG file.]]></output>
    <tags>
      <tag id="exif" title="EXIF" description="Managing EXIF metadata" />
      <tag id="thumbnail" title="Thumbnail" description="Generating thumbnails from images" />
      <tag id="read" title="Read" description="Reading images with codecs" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var jpegReader = new JpegReader("Venice.jpg"))
using (var thumbnail = (Bitmap)jpegReader.Exif[ExifDictionary.Thumbnail])
using (var jpegWriter = new JpegWriter("GetExifThumbnail.jpg"))
{
    Pipeline.Run(thumbnail + jpegWriter);
}]]></code>
    <io>
      <in_preview>
        <file>Venice.jpg</file>
      </in_preview>
      <out_preview>
        <file>GetExifThumbnail.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Text/EnhancedText/GradientColor.cs">
    <title>Gradient Color</title>
    <description>Demonstrates drawing text with a gradient fill.</description>
    <instruction>This code creates a bitmap with gradient-colored text and saves it as an image.</instruction>
    <output><![CDATA[The code:

- Creates a `Bitmap` object with a white background (`RgbColor(255, 255, 255, 255)`).
- Initializes an `AdvancedGraphics` object to handle the drawing on the bitmap.
- Defines a `LinearGradientBrush` for coloring the text, with a gradient that starts with Aqua, transitions to Black, and ends with Violet.
- Specifies the start and end points for the gradient and positions the color stops at defined positions (0.0, 0.66, 1.0).
- Defines the text "GRADIENT" and applies the gradient brush as its fill color.
- The text is drawn on the bitmap using a font (`Verdana`, 110pt) at the position `(10f, 230f)`.
- The final result is saved as a new PNG file (`GradientColor.png`).]]></output>
    <tags>
      <tag id="text" title="Text" description="Rendering and formatting text" />
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="gradient" title="Gradient" description="Using gradient brushes and fills" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;]]></usings>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap(600, 250, PixelFormat.Format24bppRgb, new RgbColor(255, 255, 255, 255)))
using (var graphics = bitmap.GetAdvancedGraphics())
{
    var gradientBrush = new LinearGradientBrush()
    {
        BackgroundColor = RgbColor.Green,
        StartPoint = new System.Drawing.PointF(0, 0),
        EndPoint = new System.Drawing.PointF(600, 400),
        ColorStops = new ColorStop[]
        {
            new ColorStop() { Color = RgbColor.Aqua, Position = 0.0f },
            new ColorStop() { Color = RgbColor.Black, Position = 0.66f },
            new ColorStop() { Color = RgbColor.Violet, Position = 1 },
        },
    };

    var dummyText = "GRADIENT";

    var text = new PlainText(dummyText, graphics.CreateFont("Verdana", 110f))
    {
        Position = new System.Drawing.PointF(10f, 230f),
        Brush = gradientBrush,
    };

    graphics.DrawText(text);

    bitmap.Save("GradientColor.png");
}]]></code>
    <io>
      <out_preview>
        <file>GradientColor.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Interoperability/HashFromBitmap/HashFromBitmap.cs">
    <title>Hash From Bitmap</title>
    <description>Demonstrates computing an MD5 hash from bitmap pixel data via unsafe pointer-based scanline access.</description>
    <instruction>Write a C# program that calculates MD5 hash from pixel data of "Chicago.jpg" by accessing raw bitmap scanlines via unsafe pointer operations and Scan0, copying each scanline to buffer using Marshal.Copy, processing through MD5 TransformBlock incrementally to handle large images without memory overflow, converting indexed formats to 32bpp ARGB first, and formatting hash as uppercase hexadecimal string.</instruction>
    <output><![CDATA[Below is a C# code sample that computes cryptographic hash from bitmap pixel data:

The code demonstrates low-level pixel data hashing using unsafe bitmap access with Scan0 pointer arithmetic, calculating scanline byte width from PixelFormat.Size, and streaming MD5 computation via TransformBlock for memory efficiency on large images. It handles indexed pixel formats by converting to 32bpp ARGB via ColorManagement, processes scanlines sequentially with Marshal.Copy to managed buffer and Stride-aware pointer advancement, and produces standard uppercase hexadecimal MD5 output suitable for image integrity verification, duplicate detection, or content fingerprinting applications.]]></output>
    <tags>
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
      <tag id="pixel-access" title="Pixel Access" description="Direct per-pixel bitmap access" />
    </tags>
    <usings><![CDATA[using System;
using System.Runtime.InteropServices;
using System.Security.Cryptography;]]></usings>
    <code language="csharp"><![CDATA[public static void Run()
{
    using (var bitmap = new Bitmap("Chicago.jpg"))
    {
        if (bitmap.PixelFormat.IsIndexed)
        {
            bitmap.ColorManagement.Convert(PixelFormat.Format32bppArgb);
        }

        Console.WriteLine("MD5: {0}", GetMD5Hash(bitmap));
    }
}

private static string GetMD5Hash(Bitmap bitmap)
{
    int scanlineByteWidth = bitmap.Width * bitmap.PixelFormat.Size / 8;

    using (var md5 = MD5.Create())
    {
        unsafe
        {
            byte* pScanline = (byte*)bitmap.Scan0.ToPointer();
            var buffer = new byte[scanlineByteWidth];

            for (int j = 0; j < bitmap.Height; ++j)
            {
                Marshal.Copy((IntPtr)pScanline, buffer, 0, scanlineByteWidth);

                md5.TransformBlock(buffer, 0, scanlineByteWidth, buffer, 0);

                pScanline += bitmap.Stride;
            }

            md5.TransformFinalBlock(new byte[0], 0, 0);
        }

        return string.Concat(Array.ConvertAll(md5.Hash, x => x.ToString("X2")));
    }
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>HashFromBitmap.txt</file>
      </out_preview>
    </io>
  </sample>
  <sample path="PSDFormat/RenderTemplates/InvertBackground.cs">
    <title>Invert Background</title>
    <description>Inverts background layer of PSD image and saves to PDF file.</description>
    <instruction>Write a C# program that processes "BusinessCard.psd" using PSD processor with custom FrameCallback to detect raster frames, applies Invert transform to invert pixel values of background layer, converts processed frame to GraphicsContainer using ResizeMode.ImageFill for layout preservation, and renders the modified PSD layers to PDF output "InvertBackground.pdf" via psdProcessor.Render method.</instruction>
    <output><![CDATA[Below is a C# code sample that inverts background layer of PSD and exports to PDF:

The code demonstrates PSD processing pipeline using custom FrameCallback to selectively apply Invert transform only to raster frames (skipping vector/text layers), converting inverted raster content to GraphicsContainer with ImageFill resizing mode to maintain design layout, while preserving non-background layers unchanged. The PSD processor handles layer composition, transparency, and effects, rendering the modified document to PDF format suitable for print production workflows where background inversion is needed for design variations or negative image effects.]]></output>
    <tags>
      <tag id="psd-processor" title="PSD Processor" description="Automating PSD-based personalization" />
      <tag id="personalization" title="Personalization" description="Replacing placeholders with dynamic content" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs.Psd;
using Aurigma.GraphicsMill.Templates;
using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[var psdProcessor = new PsdProcessor();

var psName = psdProcessor.FontResolver.FontRegistry.Add("ARIALUNI.TTF");
psdProcessor.FontResolver.FontRegistry.FallbackFonts.Add(psName);

psdProcessor.FrameCallback = (processor, frame) =>
{
    if (frame.Type != FrameType.Raster)
    {
        return processor.ProcessFrame(frame);
    }

    using (var invert = new Invert())
    {
        return frame.ToGraphicsContainer(frame + invert, ResizeMode.ImageFill);
    }
};

psdProcessor.Render("BusinessCard.psd", "InvertBackground.pdf");]]></code>
    <io>
      <in_download>
        <file>BusinessCard.psd</file>
      </in_download>
      <out_preview>
        <file>InvertBackground.png</file>
      </out_preview>
      <out_download>
        <file>InvertBackground.pdf</file>
      </out_download>
    </io>
  </sample>
  <sample path="Transforms/AdvancedToneCorrection/Levels.cs">
    <title>Levels</title>
    <description>Apply custom levels adjustment to an image.</description>
    <instruction>Apply custom levels adjustment to an image.</instruction>
    <output><![CDATA[The code:

- Adjusts the levels of the image using custom input/output levels and midpoint values.
- Applies the histogram adjustment using the `HistogramMode.Sum` mode for enhancing the image brightness and contrast.
- Saves the adjusted image in the output file.]]></output>
    <tags>
      <tag id="color-adjustment" title="Color Adjustment" description="Adjusting brightness, contrast and color" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Chicago.jpg"))
{
    bitmap.ColorAdjustment.Levels(0.03F, 0.9F, 0.05F, 1.5F, 0.7F, HistogramMode.Sum);

    bitmap.Save("Levels.jpg");
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>Levels.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/LoadingAndSavingImages/LoadMultiframeImage.cs">
    <title>Load Multiframe Image</title>
    <description>Loads multiframe image.</description>
    <instruction>Write a C# program that reads a multi-frame TIFF file and saves each frame as a separate JPEG image.</instruction>
    <output><![CDATA[Below is a C# code sample that reads each frame from a multi-frame TIFF image and saves it as a separate JPEG file:

The code demonstrates how to extract individual frames from a TIFF image and save them as separate JPEG files.]]></output>
    <tags>
      <tag id="tiff" title="TIFF" description="Reading and writing TIFF images" />
      <tag id="jpg" title="JPG" description="Reading and writing JPEG images" />
      <tag id="read" title="Read" description="Reading images with codecs" />
      <tag id="write" title="Write" description="Writing images with codecs" />
      <tag id="multi-frame" title="Multiple frames" description="Handling multi-frame image formats" />
      <tag id="filesystem" title="Filesystem" description="Loading and saving images from files" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var reader = new TiffReader("TIFFMultiframe.tif"))
{
    for (int i = 0; i < reader.Frames.Count; i++)
    {
        using (var bitmap = reader.Frames[i].GetBitmap())
        {
            bitmap.Save("LoadMultiframe_" + i + ".jpg");
        }
    }
}]]></code>
    <io>
      <in_download>
        <file>TIFFMultiframe.tif</file>
      </in_download>
      <out_preview>
        <file>LoadMultiframe_0.jpg</file>
        <file>LoadMultiframe_1.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/LoadingAndSavingImages/LoadSaveStream.cs">
    <title>Load Save Stream</title>
    <description>Loads and saves image to stream.</description>
    <instruction>Write a C# program that loads an image from a stream, applies JPEG quality settings, and saves it to another stream.</instruction>
    <output><![CDATA[Below is a C# code sample that loads an image from a stream, applies JPEG quality settings, and saves it to a different stream:

The code demonstrates how to load an image from an input stream, set encoder options (JPEG quality), and save it to an output stream.]]></output>
    <tags>
      <tag id="jpg" title="JPG" description="Reading and writing JPEG images" />
      <tag id="read" title="Read" description="Reading images with codecs" />
      <tag id="write" title="Write" description="Writing images with codecs" />
      <tag id="stream" title="Stream" description="Reading and writing images from streams" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var readStream = System.IO.File.OpenRead("Chicago.jpg"))
using (var writerStream = System.IO.File.OpenWrite("LoadSaveStream.jpg"))
using (var bitmap = new Bitmap(readStream))
{
    bitmap.Save(writerStream, new JpegSettings(85));
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>LoadSaveStream.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Drawing/Transform/MatrixTransform.cs">
    <title>Matrix Transform</title>
    <description>Applies matrix transformation to graphics.</description>
    <instruction>Draw an ellipse and text with transformations (move, shear, rotate) applied to the coordinate system.</instruction>
    <output><![CDATA[The code:

- Draws an ellipse and centered text in a normal coordinate system.
- Applies a transformation to the coordinate system (translation to the center) and draws the first shape.
- Then, applies further transformations (translation, shear, rotation) and draws the same shape with altered transformations and reduced opacity.
- Saves the final image to an output file.]]></output>
    <tags>
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;]]></usings>
    <code language="csharp"><![CDATA[var drawEllipseAndText = (Graphics graphics) =>
{
    graphics.DrawEllipse(new Pen(new RgbColor(0x01, 0x97, 0xfd), 20f), -280, -135, 560, 270);

    var text = new PlainText("Graphics Mill", graphics.CreateFont("Arial", "Bold", 80f));
    text.Alignment = TextAlignment.Center;
    text.Position = new System.Drawing.PointF(0f, text.GetBlackBox(graphics.FontRegistry, graphics.DpiX, graphics.DpiY).Height / 2);
    text.Brush = new SolidBrush(new RgbColor(0xd4, 0x00, 0x00));

    graphics.DrawText(text);
};

using (var bitmap = new Bitmap(600, 300, PixelFormat.Format24bppRgb, RgbColor.White))
using (var graphics = bitmap.GetAdvancedGraphics())
{
    // Move coordinate system
    graphics.Transform = new System.Drawing.Drawing2D.Matrix();
    graphics.Transform.Translate(bitmap.Width / 2, bitmap.Height / 2);

    drawEllipseAndText(graphics);

    // Move, shear and rotate coordinate system
    graphics.Transform = new System.Drawing.Drawing2D.Matrix();
    graphics.Transform.Translate(bitmap.Width / 2, bitmap.Height / 2);
    graphics.Transform.Shear(0.5f, 0.1f);
    graphics.Transform.Rotate(30f);

    graphics.Opacity = 0.3f;

    drawEllipseAndText(graphics);

    bitmap.Save("TransformCoordinates.png");
}]]></code>
    <io>
      <out_preview>
        <file>TransformCoordinates.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Transforms/MinimumMaximumMedian/Maximum.cs">
    <title>Maximum</title>
    <description>Applies the Maximum transform to the image.</description>
    <instruction>Apply the "Maximum" transform to the image, modifying the image using the specified parameter of 3.</instruction>
    <output><![CDATA[The code:

- Loads the image.
- Applies the "Maximum" transform with a specified parameter value of 3.
- Saves the modified image to a new file.]]></output>
    <tags>
      <tag id="transform" title="Transform" description="Image transforms and effects" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Chicago.jpg"))
{
    bitmap.Transforms.Maximum(3);

    bitmap.Save("Maximum.jpg");
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>Maximum.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Transforms/MinimumMaximumMedian/Median.cs">
    <title>Median</title>
    <description>Applies the Median transform to the image.</description>
    <instruction>Apply the "Median" transform to the image using the specified parameter of 3.</instruction>
    <output><![CDATA[The code:

- Reads the image using Bitmap.
- Applies the "Median" transform with a parameter value of 3.
- Saves the transformed image to a new file.]]></output>
    <tags>
      <tag id="transform" title="Transform" description="Image transforms and effects" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Chicago.jpg"))
{
    bitmap.Transforms.Median(3);

    bitmap.Save("Median.jpg");
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>Median.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Transforms/MinimumMaximumMedian/Minimum.cs">
    <title>Minimum</title>
    <description>Applies the Minimum transform to the image.</description>
    <instruction>Apply the "Minimum" transform to the image using the specified parameter of 3.</instruction>
    <output><![CDATA[The code:

- Uses the Bitmap class to load an image.
- Applies the "Minimum" transform with a parameter value of 3 to the image.
- Saves the transformed image to a file.]]></output>
    <tags>
      <tag id="transform" title="Transform" description="Image transforms and effects" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Chicago.jpg"))
{
    bitmap.Transforms.Minimum(3);

    bitmap.Save("Minimum.jpg");
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>Minimum.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Metadata/ClippingPath/ModifyClippingPathExplicitly.cs">
    <title>Modify Clipping Path Explicitly</title>
    <description>Modifies clipping path explicitly.</description>
    <instruction>Crop the image while modifying its clipping path explicitly and save the result as a JPEG file.</instruction>
    <output><![CDATA[The code:

- Reads the "Apple.jpg" image and extracts its first frame.
- Crops the image using specified coordinates (20, 20) to (bitmap.Width - 40, bitmap.Height - 40).
- Modifies the clipping path associated with the image by applying the crop transformation.
- Creates an Adobe resource dictionary and adds the modified clipping path to it.
- Saves the cropped image with the updated clipping path to "ModifyClippingPathExplicitly.jpg" with the Adobe resources (clipping path) included.]]></output>
    <tags>
      <tag id="clipping-paths" title="Clipping Paths" description="Reading and writing Adobe resources clipping path" />
      <tag id="read" title="Read" description="Reading images with codecs" />
      <tag id="write" title="Write" description="Writing images with codecs" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
      <tag id="crop" title="Crop" description="Cropping images" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[using (var reader = new JpegReader("Apple.jpg"))
using (var bitmap = reader.Frames[0].GetBitmap())
{
    var crop = new Crop(20, 20, bitmap.Width - 40, bitmap.Height - 40);

    var cropped = crop.Apply(bitmap);

    var clippingPath = reader.ClippingPaths[0];

    clippingPath.ApplyTransform(crop.GetPathTransformMatrix(bitmap.Width, bitmap.Height).ToGdiPlusMatrix());

    var adobeResources = new AdobeResourceDictionary();
    adobeResources.Add(FirstPathId, new AdobeResourceBlock("Apple", clippingPath.Data));

    var jpegSettings = new JpegSettings();
    jpegSettings.AdobeResources = adobeResources;

    cropped.Save("ModifyClippingPathExplicitly.jpg", jpegSettings);
}]]></code>
    <io>
      <in_preview>
        <file>Apple.jpg</file>
      </in_preview>
      <out_preview>
        <file>ModifyClippingPathExplicitly.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Metadata/ClippingPath/ModifyClippingPathExplicitlyMemoryFriendly.cs">
    <title>Modify Clipping Path Explicitly (Memory Friendly)</title>
    <description>Modifies clipping path explicitly using memory-friendly Pipeline API.</description>
    <instruction>Modify an image by combining it with a generated white background, adjusting its clipping path coordinates, and saving it with the updated clipping path as a JPEG.</instruction>
    <output><![CDATA[The code:

- Reads the "Apple.jpg" image.
- Generates a new image with specified width and height, using a white background.
- Combines the original image onto the center of the generated image.
- Transforms the clipping path relative coordinates to match the new image dimensions.
- Removes any existing clipping paths within the Adobe resources and adds the transformed clipping paths.
- Saves the result as a JPEG image, including the updated clipping paths in the Adobe resources, to "ModifyClippingPathExplicitlyMemoryFriendly.jpg".]]></output>
    <tags>
      <tag id="clipping-paths" title="Clipping Paths" description="Reading and writing Adobe resources clipping path" />
      <tag id="read" title="Read" description="Reading images with codecs" />
      <tag id="write" title="Write" description="Writing images with codecs" />
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
      <tag id="crop" title="Crop" description="Cropping images" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[int width = 1000;
int height = 1000;

using (var reader = new JpegReader("Apple.jpg"))
using (var generator = new ImageGenerator(width, height, reader.PixelFormat, RgbColor.White))
using (var combiner = new Combiner(CombineMode.Copy))
using (var writer = new JpegWriter("ModifyClippingPathExplicitlyMemoryFriendly.jpg"))
{
    combiner.TopImage = reader;
    combiner.X = (width - reader.Width) / 2;
    combiner.Y = (height - reader.Height) / 2;

    // The clipping path has relatives coordinates (0.0f ... 1.f0). So we need to transform it.
    var transform = new System.Drawing.Drawing2D.Matrix();
    transform.Scale((float)reader.Width / (float)width, (float)reader.Height / (float)height);
    transform.Translate((float)combiner.X / (float)reader.Width, (float)combiner.Y / (float)reader.Height);

    var adobeResources = reader.AdobeResources;

    // Remove clipping paths
    foreach (long key in adobeResources.Keys)
    {
        if (key >= FirstPathId && key <= LastPathId)
        {
            adobeResources.Remove(key);
        }
    }

    // Transform and save clipping paths
    for (var i = 0; i < reader.ClippingPaths.Count; i++)
    {
        var clippingPath = reader.ClippingPaths[i];
        clippingPath.ApplyTransform(transform);

        adobeResources.Add(FirstPathId + i, new AdobeResourceBlock(clippingPath.Name, clippingPath.Data));
    }

    writer.AdobeResources = adobeResources;

    Pipeline.Run(generator + combiner + writer);
}]]></code>
    <io>
      <in_preview>
        <file>Apple.jpg</file>
      </in_preview>
      <out_preview>
        <file>ModifyClippingPathExplicitlyMemoryFriendly.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="LargeImages/Transforms/GetMultipleThumbnails.cs">
    <title>Multiple thumbnails</title>
    <description>Creates two different-sized images from a single read of the source image. In most cases, reading the image is the bottleneck, so this approach significantly improves performance.</description>
    <instruction>Resize the input image to two different sizes (big and small) and save the results to separate files.</instruction>
    <output><![CDATA[The code:

- Reads the image "Venice.jpg".
- Resizes the image to 640px wide and saves it as "Venice_thumbnail_big.jpg".
- Resizes the image to 128px wide and saves it as "Venice_thumbnail_small.jpg".]]></output>
    <tags>
      <tag id="branched-pipeline" title="Branched Pipeline" description="Building branched processing pipelines" />
      <tag id="resize" title="Resize" description="Resizing images" />
      <tag id="thumbnail" title="Thumbnail" description="Generating thumbnails from images" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[// reader --->  resizeBig    --->  writerBig
//        \-->  resizeSmall  --->  writerSmall
using (var reader = ImageReader.Create("Venice.jpg"))
using (var resizeBig = new Resize(640, 0, ResizeInterpolationMode.High))
using (var writerBig = ImageWriter.Create("Venice_thumbnail_big.jpg"))
using (var resizeSmall = new Resize(128, 0, ResizeInterpolationMode.High))
using (var writerSmall = ImageWriter.Create("Venice_thumbnail_small.jpg"))
{
    reader.Receivers.Add(resizeBig);
    resizeBig.Receivers.Add(writerBig);

    reader.Receivers.Add(resizeSmall);
    resizeSmall.Receivers.Add(writerSmall);

    Pipeline.Run(reader);
}]]></code>
    <io>
      <in_preview>
        <file>Venice.jpg</file>
      </in_preview>
      <out_preview>
        <file>Venice_thumbnail_big.jpg</file>
        <file>Venice_thumbnail_small.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Drawing/DrawingImages/DrawingImage.cs">
    <title>Overlay an Image onto Another Image</title>
    <description>Apply a watermark image onto a base image using advanced graphics drawing features.</description>
    <instruction>Overlay a watermark image onto another image using advanced graphics drawing capabilities.</instruction>
    <output><![CDATA[The code:

- Loads a base image and a watermark image.
- Creates a graphics object from the base image for advanced drawing operations.
- Draws the watermark near the bottom-left corner of the base image with a margin.
- Saves the composited image to a new file.]]></output>
    <tags>
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="watermark" title="Watermark" description="Adding text or image watermarks" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Venice.jpg"))
using (var watermark = new Bitmap("Stamp.png"))
using (var graphics = bitmap.GetAdvancedGraphics())
{
    graphics.DrawImage(watermark, 10, bitmap.Height - watermark.Height - 40);

    bitmap.Save("DrawImage.jpg");
}]]></code>
    <io>
      <in_preview>
        <file>Venice.jpg</file>
        <file>Stamp.png</file>
      </in_preview>
      <out_preview>
        <file>DrawImage.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Text/TextLayout/PathBoundedText.cs">
    <title>Path Bounded Text</title>
    <description>Draws text that flows across text frames; a green ellipse serves as a wrapping path that excludes text from its area.</description>
    <instruction>This code demonstrates how to draw text inside multiple bounding paths and wrap it around a custom path using the `PathBoundedText` class.
The text flows between two rectangular bounding paths and is wrapped around an elliptical path. The result is displayed with drawn paths for visualization.</instruction>
    <output><![CDATA[The code:

- Creates a 600x300 pixel bitmap with a white background.
- Defines a long text block (`dummyText`) to be displayed.
- Creates a `PathBoundedText` object and assigns two rectangular bounding paths for the text to flow across.
- Adds an elliptical path to wrap the text around it.
- Draws the text, bounding paths, and wrapping path on the graphics object.
- Colors the wrapping path in light green, the bounding paths in red, and draws a blue line between the bounding paths.
- Saves the final image as "DrawPathBoundedText.png".]]></output>
    <tags>
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="text-layout" title="Text Layout" description="Controlling advanced text layout" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;]]></usings>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap(600, 300, PixelFormat.Format24bppRgb, RgbColor.White))
using (var graphics = bitmap.GetAdvancedGraphics())
{
    var dummyText = @"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do " +
        "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim " +
        "veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo " +
        "consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum " +
        "dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, " +
        "sunt in culpa qui officia deserunt mollit anim id est laborum.";

    var pathBoundedText = new PathBoundedText(dummyText, graphics.CreateFont("Verdana", 18f), new SolidBrush(RgbColor.Black));

    // Adding text areas. When the first text area runs out of space,
    // text will automatically flow to the next one.
    var boundingPath1 = new Path();
    boundingPath1.DrawRectangle(20, 20, 260, 260);
    pathBoundedText.BoundingPaths.Add(boundingPath1);

    var boundingPath2 = new Path();
    boundingPath2.DrawRectangle(320, 20, 260, 260);
    pathBoundedText.BoundingPaths.Add(boundingPath2);

    // Adding paths which you need to wrap with the text
    var wrappingPath = new Path();
    wrappingPath.DrawEllipse(200, 100, 200, 100);
    pathBoundedText.WrappingPaths.Add(wrappingPath);

    graphics.DrawText(pathBoundedText);

    // Drawing frames around text blocks (for demonstration purposes)
    graphics.FillPath(new SolidBrush(RgbColor.LightGreen), wrappingPath);

    var pen = new Pen(RgbColor.Red);
    graphics.DrawPath(pen, boundingPath1);
    graphics.DrawPath(pen, boundingPath2);

    graphics.DrawLine(new Pen(RgbColor.Blue, 2f), 280f, 280f, 320f, 20f);

    bitmap.Save("DrawPathBoundedText.png");
}]]></code>
    <io>
      <out_preview>
        <file>DrawPathBoundedText.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Text/TextLayout/PathText.cs">
    <title>Path Text</title>
    <description>Draws text on a path.</description>
    <instruction>This code demonstrates how to draw text along a custom path using the `PathText` class. The text is positioned along a Bezier curve path with specific start and end points.
It also showcases styling the path and text using a crimson-colored pen and a solid black brush.</instruction>
    <output><![CDATA[The code:

- Creates a 400x250 pixel bitmap with a white background.
- Defines a text ("TEXT ON PATH") to be drawn along a Bezier curve path.
- Uses the `PathText` class to position the text along the defined path.
- Draws the path in blue and the text along it using a black brush and crimson-colored pen.
- Saves the image as "PathText.png".]]></output>
    <tags>
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="text-layout" title="Text Layout" description="Controlling advanced text layout" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;]]></usings>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap(400, 250, PixelFormat.Format24bppRgb, new RgbColor(255, 255, 255, 255)))
using (var graphics = bitmap.GetAdvancedGraphics())
{
    var pathText = new PathText("TEXT ON PATH", graphics.CreateFont("Arial", 36))
    {
        Pen = new Pen(RgbColor.Crimson, 1),
        Brush = new SolidBrush(new RgbColor(0x41, 0x41, 0x41)),
        ParagraphStyle = new ParagraphStyle() { Alignment = TextAlignment.Left },
        Stretch = false,
        Start = 0.2f,
        End = 1.0f,
        AutoExtend = false,
    };

    pathText.Path.MoveTo(26, 230);
    pathText.Path.CurveTo(126, 300, 226, 21, 426, 221);

    graphics.DrawPath(new Pen(RgbColor.Blue), pathText.Path);
    graphics.DrawText(pathText);

    bitmap.Save("PathText.png");
}]]></code>
    <io>
      <out_preview>
        <file>PathText.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/Pdf/Layers.cs">
    <title>PDF Layers</title>
    <description>Creates a PDF with layered content.</description>
    <instruction>Write a C# program that creates a PDF with layers. One layer should be visible and another should be invisible. The code should draw shapes on each layer, and a line should be drawn without any layer.</instruction>
    <output><![CDATA[Below is a C# code sample that demonstrates how to create a PDF with multiple layers. One layer is visible, another is invisible, and a line is drawn without any layer applied:

This code generates a PDF with a visible green layer, an invisible red layer, and a blue line drawn without any layer, allowing you to work with layers in PDF documents.]]></output>
    <tags>
      <tag id="pdf" title="PDF" description="Importing and exporting PDF documents" />
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="write" title="Write" description="Writing images with codecs" />
      <tag id="filesystem" title="Filesystem" description="Loading and saving images from files" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;
using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var writer = new PdfWriter("PdfWithLayers.pdf"))
using (var gr = writer.GetGraphics())
{
    writer.AddPage(500, 500);

    // Visible layer
    gr.Layer = new Layer("Visible layer");

    gr.FillRectangle(new SolidBrush(RgbColor.Green), 0, 0, 100, 100);
    gr.FillEllipse(new SolidBrush(RgbColor.Green), 100, 0, 100, 100);

    // Invisible layer
    gr.Layer = new Layer("Invisible layer") { IsVisible = false };

    gr.FillRectangle(new SolidBrush(RgbColor.Red), 0, 300, 100, 100);
    gr.FillEllipse(new SolidBrush(RgbColor.Red), 100, 300, 100, 100);

    // No layer
    gr.Layer = null;

    gr.DrawLine(new Pen(RgbColor.Blue, 4), gr.Width, 0, 0, gr.Height);

    writer.Close();
}]]></code>
    <io>
      <out_preview>
        <file>PdfWithLayers.png</file>
      </out_preview>
      <out_download>
        <file>PdfWithLayers.pdf</file>
      </out_download>
    </io>
  </sample>
  <sample path="Codecs/VectorFormats/PdfToSVG.cs">
    <title>PDF To SVG</title>
    <description>Reads vector content from a PDF file and saves it to an SVG format.</description>
    <instruction>Convert a PDF file to an SVG format by rendering its graphics container content.</instruction>
    <output><![CDATA[The following code:

- Reads a PDF file using `PdfReader`.
- Creates an `SvgWriter` with the same dimensions and resolution as the input PDF.
- Retrieves the graphics container of the first frame from the PDF.
- Draws the container onto the SVG graphics context, resulting in a vector-based output.]]></output>
    <tags>
      <tag id="pdf" title="PDF" description="Importing and exporting PDF documents" />
      <tag id="svg" title="SVG" description="Importing and exporting SVG graphics" />
      <tag id="format-conversion" title="Format Conversion" description="Converting images between formats" />
      <tag id="container" title="Graphics Container" description="Using graphics containers for grouped items" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var reader = new PdfReader("Seal.pdf"))
using (var writer = new SvgWriter("Seal.svg", reader.Width, reader.Height, reader.DpiX, reader.DpiY))
using (var gr = writer.GetGraphics())
{
    using (var container = reader.Frames[0].GetContent())
    {
        gr.DrawContainer(container, 0, 0);
    }
}]]></code>
    <io>
      <in_download>
        <file>Seal.pdf</file>
      </in_download>
      <out_preview>
        <file>Seal.svg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Text/TextLayout/PlainText.cs">
    <title>Plain Text</title>
    <description>Demonstrates how to use plain text.</description>
    <instruction>This code demonstrates how to render both horizontal and vertical text using the `PlainText` class.
The horizontal text is displayed normally, while the vertical text is rotated to be drawn vertically.
A glow effect is applied to the vertical text, and a red ellipse is drawn around the text positions for visualization.</instruction>
    <output><![CDATA[The code:

- Creates a 400x250 pixel bitmap with a white background.
- Draws horizontal text with two lines using the `PlainText` class (Times New Roman font, 22pt).
- Draws vertical text with a glow effect using the `PlainText` class (Arial font, 24pt).
- Adds a red ellipse around the positions of the texts for reference.
- Saves the resulting image as "PlainText.png".]]></output>
    <tags>
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="text-layout" title="Text Layout" description="Controlling advanced text layout" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;
using Aurigma.GraphicsMill.AdvancedDrawing.Effects;]]></usings>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap(400, 250, PixelFormat.Format24bppRgb, new RgbColor(255, 255, 255, 255)))
using (var graphics = bitmap.GetAdvancedGraphics())
{
    var brush = new SolidBrush(new RgbColor(0x41, 0x41, 0x41));

    var texts = new PlainText[]
    {
        new PlainText("Horizontal text\nwith two lines", graphics.CreateFont("Times New Roman", 22f), brush)
        {
            Position = new System.Drawing.PointF(50f, 38f),
        },
        new PlainText("Vertical", graphics.CreateFont("Arial", 24f), brush)
        {
            Vertical = true,
            Position = new System.Drawing.PointF(20f, 10f),
            Effect = new Glow(new RgbColor(0x66, 0xaf, 0xe9), 5),
        },
    };

    foreach (var text in texts)
    {
        graphics.DrawEllipse(new Pen(RgbColor.Red, 2), text.Position.X - 1, text.Position.Y - 1, 2, 2);
        graphics.DrawText(text);
    }

    bitmap.Save("PlainText.png");
}]]></code>
    <io>
      <out_preview>
        <file>PlainText.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/Png/PngNeuQuantExample.cs">
    <title>Png NeuQuant Example</title>
    <description>Saves image to PNG format using different bitness, color quantization and dithering algorithms.</description>
    <instruction>Write a C# program that saves an image to PNG format using different bit depths, color quantization algorithms, and dithering techniques. The program should convert the image to 24-bit PNG, 8-bit PNG with Octree and Floyd-Steinberg dithering, and 8-bit PNG with NeuQuant color quantization.</instruction>
    <output><![CDATA[Below is a C# code sample that demonstrates how to save an image to PNG format using various bit depths and color quantization methods. The program saves the image as a 24-bit PNG, an 8-bit PNG with Octree and Floyd-Steinberg dithering, and an 8-bit PNG with NeuQuant color quantization:

This code provides conversions that optimize file sizes and image quality based on the selected bit depth and quantization algorithms.]]></output>
    <tags>
      <tag id="png" title="PNG" description="Reading and writing PNG images" />
      <tag id="indexed" title="Indexed format" description="Working with indexed-color images" />
      <tag id="format-conversion" title="Format Conversion" description="Converting images between formats" />
    </tags>
    <usings><![CDATA[using System;
using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[public static void Run()
{
    Save("Chicago.jpg");
    Save("Stamp.png");
}

private static void Save(string sourceFileName)
{
    // Source file information
    long sourceFileSize = new System.IO.FileInfo(sourceFileName).Length;

    Console.WriteLine("Source file:");
    Console.WriteLine("  {0}", sourceFileName);
    Console.WriteLine("  {0:f2} KB", sourceFileSize / 1024f);

    var baseName = System.IO.Path.GetFileNameWithoutExtension(sourceFileName);

    // Convert to 24-bit PNG
    {
        var png24bitFileName = baseName + "_24bit.png";

        // Save to PNG
        using (var bitmap = new Bitmap(sourceFileName))
        {
            bitmap.Save(png24bitFileName, new PngSettings(true));
        }

        long png24bitFileSize = new System.IO.FileInfo(png24bitFileName).Length;

        Console.WriteLine("PNG 24-bit:");
        Console.WriteLine("  {0}", png24bitFileName);
        Console.WriteLine("  {0:f2} KB ({1:f2}%)", (float)png24bitFileSize / 1024f, (float)png24bitFileSize / (float)sourceFileSize * 100f);
    }

    // Convert to 8-bit PNG using the Octree color quantization and Floyd–Steinberg dithering algorithms
    {
        var png8bitFileName = baseName + "_8bit.png";

        // Save to PNG
        using (var bitmap = new Bitmap(sourceFileName))
        {
            bitmap.ColorManagement.Convert(PixelFormat.Format8bppIndexed);

            bitmap.Save(png8bitFileName, new PngSettings(true));
        }

        long png8bitFileSize = new System.IO.FileInfo(png8bitFileName).Length;

        Console.WriteLine("PNG 8-bit (Octree, Floyd–Steinberg, no alpha transparency):");
        Console.WriteLine("  {0}", png8bitFileName);
        Console.WriteLine("  {0:f2} KB ({1:f2}%)", (float)png8bitFileSize / 1024f, (float)png8bitFileSize / (float)sourceFileSize * 100f);
    }

    // Convert to 8-bit PNG using the Neuquant color quantization algorithm
    {
        var png8bitNeuQuantFileName = baseName + "_8bit_NeuQuant.png";

        // Save to PNG
        using (var bitmap = new Bitmap(sourceFileName))
        {
            bitmap.ColorManagement.Palette = new ColorPalette(ColorPaletteType.NeuQuant);
            bitmap.ColorManagement.Convert(PixelFormat.Format8bppIndexed);

            bitmap.Save(png8bitNeuQuantFileName, new PngSettings(true));
        }

        long png8bitNeuQuantFileSize = new System.IO.FileInfo(png8bitNeuQuantFileName).Length;

        Console.WriteLine("PNG 8-bit (NeuQaunt, with alpha transparency):");
        Console.WriteLine("  {0}", png8bitNeuQuantFileName);
        Console.WriteLine("  {0:f2} KB ({1:f2}%)", (float)png8bitNeuQuantFileSize / 1024f, (float)png8bitNeuQuantFileSize / (float)sourceFileSize * 100f);
    }
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
        <file>Stamp.png</file>
      </in_preview>
      <out_preview>
        <file>PngNeuQuant.txt</file>
        <file>Chicago_24bit.png</file>
        <file>Chicago_8bit.png</file>
        <file>Chicago_8bit_NeuQuant.png</file>
        <file>Stamp_24bit.png</file>
        <file>Stamp_8bit.png</file>
        <file>Stamp_8bit_NeuQuant.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Interoperability/SystemDrawingInteroperability/PreserveColorProfileAndMetadata.cs">
    <title>Preserve Color Profile And Metadata (System.Drawing Interop)</title>
    <description>Converts Aurigma.GraphicsMill.Bitmap to System.Drawing.Bitmap and vice versa preserving metadata.</description>
    <instruction>Write a C# program that demonstrates interoperability between Aurigma.GraphicsMill.Bitmap and System.Drawing.Bitmap while preserving color profile and metadata by loading JPEG via JpegReader, casting GraphicsMill Bitmap to System.Drawing.Bitmap for legacy processing (watermark application), casting back to GraphicsMill Bitmap, manually copying ColorProfile, and copying all metadata (EXIF, IPTC, XMP, AdobeResources) to JpegWriter before saving via Pipeline to maintain image integrity during format transitions.</instruction>
    <output><![CDATA[Below is a C# code sample that shows System.Drawing interop with metadata preservation:

The code demonstrates seamless integration between GraphicsMill and legacy System.Drawing applications by direct casting between Bitmap types to preserve pixel data without copying, manually transferring ColorProfile after round-trip processing, and explicitly copying comprehensive metadata sets (EXIF, IPTC, XMP, AdobeResources) to JpegWriter. This pattern enables integration with existing System.Drawing-based watermarking or effects libraries while maintaining professional image quality, color accuracy via ICC profiles, and complete metadata preservation essential for photography and publishing workflows.]]></output>
    <tags>
      <tag id="interoperability" title="Interoperability" description="Interop with GDI+ and other libraries" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
      <tag id="metadata" title="Metadata" description="Reading and writing image metadata" />
      <tag id="color-profile" title="Color Profile" description="Using ICC color profiles" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[// Imagine that you have a legacy application which works with System.Drawing.Bitmap,
// and you want to integrate it with Graphics Mill, and you want to preserve metadata and color profile
using (var reader = new JpegReader("Copenhagen_RGB.jpg"))
using (var gmBitmap1 = reader.Frames[0].GetBitmap())
using (var sdBitmap = (System.Drawing.Bitmap)gmBitmap1)
{
    // Here we modify System.Drawing.Bitmap
    Utils.ApplyWatermark(sdBitmap);

    // To copy pixels, just cast your System.Drawing.Bitmap to Aurigma.GraphicsMill.Bitmap.
    using (var gmBitmap2 = (Bitmap)sdBitmap)
    {
        // Copy color profile
        gmBitmap2.ColorProfile = gmBitmap1.ColorProfile;

        using (var writer = new JpegWriter("PreserveColorProfileAndMetadata.jpg"))
        {
            // Copy metadata
            writer.Exif = reader.Exif;
            writer.Iptc = reader.Iptc;
            writer.Xmp = reader.Xmp;
            writer.AdobeResources = reader.AdobeResources;

            Pipeline.Run(gmBitmap2 + writer);
        }
    }
}]]></code>
    <io>
      <in_preview>
        <file>Copenhagen_RGB.jpg</file>
      </in_preview>
      <out_preview>
        <file>PreserveColorProfileAndMetadata.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="ColorManagement/RGBToCMYK/PreviewRgbToCmykOnScreen.cs">
    <title>Preview RGB To CMYK On Screen</title>
    <description>Generates an RGB preview of CMYK color conversion.</description>
    <instruction>Simulates how an RGB image would appear when printed in CMYK by performing a soft-proofing conversion.</instruction>
    <output><![CDATA[The code:

- Loads "Copenhagen_RGB.jpg" into a `Bitmap`.
- Assigns the sRGB color profile if none is embedded.
- Sets a target device profile (e.g., "ISOcoated_v2_eci.icc") to simulate a CMYK press condition.
- Sets the destination profile to `ColorProfile.FromScreen()` to display the result as it would appear on screen.
- Converts the image to 24bpp RGB using soft-proofing (via `TargetDeviceProfile`).
- Saves the soft-proofed image to "PreviewRgbToCmykOnScreen.jpg".]]></output>
    <tags>
      <tag id="color-management" title="Color Management" description="Color management with ICC profiles" />
      <tag id="color-conversion" title="Color Conversion" description="Converting colors between color spaces" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Copenhagen_RGB.jpg"))
{
    if (bitmap.ColorProfile == null)
    {
        bitmap.ColorProfile = ColorProfile.FromSrgb();
    }

    bitmap.ColorManagement.TargetDeviceProfile = new ColorProfile("ISOcoated_v2_eci.icc");
    bitmap.ColorManagement.DestinationProfile = ColorProfile.FromScreen();

    bitmap.ColorManagement.Convert(PixelFormat.Format24bppRgb);

    bitmap.Save("PreviewRgbToCmykOnScreen.jpg");
}]]></code>
    <io>
      <in_preview>
        <file>Copenhagen_RGB.jpg</file>
      </in_preview>
      <in_download>
        <file>ISOcoated_v2_eci.icc</file>
      </in_download>
      <out_preview>
        <file>PreviewRgbToCmykOnScreen.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="ColorManagement/RGBToCMYK/PreviewRgbToCmykOnScreenMemoryFriendly.cs">
    <title>Preview RGB To CMYK On Screen (Memory Friendly)</title>
    <description>Generates an RGB preview of CMYK color conversion using memory-friendly Pipeline API.</description>
    <instruction>Performs soft-proofing to preview how an RGB image will appear when printed in CMYK, using the memory-friendly Pipeline API.</instruction>
    <output><![CDATA[The code:

- Creates a pipeline that loads "Copenhagen_RGB.jpg" and writes to "PreviewRgbToCmykOnScreenMemoryFriendly.jpg".
- Sets `DefaultSourceProfile` to sRGB in case the image lacks an embedded profile.
- Assigns a `TargetDeviceProfile` (e.g., "ISOcoated_v2_eci.icc") to simulate printing conditions.
- Sets the `DestinationProfile` to `ColorProfile.FromScreen()` to preview the CMYK result on a monitor.
- Uses perceptual rendering intent for smoother color transitions.
- Converts the image to 24bpp RGB with simulated CMYK appearance using `ColorConverter`.]]></output>
    <tags>
      <tag id="color-management" title="Color Management" description="Color management with ICC profiles" />
      <tag id="color-conversion" title="Color Conversion" description="Converting colors between color spaces" />
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[using (var reader = ImageReader.Create("Copenhagen_RGB.jpg"))
using (var converter = new ColorConverter())
using (var writer = ImageWriter.Create("PreviewRgbToCmykOnScreenMemoryFriendly.jpg"))
{
    converter.DestinationPixelFormat = PixelFormat.Format24bppRgb;
    converter.DefaultSourceProfile = ColorProfile.FromSrgb();
    converter.TargetDeviceProfile = new ColorProfile("ISOcoated_v2_eci.icc");
    converter.DestinationProfile = ColorProfile.FromScreen();
    converter.TransformationIntent = ColorTransformationIntent.Perceptual;

    Pipeline.Run(reader + converter + writer);
}]]></code>
    <io>
      <in_preview>
        <file>Copenhagen_RGB.jpg</file>
      </in_preview>
      <in_download>
        <file>ISOcoated_v2_eci.icc</file>
      </in_download>
      <out_preview>
        <file>PreviewRgbToCmykOnScreenMemoryFriendly.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Metadata/EXIFAndIPTC/ProcessComplexExifTypes.cs">
    <title>Process Complex EXIF Types</title>
    <description>Reads and writes complex EXIF tags.</description>
    <instruction>Modify EXIF data of a JPEG image, specifically GPS latitude and version information, and save the updated image with the new EXIF metadata.</instruction>
    <output><![CDATA[The code:

- Reads the input JPEG image.
- Retrieves and modifies the EXIF data, including setting a new GPS latitude and version information.
- Updates the EXIF metadata to include "Aurigma Graphics Mill" in the Software field.
- Saves the modified image with the updated EXIF metadata to the specified output file.]]></output>
    <tags>
      <tag id="exif" title="EXIF" description="Managing EXIF metadata" />
      <tag id="read" title="Read" description="Reading images with codecs" />
      <tag id="write" title="Write" description="Writing images with codecs" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var jpegReader = new JpegReader("Chicago.jpg"))
using (var jpegWriter = new JpegWriter("ProcessComplexExifTypes.jpg", 70))
{
    var exif = new ExifDictionary(jpegReader.Exif);

    object[] latitude = null;

    if (exif.Contains(ExifDictionary.GpsLatitude))
    {
        latitude = exif.GetItemArray(ExifDictionary.GpsLatitude);
        latitude[0] = new UnsignedRational(113, 12);
    }
    else
    {
        // Alexandria, Virginia
        latitude = new object[] { new UnsignedRational(38, 1), new UnsignedRational(48, 1), new UnsignedRational(17, 1) };
    }

    exif.SetItemArray(ExifDictionary.GpsLatitude, latitude);

    var gpsVer = new object[] { (byte)2, (byte)0, (byte)0, (byte)1 };
    exif.SetItemArray(ExifDictionary.GpsVersionId, gpsVer);

    exif[ExifDictionary.Software] = "Aurigma Graphics Mill";
    jpegWriter.Exif = exif;

    Pipeline.Run(jpegReader + jpegWriter);
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_download>
        <file>WriteExifIptcMemoryFriendly.jpg</file>
      </out_download>
    </io>
  </sample>
  <sample path="Interoperability/SystemDrawingInteroperability/ProcessNonRgb.cs">
    <title>Process Non-RGB (System.Drawing Interop)</title>
    <description>Loads non-RGB image with Aurigma.GraphicsMill.Bitmap, pass it to System.Drawing.Bitmap and
convert it back to Aurigma.GraphicsMill.Bitmap.</description>
    <instruction>Write a C# program that processes non-RGB images (CMYK "Copenhagen_CMYK.jpg") for System.Drawing interop by converting to RGB (Format24bppRgb) with sRGB destination profile using ColorManagement.Convert, casting to System.Drawing.Bitmap for legacy processing (watermark), converting back to original CMYK format with source ColorProfile, preserving all metadata (EXIF, IPTC, XMP, AdobeResources), and saving via JpegWriter while properly managing temporary RGB bitmap disposal.</instruction>
    <output><![CDATA[Below is a C# code sample that enables System.Drawing processing of non-RGB images:

The code demonstrates round-trip color space conversion for System.Drawing compatibility: CMYK→sRGB RGB (24bpp) for casting to System.Drawing.Bitmap, legacy processing, then RGB→original CMYK using source ColorProfile for accurate color fidelity. It uses conditional ColorManagement.Convert pipelines with explicit DestinationProfile assignments, preserves original ColorProfile on return conversion, manually copies comprehensive metadata to JpegWriter, and implements defensive resource management with try-finally for temporary RGB bitmap disposal. This pattern enables legacy System.Drawing integration with CMYK/print workflows while maintaining color accuracy and metadata integrity.]]></output>
    <tags>
      <tag id="interoperability" title="Interoperability" description="Interop with GDI+ and other libraries" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
      <tag id="metadata" title="Metadata" description="Reading and writing image metadata" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[// Imagine that you have a legacy application which works with System.Drawing.Bitmap,
// and you need to work with non-RGB images. You should convert it to RGB with Graphics Mill, cast it
// to System.Drawing.Bitmap and convert back.
using (var reader = new JpegReader("Copenhagen_CMYK.jpg"))
using (var gmBitmap1 = reader.Frames[0].GetBitmap())
{
    Bitmap rgbGmBitmap = null;

    try
    {
        // Convert a non-RGB image to the RGB color space with the sRGB color profile
        if (!gmBitmap1.PixelFormat.IsRgb)
        {
            rgbGmBitmap = new Bitmap(gmBitmap1);
            rgbGmBitmap.ColorManagement.DestinationProfile = ColorProfile.FromSrgb();
            rgbGmBitmap.ColorManagement.Convert(PixelFormat.Format24bppRgb);
        }

        using (var sdBitmap = (System.Drawing.Bitmap)(gmBitmap1.PixelFormat.IsRgb ? gmBitmap1 : rgbGmBitmap))
        {
            // Here we modify System.Drawing.Bitmap
            Utils.ApplyWatermark(sdBitmap);

            using (var gmBitmap2 = (Bitmap)sdBitmap)
            {
                // Convert an RGB image to the source color space (CMYK, grayscale, or Lab)
                if (!gmBitmap1.PixelFormat.IsRgb)
                {
                    gmBitmap2.ColorProfile = ColorProfile.FromSrgb();
                    gmBitmap2.ColorManagement.DestinationProfile = gmBitmap1.ColorProfile;
                    gmBitmap2.ColorManagement.Convert(gmBitmap1.PixelFormat);
                }

                // Copy color profile
                gmBitmap2.ColorProfile = gmBitmap1.ColorProfile;

                using (var writer = new JpegWriter("ProcessNonRgb.jpg"))
                {
                    // Copy metadata
                    writer.Exif = reader.Exif;
                    writer.Iptc = reader.Iptc;
                    writer.Xmp = reader.Xmp;
                    writer.AdobeResources = reader.AdobeResources;

                    Pipeline.Run(gmBitmap2 + writer);
                }
            }
        }
    }
    finally
    {
        if (rgbGmBitmap != null)
        {
            rgbGmBitmap.Dispose();
        }
    }
}]]></code>
    <io>
      <in_preview>
        <file>Copenhagen_CMYK.jpg</file>
      </in_preview>
      <out_preview>
        <file>ProcessNonRgb.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/Jpeg/ReadAndWriteJpeg.cs">
    <title>Read and Write JPEG</title>
    <description>Reads and writes image in JPEG format.</description>
    <instruction>Write a C# program that loads a JPEG image, vertically flips it, and saves it using high-quality JPEG encoding settings including 90% quality, no chroma subsampling, and progressive mode enabled.</instruction>
    <output><![CDATA[Here is a C# program that reads a JPEG image, flips it vertically, and saves it as a new JPEG file with specific compression settings:

This code loads an input JPEG file, applies a vertical flip, and saves it as an output JPEG using 90% quality, progressive encoding, and no chroma subsampling.]]></output>
    <tags>
      <tag id="jpg" title="JPG" description="Reading and writing JPEG images" />
      <tag id="read" title="Read" description="Reading images with codecs" />
      <tag id="write" title="Write" description="Writing images with codecs" />
      <tag id="filesystem" title="Filesystem" description="Loading and saving images from files" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Chicago.jpg"))
{
    bitmap.Transforms.Flip(FlipType.Vertical);

    var jpegSettings = new JpegSettings()
    {
        Quality = 90,
        UseSubsampling = false,
        IsProgressive = true,
    };

    bitmap.Save("ReadWriteJpeg.jpg", jpegSettings);
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>ReadWriteJpeg.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/Gif/ReadAnimatedGif.cs">
    <title>Read Animated Gif</title>
    <description>Reads frames of animated image in GIF format.</description>
    <instruction>Read all frames of an animated GIF image and save each frame as a separate GIF file.</instruction>
    <output><![CDATA[Here is a C# program that loads an animated GIF and extracts each frame into its own separate file:

This code reads `AnimatedGIF.gif`, iterates through all frames, and saves each one as `ReadAnimatedGif_0.gif`, `ReadAnimatedGif_1.gif`, etc. It demonstrates how to access and export individual frames from an animated image without using the Pipeline API.]]></output>
    <tags>
      <tag id="gif" title="GIF" description="Reading, writing and animating GIFs" />
      <tag id="filesystem" title="Filesystem" description="Loading and saving images from files" />
      <tag id="multi-frame" title="Multiple frames" description="Handling multi-frame image formats" />
      <tag id="read" title="Read" description="Reading images with codecs" />
      <tag id="write" title="Write" description="Writing images with codecs" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var reader = new GifReader("AnimatedGIF.gif"))
{
    for (int i = 0; i < reader.Frames.Count; i++)
    {
        using (var bitmap = reader.Frames[i].GetBitmap())
        {
            bitmap.Save("ReadAnimatedGif_" + i + ".gif");
        }
    }
}]]></code>
    <io>
      <in_preview>
        <file>AnimatedGIF.gif</file>
      </in_preview>
      <out_preview>
        <file>ReadAnimatedGif_0.gif</file>
        <file>ReadAnimatedGif_1.gif</file>
        <file>ReadAnimatedGif_2.gif</file>
        <file>ReadAnimatedGif_3.gif</file>
        <file>ReadAnimatedGif_4.gif</file>
        <file>ReadAnimatedGif_5.gif</file>
        <file>ReadAnimatedGif_6.gif</file>
        <file>ReadAnimatedGif_7.gif</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Metadata/ClippingPath/ReadClippingPathFlatness.cs">
    <title>Read Clipping Path Flatness</title>
    <description>Read a TIFF image that contains an Adobe resource block for clipping paths, retrieve and display the clipping path name and flatness.</description>
    <instruction>Read a TIFF image that contains an Adobe resource block for clipping paths, retrieve and display the clipping path name and flatness value.</instruction>
    <output><![CDATA[The code:

- Reads the "TIFFWithClippingPath.tif" image.
- Extracts the clipping path from the Adobe resources using the specified key (0x0bb7).
- Displays the clipping path name and the flatness value, which is a fixed point number extracted from the Adobe resource block.]]></output>
    <tags>
      <tag id="read" title="Read" description="Reading images with codecs" />
      <tag id="metadata" title="Metadata" description="Reading and writing image metadata" />
      <tag id="clipping-paths" title="Clipping Paths" description="Reading and writing Adobe resources clipping path" />
    </tags>
    <usings><![CDATA[using System;
using System.Linq;
using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var reader = new TiffReader("TIFFWithClippingPath.tif"))
{
    const int clippingPathKey = 0x0bb7;

    if (reader.AdobeResources.Contains(clippingPathKey))
    {
        var arb = (AdobeResourceBlock)reader.AdobeResources[clippingPathKey];

        byte nameSize = arb.Data[0];

        Console.WriteLine($"Clipping path name: {System.Text.Encoding.UTF8.GetString(arb.Data.Skip(1).Take(nameSize).ToArray())}");

        // Flatness is a fixed point value in format 8p16: one byte for integer and 2 bytes for fractional.
        float flatness = (float)arb.Data[nameSize + 2] + ((float)(arb.Data[nameSize + 3] << 8 | arb.Data[nameSize + 4]) / ushort.MaxValue);

        Console.WriteLine($"Flatness: {flatness}");
    }
}]]></code>
    <io>
      <in_download>
        <file>TIFFWithClippingPath.tif</file>
      </in_download>
      <out_preview>
        <file>ReadClippingPathFlatness.txt</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/Tga/ReadConvertAndWriteTga.cs">
    <title>Read Convert And Write TGA</title>
    <description>Reads image in TARGA 24 format and saves to TARGA 16 format with RLE compression.</description>
    <instruction>Write a C# program that reads a TGA image file "WriteTga.tga" using TgaReader, converts it to 16-bit format with RLE compression using TgaWriter settings, and saves it as "ReadConvertAndWriteTga.tga" using the Pipeline API.</instruction>
    <output><![CDATA[Below is a C# code sample that reads a TGA image, converts it to 16-bit format with RLE compression, and saves it to a new file:

The code demonstrates reading a TGA image using TgaReader, configuring TgaWriter with RLE compression (CompressionType.Rle) and reduced precision (16-bit format), then processing the conversion through GraphicsMill's Pipeline API for efficient memory usage and format conversion.]]></output>
    <tags>
      <tag id="tga" title="TGA" description="Reading and writing TGA images" />
      <tag id="format-conversion" title="Format Conversion" description="Converting images between formats" />
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var reader = new TgaReader("WriteTga.tga"))
using (var writer = new TgaWriter("ReadConvertAndWriteTga.tga"))
{
    writer.Compression = CompressionType.Rle;
    writer.ReducedPrecision = true;

    Pipeline.Run(reader + writer);
}]]></code>
    <io>
      <in_download>
        <file>WriteTga.tga</file>
      </in_download>
      <out_download>
        <file>ReadConvertAndWriteTga.tga</file>
      </out_download>
    </io>
  </sample>
  <sample path="Metadata/EXIFAndIPTC/ReadExifIptc.cs">
    <title>Read EXIF and IPTC</title>
    <description>Reads EXIF and IPTC metadata.</description>
    <instruction>Read and display EXIF and IPTC metadata from a JPEG image, printing all available tags and their values to the console.</instruction>
    <output><![CDATA[The code:

- Reads the input JPEG image and extracts its EXIF and IPTC metadata.
- Displays the EXIF tags and their descriptions along with the values in the console.
- Displays the IPTC tags and their descriptions along with the values in the console.]]></output>
    <tags>
      <tag id="exif" title="EXIF" description="Managing EXIF metadata" />
      <tag id="iptc" title="IPTC" description="Managing IPTC metadata" />
      <tag id="read" title="Read" description="Reading images with codecs" />
    </tags>
    <usings><![CDATA[using System;
using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var jpegReader = new JpegReader("Chicago.jpg"))
{
    // Read metadata
    var exif = jpegReader.Exif;
    var iptc = jpegReader.Iptc;

    // Show EXIF tags
    if (exif != null)
    {
        Console.WriteLine("EXIF");
        Console.WriteLine("---------------");
        foreach (object key in exif.Keys)
        {
            Console.WriteLine("{0}: {1}, {2}", exif.GetKeyDescription(key), exif[key], exif.GetItemString(key));
        }
    }

    // Show IPTC tags
    if (iptc != null)
    {
        Console.WriteLine("IPTC");
        Console.WriteLine("---------------");
        foreach (long key in iptc.Keys)
        {
            Console.WriteLine("{0}: {1}, {2}", iptc.GetKeyDescription(key), iptc[key], iptc.GetItemString(key));
        }
    }
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>ReadExifIptc.txt</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/Tiff/ReadExtraChannelFromTiff.cs">
    <title>Read Extra Channel From TIFF</title>
    <description>Reads a extra channel from a TIFF file and saves it as a new TIFF image.</description>
    <instruction>Write a C# program that reads a TIFF image, extracts an extra channel, and saves it as a new TIFF image.</instruction>
    <output><![CDATA[Below is a C# code sample that demonstrates how to read a TIFF image, extract an extra channel, and save it as a new TIFF image.

This code reads a TIFF image, retrieves the extra channel from the first frame, and saves the extracted bitmap to a new TIFF file.]]></output>
    <tags>
      <tag id="tiff" title="TIFF" description="Reading and writing TIFF images" />
      <tag id="extra-channels" title="Extra Channels" description="Working with TIFF extra channels" />
      <tag id="read" title="Read" description="Reading images with codecs" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var reader = new TiffReader("CopenhagenWithExtraChannel.tif"))
{
    var bitmap = reader.Frames[0].ExtraChannels[0].GetBitmap();

    bitmap.Save("BusinessCard_ReadExtra.tif");
}]]></code>
    <io>
      <in_download>
        <file>CopenhagenWithExtraChannel.tif</file>
      </in_download>
      <out_download>
        <file>BusinessCard_ReadExtra.tif</file>
      </out_download>
    </io>
  </sample>
  <sample path="Codecs/LoadingAndSavingImages/ReadImageMetadata.cs">
    <title>Read Image Metadata</title>
    <description>Reads image metadata without loading bitmap data.</description>
    <instruction>Write a C# program that reads metadata (EXIF, IPTC) from an image file without loading the bitmap data.</instruction>
    <output><![CDATA[Below is a C# code sample that demonstrates how to read the metadata (EXIF, IPTC) from an image file without loading the bitmap data:

This example efficiently accesses image metadata properties such as width, height, and pixel format, as well as EXIF and IPTC tags, without actually loading the image data into memory.]]></output>
    <tags>
      <tag id="jpg" title="JPG" description="Reading and writing JPEG images" />
      <tag id="read" title="Read" description="Reading images with codecs" />
      <tag id="metadata" title="Metadata" description="Reading and writing image metadata" />
      <tag id="filesystem" title="Filesystem" description="Loading and saving images from files" />
    </tags>
    <usings><![CDATA[using System;
using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var reader = ImageReader.Create("Chicago.jpg"))
{
    Console.WriteLine("Width: {0}", reader.Width);
    Console.WriteLine("Height: {0}", reader.Height);
    Console.WriteLine("Pixel format: {0}", reader.PixelFormat);

    if (reader.Exif != null)
    {
        Console.WriteLine("EXIF tag count: {0}", reader.Exif.Count);
    }

    if (reader.Iptc != null)
    {
        Console.WriteLine("IPTC tag count: {0}", reader.Iptc.Count);
    }
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>ReadImageMetadata.txt</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/CustomCodecs/ReadImageWithWPF.cs">
    <title>Read image with WPF</title>
    <description>Demonstrates passing an image to a pipeline with the custom image reader.</description>
    <instruction>Demonstrate how to pass an image to a pipeline using a custom image reader.</instruction>
    <output><![CDATA[Here is a C# program that utilizes a custom image reader to pass an image into the memory-friendly Pipeline API for processing:

This code defines `WpfImageReader`, a custom image reader that extracts metadata and image properties from a WPF `BitmapSource`. The `ReadImageWithWPF.Run()` method reads an HEIC image, extracts EXIF metadata, and writes it to a TIFF file using the Pipeline API.]]></output>
    <tags>
      <tag id="read" title="Read" description="Reading images with codecs" />
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
      <tag id="metadata" title="Metadata" description="Reading and writing image metadata" />
      <tag id="tiff" title="TIFF" description="Reading and writing TIFF images" />
      <tag id="write" title="Write" description="Writing images with codecs" />
      <tag id="format-conversion" title="Format Conversion" description="Converting images between formats" />
      <tag id="wpf" title="WPF" description="Interoperability and conversion with WPF images" />
      <tag id="stream" title="Stream" description="Reading and writing images from streams" />
    </tags>
    <usings><![CDATA[using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[public sealed class WpfImageReader : IImageReader, IImageParams
{
    private readonly BitmapSource bitmapSource;

    public WpfImageReader(System.IO.Stream stream)
    {
        this.bitmapSource = BitmapFrame.Create(stream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.OnLoad);

        if (this.bitmapSource.Metadata is BitmapMetadata metadata)
        {
            this.Exif = new ExifDictionary();
            this.CaptureMetadata(metadata, string.Empty);
        }
    }

    public Aurigma.GraphicsMill.Ink Ink => null;

    public ColorPalette Palette => null;

    public ColorProfile ColorProfile => null;

    public float DpiX
    {
        get
        {
            return (float)this.bitmapSource.DpiX;
        }
    }

    public float DpiY
    {
        get
        {
            return (float)this.bitmapSource.DpiY;
        }
    }

    public PixelFormat PixelFormat
    {
        get
        {
            return ConvertFormat(this.bitmapSource.Format);
        }
    }

    public int Height
    {
        get
        {
            return this.bitmapSource.PixelHeight;
        }
    }

    public int Width
    {
        get
        {
            return this.bitmapSource.PixelWidth;
        }
    }

    public ExifDictionary Exif { get; private set; }

    public ImageParams GetImageParams()
    {
        return ImageParams.Create(this);
    }

    public Bitmap GetStripe(int stripeY, int stripeHeight)
    {
        // In production, it makes sense to consider more sophisticated logic
        // for disposing stripe bitmaps. The possible approach is to dispose
        // the previous stripe with generating the next one.
        var stripe = new Bitmap(this.Width, stripeHeight, this.PixelFormat);

        stripe.DpiX = this.DpiX;
        stripe.DpiY = this.DpiY;

        this.bitmapSource.CopyPixels(new System.Windows.Int32Rect(0, stripeY, stripe.Width, stripe.Height), stripe.Scan0, stripe.Stride * stripe.Height, stripe.Stride);

        return stripe;
    }

    /// <summary>
    /// Converts WPF pixel format to corresponding one for Graphics Mill.
    /// </summary>
    private static PixelFormat ConvertFormat(System.Windows.Media.PixelFormat format)
    {
        var dict = new Dictionary<System.Windows.Media.PixelFormat, Aurigma.GraphicsMill.PixelFormat>
        {
            { System.Windows.Media.PixelFormats.Bgr24, Aurigma.GraphicsMill.PixelFormat.Format24bppRgb },
            { System.Windows.Media.PixelFormats.Bgr32, Aurigma.GraphicsMill.PixelFormat.Format32bppRgb },
            { System.Windows.Media.PixelFormats.Bgra32, Aurigma.GraphicsMill.PixelFormat.Format32bppArgb },
            { System.Windows.Media.PixelFormats.Gray8, Aurigma.GraphicsMill.PixelFormat.Format8bppGrayscale },
            { System.Windows.Media.PixelFormats.Gray16, Aurigma.GraphicsMill.PixelFormat.Format16bppGrayscale },
        };

        if (!dict.ContainsKey(format))
        {
            throw new Aurigma.GraphicsMill.UnsupportedPixelFormatException();
        }

        return dict[format];
    }

    private static UnsignedRational ToRational(ulong value)
    {
        var firstHalf = (uint)(value >> 32);
        var secondHalf = (uint)(value & 0xffffffff);

        return new UnsignedRational(firstHalf, secondHalf);
    }

    private static Rational ToRational(long value)
    {
        var firstHalf = (int)(value >> 32);
        var secondHalf = (int)(value & 0xffffffff);

        return new Rational(firstHalf, secondHalf);
    }

    private void WriteTag(long tag, object value)
    {
        if (this.Exif.Contains(tag))
        {
            return;
        }

        if (value is byte)
        {
            this.Exif.Add(tag, (byte)value);
        }
        else if (value is long)
        {
            this.Exif.Add(tag, ToRational((long)value));
        }
        else if (value is ulong)
        {
            this.Exif.Add(tag, ToRational((ulong)value));
        }
        else if (value is ushort)
        {
            this.Exif.Add(tag, (ushort)value);
        }
        else if (value is short)
        {
            this.Exif.Add(tag, (short)value);
        }
        else if (value is string)
        {
            this.Exif.Add(tag, value as string);
        }
        else if (value is ulong[])
        {
            var data = value as ulong[];
            this.Exif.Add(tag, new UnsignedRational[] { ToRational(data[0]), ToRational(data[1]), ToRational(data[2]) });
        }
        else if (value is long[])
        {
            var data = value as long[];
            this.Exif.Add(tag, new Rational[] { ToRational(data[0]), ToRational(data[1]), ToRational(data[2]) });
        }
        else
        {
            const long exifTagUserComment = 0x9286;
            if (tag == exifTagUserComment)
            {
                var blob = value as BitmapMetadataBlob;
                this.Exif.Add(tag, blob.GetBlobValue());
            }
        }
    }

    private void CaptureMetadata(BitmapMetadata metadata, string query)
    {
        foreach (var relativeQuery in metadata)
        {
            var queryReader = metadata.GetQuery(relativeQuery);

            if (queryReader is BitmapMetadata innerMetadata)
            {
                this.CaptureMetadata(innerMetadata, query + relativeQuery);
            }
            else if (query.Contains("app1") || query.Contains("ifd"))
            {
                var m = Regex.Match(relativeQuery, @"\d+");
                if (m.Length == 0)
                {
                    continue;
                }

                var tag = long.Parse(m.Value);
                WriteTag(tag, queryReader);
            }
        }
    }

    internal class ReadImageWithWPF
    {
        public static void Run()
        {
            using (var fs = new FileStream("IMG_4212.HEIC", FileMode.Open, FileAccess.Read))
            using (var reader = new CustomImageReader(new WpfImageReader(fs)))
            using (var writer = new TiffWriter("ReadImageWithWPF.tif"))
            {
                var wpfReader = (WpfImageReader)reader.InternalImageReader;
                if (wpfReader.Exif != null)
                {
                    writer.Exif = wpfReader.Exif;

                    foreach (object key in wpfReader.Exif.Keys)
                    {
                        Console.WriteLine("{0}: {1}, {2}", wpfReader.Exif.GetKeyDescription(key), wpfReader.Exif[key], wpfReader.Exif.GetItemString(key));
                    }
                }

                Pipeline.Run(reader + writer);
            }
        }
    }
}]]></code>
    <io>
      <in_download>
        <file>IMG_4212.HEIC</file>
      </in_download>
      <out_preview>
        <file>ReadImageWithWPF.txt</file>
      </out_preview>
      <out_download>
        <file>ReadImageWithWPF.tif</file>
      </out_download>
    </io>
  </sample>
  <sample path="Codecs/Tiff/ReadMultiframeTiff.cs">
    <title>Read Multiframe TIFF</title>
    <description>Reads multiframe image in TIFF format.</description>
    <instruction>Write a C# program that reads a multi-frame TIFF image and saves each frame as a separate JPEG image.</instruction>
    <output><![CDATA[Below is a C# code sample that demonstrates how to read each frame from a multi-frame TIFF image and save them individually as JPEG files.

This code iterates over all the frames in the TIFF file, converts each frame to a bitmap, and saves them as separate JPEG images with indexed filenames.]]></output>
    <tags>
      <tag id="tiff" title="TIFF" description="Reading and writing TIFF images" />
      <tag id="multi-frame" title="Multiple frames" description="Handling multi-frame image formats" />
      <tag id="read" title="Read" description="Reading images with codecs" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var reader = new TiffReader("WriteMultiframeTiff.tif"))
{
    for (int i = 0; i < reader.Frames.Count; i++)
    {
        using (var bitmap = reader.Frames[i].GetBitmap())
        {
            bitmap.Save("ReadMultiframeTiff_" + i + ".jpg");
        }
    }
}]]></code>
    <io>
      <in_download>
        <file>WriteMultiframeTiff.tif</file>
      </in_download>
      <out_preview>
        <file>ReadMultiframeTiff_0.jpg</file>
        <file>ReadMultiframeTiff_1.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/Tiff/ReadMultiframeTiffMemoryFriendly.cs">
    <title>Read Multiframe TIFF Memory Friendly</title>
    <description>Reads multiframe image in TIFF format using memory-friendly Pipeline API.</description>
    <instruction>Write a memory-friendly C# program using the Pipeline API that reads a multi-frame TIFF image and saves each frame as a separate JPEG image.</instruction>
    <output><![CDATA[Below is a C# code snippet that uses the memory-efficient Pipeline API to read each frame of a multi-frame TIFF and save it as an individual JPEG file.

This code avoids loading the full image into memory by streaming each frame from the TIFF directly into a JPEG file.]]></output>
    <tags>
      <tag id="tiff" title="TIFF" description="Reading and writing TIFF images" />
      <tag id="multi-frame" title="Multiple frames" description="Handling multi-frame image formats" />
      <tag id="read" title="Read" description="Reading images with codecs" />
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var reader = new TiffReader("WriteMultiframeTiff.tif"))
{
    for (int i = 0; i < reader.Frames.Count; i++)
    {
        using (var writer = new JpegWriter("ReadMultiframeTiffMemoryFriendly_" + i + ".jpg"))
        {
            Pipeline.Run(reader.Frames[i] + writer);
        }
    }
}]]></code>
    <io>
      <in_download>
        <file>WriteMultiframeTiff.tif</file>
      </in_download>
      <out_preview>
        <file>ReadMultiframeTiffMemoryFriendly_0.jpg</file>
        <file>ReadMultiframeTiffMemoryFriendly_1.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/RAW/ReadRaw.cs">
    <title>Read RAW Image</title>
    <description>Reads RAW image.</description>
    <instruction>Write a C# program that reads a raw image file (e.g., ARW format) and saves it as a JPEG image.</instruction>
    <output><![CDATA[Below is a C# code sample that demonstrates how to read a raw image file (e.g., ARW format) and save it as a JPEG image:

This code reads an ARW image and saves it as a JPEG file.]]></output>
    <tags>
      <tag id="jpg" title="JPG" description="Reading and writing JPEG images" />
      <tag id="raw" title="RAW" description="Processing camera RAW images" />
      <tag id="format-conversion" title="Format Conversion" description="Converting images between formats" />
    </tags>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("DSC02363.ARW"))
{
    bitmap.Save("ReadRaw.jpg");
}]]></code>
    <io>
      <in_download>
        <file>DSC02363.ARW</file>
      </in_download>
      <out_preview>
        <file>ReadRaw.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/Tiff/ReadTiff.cs">
    <title>Read TIFF</title>
    <description>Reads first frame of image in TIFF format.</description>
    <instruction>Read the first frame of a TIFF image and save it as a JPEG using C#.</instruction>
    <output><![CDATA[The following code snippet reads only the first frame of a multi-frame TIFF file and saves it as a JPEG:

This method loads the image into memory and is suitable when only the first frame is needed.]]></output>
    <tags>
      <tag id="tiff" title="TIFF" description="Reading and writing TIFF images" />
      <tag id="read" title="Read" description="Reading images with codecs" />
      <tag id="format-conversion" title="Format Conversion" description="Converting images between formats" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("WriteMultiframeTiff.tif"))
{
    bitmap.Save("ReadTiff.jpg");
}]]></code>
    <io>
      <in_download>
        <file>WriteMultiframeTiff.tif</file>
      </in_download>
      <out_download>
        <file>ReadTiff.jpg</file>
      </out_download>
    </io>
  </sample>
  <sample path="Metadata/XMP/ReadXmpMetadata.cs">
    <title>Read XMP Metadata</title>
    <description>Reads all XMP properties.</description>
    <instruction>Extract and display XMP metadata from a JPEG image.</instruction>
    <output><![CDATA[The code:

- Reads the XMP metadata from the input JPEG image.
- Iterates through each node in the XMP data and prints the name and value for nodes of type SimpleProperty.]]></output>
    <tags>
      <tag id="xmp" title="XMP" description="Managing XMP metadata" />
      <tag id="read" title="Read" description="Reading images with codecs" />
    </tags>
    <usings><![CDATA[using System;
using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var reader = new JpegReader("Chicago.jpg"))
{
    if (reader.Xmp != null)
    {
        var xmp = new XmpData(reader.Xmp);

        foreach (XmpNode node in xmp.Values)
        {
            if (node.NodeType == XmpNodeType.SimpleProperty)
            {
                Console.WriteLine("{0}: {1}", node.Name, node);
            }
        }
    }
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>ReadXmpMetadata.txt</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Metadata/XMP/ReadXmpProperty.cs">
    <title>Read XMP Property</title>
    <description>Reads specific XMP property.</description>
    <instruction>Extract and display the creation date from XMP metadata in a JPEG image.</instruction>
    <output><![CDATA[The code:

- Reads the XMP metadata from the input JPEG image.
- If the XMP data contains the `xmp:XmpCreateDate` tag, it prints the value associated with this tag, which indicates the creation date.]]></output>
    <tags>
      <tag id="xmp" title="XMP" description="Managing XMP metadata" />
      <tag id="read" title="Read" description="Reading images with codecs" />
    </tags>
    <usings><![CDATA[using System;
using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var reader = new JpegReader("Apple.jpg"))
{
    // Check if XMP data are present in the file
    if (reader.Xmp != null)
    {
        // Get an XML code from the reader
        var xmp = new XmpData(reader.Xmp);

        // Print the value of the xmp:XmpCreateDate tag if it exists
        if (xmp.Contains(XmpTagNames.XmpCreateDate))
        {
            Console.WriteLine(
                "\n\nCreate date {0}",
                xmp[XmpTagNames.XmpCreateDate]);
        }
    }
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>ReadXmpProperty.txt</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/VectorFormats/RecolorRedStrokes.cs">
    <title>Recolor Red Strokes</title>
    <description>Demonstrates how to modify the stroke colors of shapes within a graphics container by detecting red strokes and recoloring them.</description>
    <instruction>Demonstrates how to edit the stroke color of shapes in a graphics container by detecting red strokes and recoloring them.</instruction>
    <output><![CDATA[The following code:

- Defines an extension method `IsRed` to check if a color is predominantly red.
- Loads a PDF file and extracts its graphics container content.
- Iterates through all shape items and modifies the pen color if the stroke is red.
- Replaces red strokes with dark magenta strokes.
- Renders the modified graphics container to a new PDF using `PdfWriter`.]]></output>
    <tags>
      <tag id="pdf" title="PDF" description="Importing and exporting PDF documents" />
      <tag id="modify-container" title="Modify Container" description="Editing items inside graphics containers" />
      <tag id="write" title="Write" description="Writing images with codecs" />
    </tags>
    <usings><![CDATA[using System.Linq;
using Aurigma.GraphicsMill.AdvancedDrawing;
using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[public static class Extensions
{
    public static bool IsRed(this Color color)
    {
        var rgbColor = (RgbColor)color.Convert(PixelFormat.Format24bppRgb);

        return rgbColor.R > (rgbColor.G + rgbColor.B);
    }
}

internal class RecolorRedStrokes
{
    public static void Run()
    {
        using (var reader = new PdfReader("GraphicsContainer.pdf"))
        using (var gc = reader.Frames[0].GetContent())
        using (var writer = new PdfWriter("GraphicsContainer_RecolorRedStrokes.pdf"))
        using (var gr = writer.GetGraphics())
        {
            writer.AddPage(gc.Width, gc.Height, gc.DpiX, gc.DpiY);

            foreach (var shapeItem in gc.Items.OfType<ShapeItem>())
            {
                if (shapeItem.Pen != null && shapeItem.Pen.Color.IsRed())
                {
                    shapeItem.Pen = new Pen(RgbColor.DarkMagenta, shapeItem.Pen.Width);
                }
            }

            gr.DrawContainer(gc, 0, 0);
        }
    }
}]]></code>
    <io>
      <in_download>
        <file>GraphicsContainer.pdf</file>
      </in_download>
      <out_preview>
        <file>GraphicsContainer_RecolorRedStrokes.png</file>
      </out_preview>
      <out_download>
        <file>GraphicsContainer_RecolorRedStrokes.pdf</file>
      </out_download>
    </io>
  </sample>
  <sample path="Codecs/Jpeg/RecompressJpegPartially.cs">
    <title>Recompress JPEG partially</title>
    <description>Applies mosaic effect on region of image with partial JPEG recompression.</description>
    <instruction>Write a C# program that applies a mosaic effect to a specific region of a JPEG image and updates only that region using partial JPEG recompression. Use the memory-friendly Pipeline API to generate the patch bitmap.</instruction>
    <output><![CDATA[Here is a C# program that applies a mosaic filter to a rectangular region of a JPEG image and saves the result using partial JPEG recompression:

This code defines a rectangle, processes the corresponding image patch with a mosaic effect using the memory-friendly Pipeline API, and writes the result back into the original JPEG using `LosslessJpeg.WritePatched()`.]]></output>
    <tags>
      <tag id="jpg" title="JPG" description="Reading and writing JPEG images" />
      <tag id="lossless" title="Lossless JPEG" description="Applying lossless JPEG operations" />
      <tag id="read" title="Read" description="Reading images with codecs" />
      <tag id="write" title="Write" description="Writing images with codecs" />
      <tag id="filesystem" title="Filesystem" description="Loading and saving images from files" />
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[var rect = new System.Drawing.Rectangle(264, 192, 264, 184);

using (var patchBitmap = new Bitmap())
{
    // Apply crop and mosaic transfroms
    using (var reader = ImageReader.Create("Chicago.jpg"))
    using (var crop = new Crop(rect))
    using (var mosaic = new Mosaic(10, 10))
    {
        Pipeline.Run(reader + crop + mosaic + patchBitmap);
    }

    // Patch JPEG
    using (var losslessJpeg = new LosslessJpeg("Chicago.jpg"))
    {
        rect = losslessJpeg.AlignToMCUSize(rect, JpegAlignToSampleSizeMode.Patch);
        losslessJpeg.WritePatched("ResompressJpegPartially.jpg", rect.Location, patchBitmap);
    }
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>ResompressJpegPartially.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Text/EnhancedText/ReflectedText.cs">
    <title>Reflected Text</title>
    <description>Exhibits a possible technique for implementing a mirrored text effect.</description>
    <instruction>This code generates an image with reflected text by using transformations and custom drawing styles.</instruction>
    <output><![CDATA[The code:

- Creates a `Bitmap` object with a white background (`RgbColor.White`) and a defined size (500x200).
- Initializes an `AdvancedGraphics` object to handle drawing on the bitmap.
- Defines the text "TEXT SAMPLE" with 50pt Arial font and applies tracking (letter-spacing) of 50 units.
- The text position is set using a transformation matrix for translation, and its bounding box is calculated to get its dimensions.
- The original text is drawn first on the bitmap at the specified position.
- For the reflected text, a new `Bitmap` object is created with transparent background and dimensions that fit the extended text width.
- A `LinearGradientBrush` is used to fill the reflected text with a gradient, starting with transparency at the top and fading to black with some alpha at the bottom.
- The reflected text is drawn on the new bitmap using the modified brush and position.
- The projective transformation is applied to widen the reflected text, and the bitmap is horizontally flipped.
- The reflected text is drawn on the original image at the appropriate position.
- The final result is saved as a PNG file (`ReflectedText.png`).]]></output>
    <tags>
      <tag id="text" title="Text" description="Rendering and formatting text" />
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="gradient" title="Gradient" description="Using gradient brushes and fills" />
      <tag id="art-text" title="Art Text" description="Creating artistic text" />
    </tags>
    <usings><![CDATA[using System.Drawing;
using Aurigma.GraphicsMill.AdvancedDrawing;
using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap(500, 200, PixelFormat.Format24bppRgb, RgbColor.White))
using (var gr = bitmap.GetAdvancedGraphics())
{
    var textPos = new System.Drawing.Point(50, 100);

    var text = new PlainText("<span style=\"tracking:50\">TEXT SAMPLE</span>", gr.CreateFont("Arial", 50));

    // Here it’s more convenient to define text position via matrix transform
    gr.Transform.Translate(textPos.X, textPos.Y);

    var bbox = text.GetBlackBox(gr.FontRegistry, gr.DpiX, gr.DpiY);

    // Draw original text
    gr.DrawText(text);

    // Parameters for reflected text widening
    const float leftExtension = 20;
    const float rightExtension = 20;

    // We need an additional bitmap
    using (var reflectedTextBitmap = new Bitmap((int)(bbox.Width + leftExtension + rightExtension), (int)bbox.Height, PixelFormat.Format32bppArgb, RgbColor.Transparent))
    using (var reflectedGraphics = reflectedTextBitmap.GetAdvancedGraphics())
    {
        var brush = new LinearGradientBrush()
        {
            StartPoint = new System.Drawing.PointF(0, 0),
            EndPoint = new System.Drawing.PointF(0, bbox.Height),
            ColorStops = new[]
            {
                new ColorStop() { Color = RgbColor.Transparent, Position = 0, Exponent = 1.0f },
                new ColorStop() { Color = RgbColor.Black.ScaleAlpha(0.8f), Position = 1 },
            },
        };

        text.Brush = brush;
        text.Position = new System.Drawing.PointF(leftExtension, -bbox.Top);

        // Draw the same with with different brush and position
        reflectedGraphics.DrawText(text);

        var srcPoints = new[]
        {
            new System.Drawing.PointF(bbox.Left, bbox.Bottom),
            new System.Drawing.PointF(bbox.Right, bbox.Bottom),
            new System.Drawing.PointF(bbox.Right, bbox.Height),
            new System.Drawing.PointF(bbox.Left, bbox.Height),
        };

        var dstPoints = new[]
        {
            new System.Drawing.PointF(bbox.Left - leftExtension, bbox.Bottom),
            new System.Drawing.PointF(bbox.Right + rightExtension, bbox.Bottom),
            new System.Drawing.PointF(bbox.Right, bbox.Height),
            new System.Drawing.PointF(bbox.Left, bbox.Height),
        };

        // Use projective matrix transform for text widening
        var projectiveMatrix = Aurigma.GraphicsMill.Transforms.Matrix.CreateFromProjectivePoints(srcPoints, dstPoints);

        reflectedTextBitmap.Transforms.ApplyMatrix(projectiveMatrix, RgbColor.Transparent, InterpolationMode.Medium);
        reflectedTextBitmap.Transforms.Flip(FlipType.Horizontal);

        gr.DrawImage(reflectedTextBitmap, -leftExtension * 2, bbox.Bottom + 3);
    }

    bitmap.Save("ReflectedText.png");
}]]></code>
    <io>
      <out_preview>
        <file>ReflectedText.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="ColorManagement/Channels/RemoveAlphaChannel.cs">
    <title>Remove Alpha Channel</title>
    <description>Removes alpha channel and replaces it with a solid color.</description>
    <instruction>Demonstrates how to remove the alpha channel from an image.</instruction>
    <output><![CDATA[The following code:

- Reads a PNG image (`Stamp.png`) using `Bitmap`.
- Removes the alpha channel from the image using `RemoveAlpha()`.
- Saves the resulting image without the alpha channel to `RemoveAlphaChannel.png`.]]></output>
    <tags>
      <tag id="channels" title="Channels" description="Reading and combining image channels" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Stamp.png"))
{
    bitmap.Channels.RemoveAlpha(RgbColor.WhiteSmoke);

    bitmap.Save("RemoveAlphaChannel.png");
}]]></code>
    <io>
      <in_preview>
        <file>Stamp.png</file>
      </in_preview>
      <out_preview>
        <file>RemoveAlphaChannel.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Transforms/GreenScreenRemoval/RemoveGreenScreen.cs">
    <title>Remove Green Screen</title>
    <description>Removes green screen using standard approach.</description>
    <instruction>Apply green screen removal to an image.</instruction>
    <output><![CDATA[The code:

- Reads an image from "GreenScreen.jpg".
- Applies the green screen removal transformation.
- Saves the result to "RemoveGreenScreen.png".]]></output>
    <tags>
      <tag id="green-screen" title="Green Screen" description="Removing green screen backgrounds" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("GreenScreen.jpg"))
{
    bitmap.Transforms.RemoveGreenScreen();

    bitmap.Save("RemoveGreenScreen.png");
}]]></code>
    <io>
      <in_preview>
        <file>GreenScreen.jpg</file>
      </in_preview>
      <out_preview>
        <file>RemoveGreenScreen.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="PSDFormat/Create3DPreview/RenderMugPreview.cs">
    <title>Render Mug Preview</title>
    <description>Creates 3D Preview of a customized mug using Adobe Photoshop's SmartObject.</description>
    <instruction>This code processes a PSD file and handles the smart object frames by replacing them with an image.</instruction>
    <output><![CDATA[The code:

- Creates a `PsdProcessor` instance to process a PSD file (`Mug.psd`).
- Defines a `FrameCallback` function to handle each frame:
- If the frame is a smart object and has the name `"Design"`, it replaces that frame with an image (`Copenhagen_RGB.jpg`) resized to fit the frame using `ResizeMode.ImageFill`.
- Renders the processed PSD into a PNG file (`RenderMugPreview.png`).]]></output>
    <tags>
      <tag id="psd-processor" title="PSD Processor" description="Automating PSD-based personalization" />
      <tag id="personalization" title="Personalization" description="Replacing placeholders with dynamic content" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Codecs.Psd;
using Aurigma.GraphicsMill.Templates;
using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[var psdProcessor = new PsdProcessor();

psdProcessor.FrameCallback = (processor, frame) =>
{
    if (frame.Type != FrameType.SmartObject || frame.Name != "Design")
    {
        return processor.ProcessFrame(frame);
    }

    var smartFrame = (PsdSmartFrame)frame;

    return smartFrame.ToGraphicsContainer(
        ImageReader.Create("Copenhagen_RGB.jpg"),
        ResizeMode.ImageFill);
};

psdProcessor.Render("Mug.psd", "RenderMugPreview.png");]]></code>
    <io>
      <in_preview>
        <file>Copenhagen_RGB.jpg</file>
      </in_preview>
      <in_download>
        <file>Mug.psd</file>
      </in_download>
      <out_preview>
        <file>RenderMugPreview.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="PSDFormat/RenderTemplates/ReplaceBackground.cs">
    <title>Replace Background</title>
    <description>Replaces background image of PSD image and saves to PDF file.</description>
    <instruction>Write a C# program that replaces the background raster layer in "BusinessCard.psd" by processing each frame with custom FrameCallback, replacing raster frames with "Venice.jpg" loaded via ImageReader using ToGraphicsContainer with ResizeMode.ImageFill to fit the background image into the PSD layer bounds while preserving non-raster layers (text, vectors), then renders the modified PSD composition to PDF "ReplaceBackground.pdf" using PsdProcessor.Render.</instruction>
    <output><![CDATA[Below is a C# code sample that replaces PSD background with external image:

The code demonstrates dynamic PSD background replacement using FrameCallback to intercept raster frame processing, substituting original background content with external "Venice.jpg" via ImageReader and ToGraphicsContainer with ImageFill mode for proper aspect ratio handling within PSD layer bounds. Non-raster elements (text, vector shapes) pass through unchanged via processor.ProcessFrame, enabling template-based design workflows where backgrounds can be swapped while maintaining foreground content positioning, typography, and vector elements in the final PDF output.]]></output>
    <tags>
      <tag id="psd-processor" title="PSD Processor" description="Automating PSD-based personalization" />
      <tag id="personalization" title="Personalization" description="Replacing placeholders with dynamic content" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Codecs.Psd;
using Aurigma.GraphicsMill.Templates;
using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[PsdProcessor psdProcessor = new PsdProcessor();

var psName = psdProcessor.FontResolver.FontRegistry.Add("ARIALUNI.TTF");
psdProcessor.FontResolver.FontRegistry.FallbackFonts.Add(psName);

psdProcessor.FrameCallback = (processor, frame) =>
{
    if (frame.Type != FrameType.Raster)
    {
        return processor.ProcessFrame(frame);
    }

    using (var background = ImageReader.Create("Venice.jpg"))
    {
        background.CloseOnDispose = false;

        return frame.ToGraphicsContainer(background, ResizeMode.ImageFill);
    }
};

psdProcessor.Render("BusinessCard.psd", "ReplaceBackground.pdf");]]></code>
    <io>
      <in_preview>
        <file>Venice.jpg</file>
      </in_preview>
      <in_download>
        <file>BusinessCard.psd</file>
      </in_download>
      <out_preview>
        <file>ReplaceBackground.png</file>
      </out_preview>
      <out_download>
        <file>ReplaceBackground.pdf</file>
      </out_download>
    </io>
  </sample>
  <sample path="Codecs/SpotColors/ReplaceProcessColor.cs">
    <title>Replace Process Color</title>
    <description>Converts the specified process color into a spot color saving graphics container to the PDF format.</description>
    <instruction>Write a C# program that converts a specified process color into a spot color and saves the graphics container to a PDF format.</instruction>
    <output><![CDATA[Below is a C# code sample that demonstrates how to convert a process color into a spot color and save the graphics container to a PDF file.
The `ReplaceProcessColors` method is used to replace colors in a `GraphicsContainer` with a spot color. The code utilizes `PdfWriter`, `PdfReader`,
and a custom extension method to perform this task:

This code replaces process colors (e.g., black) with a specified PANTONE spot color in a PDF document and saves the resulting content to a new file.]]></output>
    <tags>
      <tag id="pdf" title="PDF" description="Importing and exporting PDF documents" />
      <tag id="spot" title="Spot Color" description="Using spot colors in images" />
      <tag id="modify-container" title="Modify Container" description="Editing items inside graphics containers" />
    </tags>
    <usings><![CDATA[using System.Linq;
using Aurigma.GraphicsMill.AdvancedDrawing;
using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[public static class Extensions
{
    public static bool IsBlack(this Color color)
    {
        var grayColor = (GrayscaleColor)color.Convert(PixelFormat.Format8bppGrayscale);

        return grayColor.L < 20;
    }

    public static void ReplaceProcessColors(this GraphicsContainer container, SpotColor spotColor)
    {
        foreach (var item in container.Items.OfType<ShapeItem>())
        {
            if (item.Brush != null && item.Brush is SolidBrush && (item.Brush as SolidBrush).Color.IsBlack())
            {
                item.Brush = new SolidBrush(spotColor);
            }
        }

        foreach (var item in container.Items.OfType<ContainerItem>())
        {
            item.GraphicsContainer.ReplaceProcessColors(spotColor);
        }
    }
}

internal class ReplaceProcessColor
{
    public static void Run()
    {
        using (var reader = new PdfReader("Seal.pdf"))
        using (var gc = reader.Frames[0].GetContent())
        using (var writer = new PdfWriter("Process2SpotColor.pdf"))
        using (var gr = writer.GetGraphics())
        {
            writer.AddPage(gc.Width, gc.Height, gc.DpiX, gc.DpiY);

            var ink = new Ink("PANTONE Red 032 C", new RgbColor(243, 40, 55));
            var spotColor = new SpotColor(ink, 255);

            gc.ReplaceProcessColors(spotColor);

            gr.DrawContainer(gc, 0, 0);
        }
    }
}]]></code>
    <io>
      <in_download>
        <file>Seal.pdf</file>
      </in_download>
      <out_preview>
        <file>Process2SpotColor.png</file>
      </out_preview>
      <out_download>
        <file>Process2SpotColor.pdf</file>
      </out_download>
    </io>
  </sample>
  <sample path="LargeImages/Transforms/Resize.cs">
    <title>Resize</title>
    <description>Resizes image using memory-friendly Pipeline API.</description>
    <instruction>Resize an image to a new width and save the result.</instruction>
    <output><![CDATA[The code:

- Reads the image.
- Resizes the image to a width of 1048 pixels (height adjusted to maintain aspect ratio).
- Saves the resized image to the specified file.]]></output>
    <tags>
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
      <tag id="resize" title="Resize" description="Resizing images" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[using (var reader = ImageReader.Create("Venice.jpg"))
using (var resize = new Resize(1048, 0, ResizeInterpolationMode.Anisotropic9))
using (var writer = ImageWriter.Create("PipelineResize.jpg"))
{
    // In this case we'll get an additional performance benefit by using resize right after the reader.
    // This allows skip decoding of unnecessary image scan-lines.
    Pipeline.Run(reader + resize + writer);
}]]></code>
    <io>
      <in_preview>
        <file>Venice.jpg</file>
      </in_preview>
      <out_preview>
        <file>PipelineResize.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Transforms/Resize/Resize.cs">
    <title>Resize</title>
    <description>Resizes image.</description>
    <instruction>Resize the image to a width of 320 pixels, maintaining the aspect ratio, with high-quality interpolation.</instruction>
    <output><![CDATA[The code:

- Loads the image from file.
- Applies the "Resize" transform with a width of 320 pixels and automatic height adjustment (aspect ratio preserved), using high-quality interpolation.
- Saves the resized image to a file.]]></output>
    <tags>
      <tag id="resize" title="Resize" description="Resizing images" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Chicago.jpg"))
{
    bitmap.Transforms.Resize(320, 0, ResizeInterpolationMode.High);
    bitmap.Save("Resize.jpg");
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>Resize.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Metadata/PreservingMetadata/ResizeAndPreserveMetadata.cs">
    <title>Resize And Preserve Metadata</title>
    <description>Resize a JPEG and preserve/update metadata with Aurigma Graphics Mill.
Halves width (keeps aspect), updates EXIF Software, adds IPTC keyword,
sets Adobe copyright flag, adds XMP dc:contributor, and saves all metadata.</description>
    <instruction>Resize an image while preserving EXIF, IPTC, Adobe resources, and XMP metadata.</instruction>
    <output><![CDATA[The code:

- Reads the input JPEG image and resizes it to half the width, keeping the height proportional.
- Retrieves and updates EXIF metadata to include the "Software" tag with the value "Aurigma Graphics Mill".
- Retrieves and updates IPTC metadata with a new keyword "mountain".
- Reads, modifies, and adds a new Adobe resource block for copyright metadata.
- Loads and updates XMP metadata, adding a contributor node with the value "John Doe".
- Writes the resized image along with the preserved and modified metadata to a new JPEG file.]]></output>
    <tags>
      <tag id="exif" title="EXIF" description="Managing EXIF metadata" />
      <tag id="iptc" title="IPTC" description="Managing IPTC metadata" />
      <tag id="adobe-resources" title="Adobe Resources" description="Working with Adobe image resource blocks" />
      <tag id="xmp" title="XMP" description="Managing XMP metadata" />
      <tag id="read" title="Read" description="Reading images with codecs" />
      <tag id="write" title="Write" description="Writing images with codecs" />
      <tag id="resize" title="Resize" description="Resizing images" />
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[using (var jpegReader = new JpegReader("Chicago.jpg"))
using (var resize = new Resize(jpegReader.Width / 2, 0))
using (var jpegWriter = new JpegWriter("ResizeAndPreserveMetadata.jpg"))
{
    // Read EXIF
    var exif = jpegReader.Exif;

    // Check if loaded image contains EXIF metadata
    if (exif == null)
    {
        exif = new ExifDictionary();
    }

    exif[ExifDictionary.Software] = "Aurigma Graphics Mill";

    // Read IPTC
    var iptc = jpegReader.Iptc;

    // Check if loaded image contains IPTC metadata
    if (iptc == null)
    {
        iptc = new IptcDictionary();
    }

    iptc[IptcDictionary.Keyword] = "mountain";

    // Read Adobe resource blocks
    var adobeResources = jpegReader.AdobeResources;

    // Check if loaded image contains Adobe image resource blocks
    if (adobeResources == null)
    {
        adobeResources = new AdobeResourceDictionary();
    }

    // Create new adobe image resource block containing copyright metadata
    var arBlock = new AdobeResourceBlock("Copyright", new byte[] { 1 });

    // Set this block to the item with 0x040A ID (copyright flag)
    adobeResources[0x040A] = arBlock;

    var xmp = new XmpData();

    // Check if loaded image contains XMP metadata
    if (jpegReader.Xmp != null)
    {
        xmp.Load(jpegReader.Xmp);
    }

    // Create a node containing dc:contributor metadata
    var node = new XmpValueNode(XmpNodeType.SimpleProperty, "John Doe", XmpTagNames.DCContributor);
    xmp.AddNode(node);

    // Write metadata
    jpegWriter.Exif = exif;
    jpegWriter.Iptc = iptc;
    jpegWriter.AdobeResources = adobeResources;
    jpegWriter.Xmp = xmp.Save();

Pipeline.Run(jpegReader + resize + jpegWriter);]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>ResizeAndPreserveMetadata.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/Gif/ResizeAnimatedGif.cs">
    <title>Resize Animated Gif</title>
    <description>Resizes animated image in GIF format.</description>
    <instruction>Resize an animated GIF image to a fixed width and height while preserving animation properties such as palette, playback count, and frame settings. Use the memory-friendly Pipeline API where applicable.</instruction>
    <output><![CDATA[Here is a C# program that loads an animated GIF, resizes each frame to 400x400, and saves the result as a new animated GIF using the Pipeline API:

This code reads `AnimatedGif.gif`, resizes each frame while preserving palette and frame-specific metadata, and writes them to `ResizeAnimatedGif.gif`. It uses the Pipeline API for memory-efficient frame writing.]]></output>
    <tags>
      <tag id="gif" title="GIF" description="Reading, writing and animating GIFs" />
      <tag id="filesystem" title="Filesystem" description="Loading and saving images from files" />
      <tag id="multi-frame" title="Multiple frames" description="Handling multi-frame image formats" />
      <tag id="read" title="Read" description="Reading images with codecs" />
      <tag id="write" title="Write" description="Writing images with codecs" />
      <tag id="resize" title="Resize" description="Resizing images" />
    </tags>
    <usings><![CDATA[using System;
using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[const int width = 400;
const int height = 400;

using (var reader = new GifReader("AnimatedGif.gif"))
{
    var kX = (float)width / (float)reader.Width;
    var kY = (float)height / (float)reader.Height;

    using (var writer = new GifWriter("ResizeAnimatedGif.gif"))
    {
        // Copy general properties of the source file
        writer.BackgroundIndex = reader.BackgroundEntryIndex;
        writer.Palette = reader.Palette;
        writer.PlaybackCount = reader.PlaybackCount;

        for (int i = 0; i < reader.Frames.Count; i++)
        {
            // Read a frame
            using (var frame = (GifFrame)reader.Frames[i])
            using (var bitmap = frame.GetBitmap())
            {
                // Preserve the original palette
                ColorPalette palette = bitmap.Palette;

                // Preserve the original pixel format
                PixelFormat pixelFormat = bitmap.PixelFormat;

                // Convert the bitmap to a non-indexed format
                bitmap.ColorManagement.Convert(Aurigma.GraphicsMill.ColorSpace.Rgb, true, false);

                // Resize the bitmap in a low quality mode to prevent noise
                var newWidth = Math.Max(1, (int)((float)bitmap.Width * kX));
                var newHeight = Math.Max(1, (int)((float)bitmap.Height * kY));
                bitmap.Transforms.Resize(newWidth, newHeight, ResizeInterpolationMode.Low);

                // Return to the indexed format
                bitmap.ColorManagement.Palette = palette;
                bitmap.ColorManagement.Convert(pixelFormat);

                // Copy frame settings
                writer.FrameOptions.Left = (ushort)((float)frame.Left * kX);
                writer.FrameOptions.Top = (ushort)((float)frame.Top * kY);
                writer.FrameOptions.Delay = frame.Delay;
                writer.FrameOptions.DisposalMethod = frame.DisposalMethod;

                // Add the frame
                Pipeline.Run(bitmap + writer);
            }
        }
    }
}]]></code>
    <io>
      <in_preview>
        <file>AnimatedGIF.gif</file>
      </in_preview>
      <out_preview>
        <file>ResizeAnimatedGif.gif</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Metadata/ClippingPath/ResizeImageAndClippingPathMemoryFriendly.cs">
    <title>Resize Image And Clipping Path (Memory Friendly)</title>
    <description>Resizes image and clipping path using memory-friendly Pipeline API.</description>
    <instruction>Resize an image by reducing its dimensions to half while preserving the clipping paths in the Adobe resources, and save it to a new file.</instruction>
    <output><![CDATA[The code:

- Reads the input image.
- Resizes the image to half of its original width and height.
- The clipping paths in the Adobe resources are preserved during the process.
- Saves the resized image with the specified output filename.]]></output>
    <tags>
      <tag id="adobe-resources" title="Adobe Resources" description="Working with Adobe image resource blocks" />
      <tag id="read" title="Read" description="Reading images with codecs" />
      <tag id="write" title="Write" description="Writing images with codecs" />
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
      <tag id="resize" title="Resize" description="Resizing images" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[using (var reader = new JpegReader("Apple.jpg"))
using (var writer = new JpegWriter("ResizeImageAndClippingPathMemoryFriendly.jpg"))
using (var resize = new Resize(reader.Width / 2, reader.Height / 2))
{
    writer.AdobeResources = reader.AdobeResources;

    Pipeline.Run(reader + resize + writer);
}]]></code>
    <io>
      <in_preview>
        <file>Apple.jpg</file>
      </in_preview>
      <out_preview>
        <file>ResizeImageAndClippingPathMemoryFriendly.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Transforms/Resize/ResizeSharp.cs">
    <title>Resize Sharp</title>
    <description>Resizes image and maintains original sharpness (like Bicubic Sharper mode in Photoshop).</description>
    <instruction>Resize the image to a width of 320 pixels, maintain the aspect ratio, apply an unsharp mask with specified parameters.</instruction>
    <output><![CDATA[The code:

- Loads the image from file using the Bitmap class.
- Applies the "Resize" transform to adjust the image width to 320 pixels while maintaining the aspect ratio, using high-quality interpolation.
- Applies the "UnsharpMask" to sharpen the image with a radius of 1 and a strength of 0.35.
- Saves the processed image to a file with the sharpness enhancement.]]></output>
    <tags>
      <tag id="transform" title="Transform" description="Image transforms and effects" />
      <tag id="resize" title="Resize" description="Resizing images" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Chicago.jpg"))
{
    bitmap.Transforms.Resize(320, 0, ResizeInterpolationMode.High);
    bitmap.Transforms.UnsharpMask(0.35f, 1, 0);
    bitmap.Save("ResizeSharp.jpg");
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>ResizeSharp.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/Jpeg/ResizeWhileReadingJpeg.cs">
    <title>Resize while reading JPEG</title>
    <description>Demonstrates how to resize a JPEG image using the codec's resize capability.</description>
    <instruction>Write a C# program that resizes a JPEG image by a factor of 2 during decoding using `JpegReader.Scale`, and saves the result to a new image.</instruction>
    <output><![CDATA[Here is a C# program that performs JPEG decoding with downscaling by a factor of 2 using the `JpegReader.Scale` property:

This approach uses the JPEG format’s ability to scale down while decoding, improving performance for resizing operations.]]></output>
    <tags>
      <tag id="jpg" title="JPG" description="Reading and writing JPEG images" />
      <tag id="read" title="Read" description="Reading images with codecs" />
      <tag id="write" title="Write" description="Writing images with codecs" />
      <tag id="resize" title="Resize" description="Resizing images" />
      <tag id="filesystem" title="Filesystem" description="Loading and saving images from files" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var reader = new JpegReader("Chicago.jpg"))
{
    reader.Scale = JpegScale.x2;

    using (var bitmap = reader.Frames[0].GetBitmap())
    {
        bitmap.Save("ResizeWhileReadingJpeg.jpg");
    }
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>ResizeWhileReadingJpeg.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="ColorManagement/RGBToCMYK/RgbToCmyk.cs">
    <title>Rgb To Cmyk color space conversion</title>
    <description>Converts color space from RGB to CMYK with color management.</description>
    <instruction>Converts an RGB image to CMYK with color management using the object-based API.</instruction>
    <output><![CDATA[The code:

- Loads "Copenhagen_RGB.jpg" into a `Bitmap`.
- Assigns the sRGB color profile if none is embedded.
- Sets the destination profile to "ISOcoated_v2_eci.icc", a common CMYK press profile.
- Uses perceptual intent to preserve visual appearance across different color gamuts.
- Converts the pixel format to `Format32bppCmyk`.
- Saves the resulting CMYK image as "RgbToCmykWithColorManagement.jpg".]]></output>
    <tags>
      <tag id="color-management" title="Color Management" description="Color management with ICC profiles" />
      <tag id="color-conversion" title="Color Conversion" description="Converting colors between color spaces" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Copenhagen_RGB.jpg"))
{
    if (bitmap.ColorProfile == null)
    {
        bitmap.ColorProfile = ColorProfile.FromSrgb();
    }

    bitmap.ColorManagement.DestinationProfile = new ColorProfile("ISOcoated_v2_eci.icc");
    bitmap.ColorManagement.TransformationIntent = ColorTransformationIntent.Perceptual;

    bitmap.ColorManagement.Convert(PixelFormat.Format32bppCmyk);

    bitmap.Save("RgbToCmykWithColorManagement.jpg");
}]]></code>
    <io>
      <in_preview>
        <file>Copenhagen_RGB.jpg</file>
      </in_preview>
      <in_download>
        <file>ISOcoated_v2_eci.icc</file>
      </in_download>
      <out_preview>
        <file>RgbToCmykWithColorManagement.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="ColorManagement/RGBToCMYK/RgbToCmykMemoryFriendly.cs">
    <title>Rgb To Cmyk Memory Friendly</title>
    <description>Converts color space from RGB to CMYK with color management using memory-friendly Pipeline API.</description>
    <instruction>Converts an RGB image to CMYK with color management using the memory-friendly Pipeline API.</instruction>
    <output><![CDATA[The code:

- Reads "Copenhagen_RGB.jpg" using a memory-efficient `ImageReader`.
- Sets the desired pixel format to `Format32bppCmyk` for CMYK output.
- Assigns the sRGB profile as the source if none is embedded.
- Sets "ISOcoated_v2_eci.icc" as the destination CMYK profile.
- Applies perceptual intent for smoother color transitions.
- Executes the conversion pipeline and saves the result as "RgbToCmykWithColorManagementMemoryFriendly.jpg".]]></output>
    <tags>
      <tag id="color-management" title="Color Management" description="Color management with ICC profiles" />
      <tag id="color-conversion" title="Color Conversion" description="Converting colors between color spaces" />
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[using (var reader = ImageReader.Create("Copenhagen_RGB.jpg"))
using (var converter = new ColorConverter())
using (var writer = ImageWriter.Create("RgbToCmykWithColorManagementMemoryFriendly.jpg"))
{
    converter.DestinationPixelFormat = PixelFormat.Format32bppCmyk;
    converter.DefaultSourceProfile = ColorProfile.FromSrgb();
    converter.DestinationProfile = new ColorProfile("ISOcoated_v2_eci.icc");
    converter.TransformationIntent = ColorTransformationIntent.Perceptual;

    Pipeline.Run(reader + converter + writer);
}]]></code>
    <io>
      <in_preview>
        <file>Copenhagen_RGB.jpg</file>
      </in_preview>
      <in_download>
        <file>ISOcoated_v2_eci.icc</file>
      </in_download>
      <out_preview>
        <file>RgbToCmykWithColorManagementMemoryFriendly.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="ColorManagement/ConvertingColorValues/RgbToCmykWithoutColorManagement.cs">
    <title>RGB To CMYK Without Color Management</title>
    <description>Converts a color specified in RGB color space to CMYK color space without using color management.</description>
    <instruction>Write a C# program that converts an RGB color (R=253, G=202, B=12) to CMYK color space without color management using the CmykColor constructor that accepts RgbColor, performing a simple mathematical conversion without ICC profiles or transformation intents, then displays the result using Console.WriteLine.</instruction>
    <output><![CDATA[Below is a C# code sample that performs RGB to CMYK conversion without color management:

The code demonstrates basic RGB to CMYK conversion using the CmykColor constructor that accepts an RgbColor parameter, applying a simple mathematical formula (typically CMYK = 1 - (RGB / 255) for each channel with black key calculation) without any ICC profile involvement or color space transformation. This approach produces device-dependent results unsuitable for professional printing but useful for quick approximations or when color management is unavailable.]]></output>
    <tags>
      <tag id="color-conversion" title="Color Conversion" description="Converting colors between color spaces" />
    </tags>
    <usings><![CDATA[using System;]]></usings>
    <code language="csharp"><![CDATA[RgbColor rgbColor = new RgbColor(253, 202, 12);
CmykColor cmykColor = new CmykColor(rgbColor);

Console.WriteLine("Without color management: {0} to {1}", rgbColor, cmykColor);]]></code>
    <io>
      <out_preview>
        <file>RgbToCmykWithoutColorManagement.txt</file>
      </out_preview>
    </io>
  </sample>
  <sample path="ColorManagement/ConvertingColorValues/RgbToLabWithColorManagement.cs">
    <title>RGB To Lab With Color Management</title>
    <description>Converts a color specified in RGB color space to LAB color space.</description>
    <instruction>Write a C# program that converts an RGB color (R=223, G=210, B=30) with sRGB profile to LAB color space using color management via the To&lt;LabColor&gt; method without explicit destination profile, then displays the conversion result using Console.WriteLine.</instruction>
    <output><![CDATA[Below is a C# code sample that performs RGB to LAB color space conversion with color management:

The code demonstrates RGB to LAB conversion using GraphicsMill's color management system. It creates an RgbColor with specific values and assigns sRGB source profile, then uses the generic To<LabColor>() method which performs device-independent color space transformation to CIELAB color space using the source profile's color space as reference. LAB conversion is useful for color comparison, sorting, and perceptual uniformity calculations in image processing workflows.]]></output>
    <tags>
      <tag id="color-management" title="Color Management" description="Color management with ICC profiles" />
      <tag id="color-conversion" title="Color Conversion" description="Converting colors between color spaces" />
    </tags>
    <usings><![CDATA[using System;]]></usings>
    <code language="csharp"><![CDATA[RgbColor rgbColor = new RgbColor(223, 210, 30)
{
    Profile = ColorProfile.FromSrgb(),
};

LabColor labColor = rgbColor.To<LabColor>();

Console.WriteLine("With color management: {0} to {1}", rgbColor, labColor);]]></code>
    <io>
      <out_preview>
        <file>RgbToLabWithColorManagement.txt</file>
      </out_preview>
    </io>
  </sample>
  <sample path="ColorManagement/ConvertingColorValues/RgbToLabWithoutColorManagement.cs">
    <title>RGB To Lab Without Color Management</title>
    <description>Converts a color specified in RGB color space to LAB color space without using color management.</description>
    <instruction>Write a C# program that converts an RGB color (R=223, G=210, B=30) to LAB color space without color management using the LabColor constructor that accepts RgbColor, performing a simple mathematical approximation without ICC profiles or source color space consideration, then displays the result using Console.WriteLine.</instruction>
    <output><![CDATA[Below is a C# code sample that performs RGB to LAB conversion without color management:

The code demonstrates basic RGB to LAB conversion using the LabColor constructor with RgbColor parameter, applying a simplified mathematical transformation (typically linear RGB to XYZ conversion followed by XYZ to LAB without gamma correction or profile interpretation) that assumes sRGB-like device characteristics. This produces device-dependent LAB values unsuitable for color-critical applications but useful for quick visual approximations or when color management infrastructure is unavailable.]]></output>
    <tags>
      <tag id="color-conversion" title="Color Conversion" description="Converting colors between color spaces" />
    </tags>
    <usings><![CDATA[using System;]]></usings>
    <code language="csharp"><![CDATA[RgbColor rgbColor = new RgbColor(223, 210, 30);
LabColor labColor = new LabColor(rgbColor);

Console.WriteLine("Without color management: {0} to {1}", rgbColor, labColor);]]></code>
    <io>
      <out_preview>
        <file>RgbToLabWithoutColorManagement.txt</file>
      </out_preview>
    </io>
  </sample>
  <sample path="LargeImages/Transforms/Rotate.cs">
    <title>Rotate</title>
    <description>Rotates image using memory-friendly Pipeline API.</description>
    <instruction>Rotate an image by 5 degrees with a yellow color and save the result.</instruction>
    <output><![CDATA[The code:

- Reads the image.
- Rotates the image by 5 degrees with a yellow color fill.
- Saves the rotated image to the specified file.]]></output>
    <tags>
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
      <tag id="rotate" title="Rotate" description="Rotating images" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[using (var reader = ImageReader.Create("Chicago.jpg"))
using (var rotate = new Rotate(5, RgbColor.Yellow, InterpolationMode.High))
using (var writer = ImageWriter.Create("PipelineRotate.jpg"))
{
    Pipeline.Run(reader + rotate + writer);
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>PipelineRotate.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Transforms/RotateAndFlip/Rotate.cs">
    <title>Rotate</title>
    <description>Rotates image on 90, 180, 270 degrees.</description>
    <instruction>Rotate the image by 90 degrees.</instruction>
    <output><![CDATA[The code:

- Loads the image from the file "Chicago.jpg".
- Applies the "Rotate" transform to rotate the image by 90 degrees.
- Saves the rotated image to a new file, "Rotate.jpg".]]></output>
    <tags>
      <tag id="rotate" title="Rotate" description="Rotating images" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Chicago.jpg"))
{
    bitmap.Transforms.Rotate(90);
    bitmap.Save("Rotate.jpg");
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>Rotate.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Transforms/RotateAndFlip/RotateArbitrary.cs">
    <title>Rotate Arbitrary</title>
    <description>Rotates image on arbitrary angle.</description>
    <instruction>Rotate the image by 15 degrees and fill the background with yellow color, applying high-quality interpolation.</instruction>
    <output><![CDATA[The code:

- Loads the image from the file "Chicago.jpg".
- Applies the "Rotate" transform with a 15-degree rotation, setting the background color to yellow and using high-quality interpolation.
- Saves the rotated image with the specified adjustments to a new file, "RotateArbitrary.jpg".]]></output>
    <tags>
      <tag id="rotate" title="Rotate" description="Rotating images" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Chicago.jpg"))
{
    bitmap.Transforms.Rotate(15, RgbColor.Yellow, InterpolationMode.High);
    bitmap.Save("RotateArbitrary.jpg");
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>RotateArbitrary.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/Jpeg/RotateJpegLosslessly.cs">
    <title>Rotate JPEG losslessly</title>
    <description>Rotates JPEG image losslessly.</description>
    <instruction>Write a C# program that performs a lossless 90-degree clockwise rotation on a JPEG image using the `LosslessJpeg` class.</instruction>
    <output><![CDATA[Below is a C# code sample that rotates a JPEG image losslessly using `LosslessJpeg.WriteRotated()` with `Rotate90FlipNone`:

This avoids recompression artifacts by modifying the JPEG structure directly.]]></output>
    <tags>
      <tag id="jpg" title="JPG" description="Reading and writing JPEG images" />
      <tag id="lossless" title="Lossless JPEG" description="Applying lossless JPEG operations" />
      <tag id="read" title="Read" description="Reading images with codecs" />
      <tag id="write" title="Write" description="Writing images with codecs" />
      <tag id="filesystem" title="Filesystem" description="Loading and saving images from files" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var losslessJpeg = new LosslessJpeg("Chicago.jpg"))
{
    losslessJpeg.WriteRotated(
        "RotateJpegLosslessly.jpg",
        System.Drawing.RotateFlipType.Rotate90FlipNone);
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>RotateJpegLosslessly.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/LoadingAndSavingImages/SaveMultiframeImage.cs">
    <title>Save Multiframe Image</title>
    <description>Saves multiframe (multipage) image.</description>
    <instruction>Write a C# program that saves a multipage TIFF image with multiple frames, using the `TiffWriter` to write each frame individually.</instruction>
    <output><![CDATA[Below is a C# code sample that demonstrates how to save a multipage TIFF image with multiple frames using the `TiffWriter`:

This code saves two frames (images) in a single multipage TIFF file by writing each frame individually.]]></output>
    <tags>
      <tag id="tiff" title="TIFF" description="Reading and writing TIFF images" />
      <tag id="write" title="Write" description="Writing images with codecs" />
      <tag id="multi-frame" title="Multiple frames" description="Handling multi-frame image formats" />
      <tag id="filesystem" title="Filesystem" description="Loading and saving images from files" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var writer = new TiffWriter("SaveMultiframe.tif"))
{
    using (var frame1 = new Bitmap("Chicago.jpg"))
    {
        Pipeline.Run(frame1 + writer);
    }

    using (var frame2 = new Bitmap("Copenhagen_RGB.jpg"))
    {
        Pipeline.Run(frame2 + writer);
    }
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg, Copenhagen_RGB.jpg</file>
      </in_preview>
      <out_download>
        <file>SaveMultiframe.tif</file>
      </out_download>
    </io>
  </sample>
  <sample path="Codecs/SpotColors/SaveSpotImageToPdf.cs">
    <title>Save Spot Image To PDF</title>
    <description>Saves an image with a spot color to PDF.</description>
    <instruction>Write a C# program that creates an image with a spot color and saves it to a PDF file.</instruction>
    <output><![CDATA[Below is a C# code sample that demonstrates how to create an image with a spot color (PANTONE Red 032 C) and save it to a PDF file.
The code uses `Bitmap` to create an image, applies a radial gradient brush, and writes the resulting image to a PDF using `PdfWriter`:

This code generates a spot color image with a radial gradient and saves it into a PDF file.]]></output>
    <tags>
      <tag id="pdf" title="PDF" description="Importing and exporting PDF documents" />
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="spot" title="Spot Color" description="Using spot colors in images" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;
using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var spotImage = new Bitmap(300, 300, PixelFormat.Format8bppSpot, RgbColor.White))
{
    spotImage.Ink = new Ink("PANTONE Red 032 C", new RgbColor(243, 40, 55));

    using (var gr = spotImage.GetAdvancedGraphics())
    {
        var brush = new RadialGradientBrush();
        brush.ColorStops = new ColorStop[]
        {
            new ColorStop() { Color = RgbColor.White, Position = 0.0f },
            new ColorStop() { Color = RgbColor.Black, Position = 1.0f },
        };
        brush.StartPoint = new System.Drawing.PointF(gr.Width / 2, gr.Height / 2);
        brush.EndPoint = brush.StartPoint;

        brush.StartRadius = 0;
        brush.EndRadius = 300;

        gr.FillRectangle(brush, 0, 0, gr.Width, gr.Height);
    }

    using (var pdfWriter = new PdfWriter("SpotImage.pdf"))
    {
        Pipeline.Run(spotImage + pdfWriter);

        pdfWriter.Close();
    }
}]]></code>
    <io>
      <out_preview>
        <file>SpotImage.png</file>
      </out_preview>
      <out_download>
        <file>SpotImage.pdf</file>
      </out_download>
    </io>
  </sample>
  <sample path="Codecs/VectorFormats/SaveToJpeg.cs">
    <title>Save Vector Content To JPEG</title>
    <description>Reads vector content from the specified PDF file, rasterizes it, and saves it in JPEG format.</description>
    <instruction>Gets content from the specified PDF file and saves it in JPEG format.</instruction>
    <output><![CDATA[The following code:

- Loads a PDF file and retrieves the graphics content from the first frame.
- Uses `ImageGenerator` to render the content into a bitmap with 24bpp RGB pixel format and a white background.
- Saves the result as a JPEG image using `JpegWriter`.]]></output>
    <tags>
      <tag id="pdf" title="PDF" description="Importing and exporting PDF documents" />
      <tag id="jpg" title="JPG" description="Reading and writing JPEG images" />
      <tag id="format-conversion" title="Format Conversion" description="Converting images between formats" />
      <tag id="rasterization" title="Rasterization" description="Rasterizing vector graphics to bitmaps" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var reader = new PdfReader("GraphicsContainer.pdf"))
using (var gc = reader.Frames[0].GetContent())
using (var writer = new JpegWriter("GraphicsContainer.jpg"))
using (var ig = new ImageGenerator(gc, PixelFormat.Format24bppRgb, RgbColor.White))
{
    Pipeline.Run(ig + writer);
}]]></code>
    <io>
      <in_download>
        <file>GraphicsContainer.pdf</file>
      </in_download>
      <out_preview>
        <file>GraphicsContainer.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="ColorManagement/ColorProfile/ShowColorProfileInfo.cs">
    <title>Show Color Profile Information</title>
    <description>Displays detailed information about color profiles (sRGB and ICC).</description>
    <instruction>Write a C# program that reads and displays detailed information about color profiles including sRGB (built-in) and custom ICC profiles (ISOcoated_v2_eci.icc, ISOnewspaper26v4_gr.icc), showing properties such as Model, Description, Manufacturer, Copyright, DeviceClass, and ColorSpace using Console.WriteLine.</instruction>
    <output><![CDATA[Below is a C# code sample that extracts and displays comprehensive color profile metadata:

The code demonstrates reading ColorProfile properties from both built-in sRGB profile (ColorProfile.FromSrgb()) and custom ICC files using ColorProfile constructor. It outputs key metadata including color model, human-readable description, manufacturer information, copyright notice, device class (monitor/printer/etc.), and color space type via formatted Console output, useful for debugging color management workflows and verifying ICC profile integrity.]]></output>
    <tags>
      <tag id="color-profile" title="Color Profile" description="Using ICC color profiles" />
    </tags>
    <usings><![CDATA[using System;]]></usings>
    <code language="csharp"><![CDATA[public static void Run()
{
    Show(ColorProfile.FromSrgb());
    Show(new ColorProfile("ISOcoated_v2_eci.icc"));
    Show(new ColorProfile("ISOnewspaper26v4_gr.icc"));
}

private static void Show(ColorProfile colorProfile)
{
    Console.WriteLine("\n## Color Profile Information #\n");
    Console.WriteLine("Model:         {0}", colorProfile.Model);
    Console.WriteLine("Description:   {0}", colorProfile.Description);
    Console.WriteLine("Manufacturer:  {0}", colorProfile.Manufacturer);
    Console.WriteLine("Copyright:     {0}", colorProfile.Copyright);
    Console.WriteLine("Device class:  {0}", colorProfile.DeviceClass);
    Console.WriteLine("Color space:   {0}", colorProfile.ColorSpace);
}]]></code>
    <io>
      <in_download>
        <file>ISOcoated_v2_eci.icc, ISOnewspaper26v4_gr.icc</file>
      </in_download>
      <out_preview>
        <file>ShowColorProfileInfo.txt</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Text/FontRegistry/ShowCustomFontMetrics.cs">
    <title>Show Custom Font Metrics</title>
    <description>Adds font to FontRegistry from file and shows its metrics.</description>
    <instruction>Write a C# program that loads custom TrueType font "Lobster.ttf" into CustomFontRegistry via Add method to get PostScript name, creates 600x250 RGB bitmap with white background, uses AdvancedGraphics with font registry to render PlainText and RoundText samples at 60pt size, calculates and displays black box metrics with DPI-aware positioning, draws visual markup showing position points, bounding boxes, ascender/descender/baseline lines, and saves both console metrics output and annotated PNG visualization "ShowCustomFontMetrics.png".</instruction>
    <output><![CDATA[Below is a C# code sample that demonstrates custom font loading and advanced text metrics visualization:

The code showcases complete custom font integration workflow: loading TTF via CustomFontRegistry.Add for PostScript name resolution, DPI-aware font creation, PlainText baseline positioning with ascender/descender visualization using MeasureString metrics, and RoundText with Bend=0.9f circular layout centered via black box calculations. Visual markup includes gray bounding rectangles, colored baseline/ascender/descender lines, red position/center markers, enabling precise typographic analysis. Console output provides quantitative metrics while PNG visualization shows spatial relationships, essential for custom font validation, UI layout precision, and advanced text rendering in graphics applications.]]></output>
    <tags>
      <tag id="text" title="Text" description="Rendering and formatting text" />
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="font" title="Font" description="Managing fonts and font metrics" />
    </tags>
    <usings><![CDATA[using System;
using Aurigma.GraphicsMill.AdvancedDrawing;
using Aurigma.GraphicsMill.AdvancedDrawing.Art;]]></usings>
    <code language="csharp"><![CDATA[public static void Run()
{
    using (var bitmap = new Bitmap(600, 250, PixelFormat.Format24bppRgb, new RgbColor(255, 255, 255, 255)))
    using (var graphics = bitmap.GetAdvancedGraphics())
    using (var fontRegistry = new CustomFontRegistry())
    {
        var fontSize = 60f;

        // Load custom TrueType font
        var psName = fontRegistry.Add("Lobster.ttf");

        graphics.FontRegistry = fontRegistry;

        var font = graphics.CreateFont(psName, fontSize);

        // Plain text metrics
        var plainText = new PlainText("plain text", font);
        plainText.Position = new System.Drawing.PointF(5, plainText.GetBlackBox(fontRegistry, bitmap.DpiX, bitmap.DpiY).Height + 10);

        ShowTextPosition(plainText.String, plainText.Position, plainText.GetBlackBox(fontRegistry, bitmap.DpiX, bitmap.DpiY));

        DrawPlainTextWithMarkup(plainText, graphics);

        // Round text metrics
        var roundText = new RoundText("Art round text", font, new System.Drawing.PointF(50, 50))
        {
            Bend = 0.9f,
        };

        roundText.Center = new System.Drawing.PointF(
            graphics.Width - (roundText.GetBlackBox(fontRegistry, bitmap.DpiX, bitmap.DpiY).Width / 2) - 15,
            graphics.Height - (roundText.GetBlackBox(fontRegistry, bitmap.DpiX, bitmap.DpiY).Height / 2) - 10);

        ShowTextPosition(roundText.String, roundText.Center, roundText.GetBlackBox(fontRegistry, bitmap.DpiX, bitmap.DpiY));

        DrawArtTextWithMarkup(roundText, graphics);

        bitmap.Save("ShowCustomFontMetrics.png");
    }
}

private static void ShowTextPosition(string str, System.Drawing.PointF pos, System.Drawing.RectangleF blackBox)
{
    Console.WriteLine("Text metrics (\"{0}\")", str);
    Console.WriteLine("  Position");
    Console.WriteLine("    X:       {0}", pos.X);
    Console.WriteLine("    Y:       {0}", pos.Y);
    Console.WriteLine("  Black box");
    Console.WriteLine("    X:       {0}", blackBox.X);
    Console.WriteLine("    Y:       {0}", blackBox.Y);
    Console.WriteLine("    Width:   {0}", blackBox.Width);
    Console.WriteLine("    Height:  {0}", blackBox.Height);
    Console.WriteLine();
}

/// <summary>
/// Draws art text with center point and black box
/// </summary>
private static void DrawArtTextWithMarkup(ArtText text, Graphics graphics)
{
    // Draw round text, its black box and center point
    graphics.DrawText(text);

    graphics.DrawRectangle(new Pen(RgbColor.Gray, 1f), text.GetBlackBox(graphics.FontRegistry, graphics.DpiX, graphics.DpiY));

    graphics.FillEllipse(new SolidBrush(RgbColor.Red), text.Center.X - 3, text.Center.Y - 3, 6, 6);
}

/// <summary>
/// Draws PlainText with ascender and descender lines
/// </summary>
private static void DrawPlainTextWithMarkup(PlainText text, Graphics graphics)
{
    // Draw plain text, its black box, ascender, descender and position point
    graphics.DrawText(text);

    var bbox = text.GetBlackBox(graphics.FontRegistry, graphics.DpiX, graphics.DpiY);

    graphics.DrawRectangle(new Pen(RgbColor.Gray, 1f), bbox);

    var font = graphics.CreateFont(text.CharStyle.PostScriptName, text.CharStyle.Size);

    var stringMeasure = font.MeasureString("plain text");

    graphics.DrawLine(
        new Pen(RgbColor.Blue, 1f),
        bbox.X,
        text.Position.Y - stringMeasure.Ascender,
        bbox.X + bbox.Width,
        text.Position.Y - stringMeasure.Ascender);

    graphics.DrawLine(
        new Pen(RgbColor.Green, 1f),
        bbox.X,
        text.Position.Y - stringMeasure.Descender,
        bbox.X + bbox.Width,
        text.Position.Y - stringMeasure.Descender);

    graphics.DrawLine(
        new Pen(RgbColor.IndianRed, 1f),
        bbox.X,
        text.Position.Y,
        bbox.X + bbox.Width,
        text.Position.Y);

    graphics.FillEllipse(new SolidBrush(RgbColor.Red), text.Position.X - 3, text.Position.Y - 3, 6, 6);
}]]></code>
    <io>
      <in_download>
        <file>Lobster.ttf</file>
      </in_download>
      <out_preview>
        <file>ShowCustomFontMetrics.txt</file>
        <file>ShowCustomFontMetrics.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Interoperability/SystemDrawingInteroperability/SimpleConversion.cs">
    <title>Simple Conversion (System.Drawing Interop)</title>
    <description>Converts Aurigma.GraphicsMill.Bitmap to System.Drawing.Bitmap and vice versa.</description>
    <instruction>Write a C# program that demonstrates simple GraphicsMill to System.Drawing interop by loading "Copenhagen_RGB.jpg" as GraphicsMill Bitmap, casting directly to System.Drawing.Bitmap for legacy processing (watermark application), casting back to GraphicsMill Bitmap to copy pixels without conversion, and saving the result as "SimpleConversion.jpg" using the Save method.</instruction>
    <output><![CDATA[Below is a C# code sample that shows basic GraphicsMill and System.Drawing interop for RGB images:

The code demonstrates seamless pixel data sharing between GraphicsMill and System.Drawing via direct casting without copying or conversion, enabling legacy System.Drawing processing (watermarking) within GraphicsMill workflows. The round-trip preserves original pixel data, color profile, and metadata through the cast operations, making it the simplest integration pattern for RGB images where no color space conversion or metadata transfer is required. This approach offers zero-overhead interoperability for applications already using both libraries.]]></output>
    <tags>
      <tag id="interoperability" title="Interoperability" description="Interop with GDI+ and other libraries" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
      <tag id="watermark" title="Watermark" description="Adding text or image watermarks" />
    </tags>
    <code language="csharp"><![CDATA[// Imagine that you have a legacy application which works with System.Drawing.Bitmap,
// and you want to integrate it with Graphics Mill.
using (var gmBitmap1 = new Bitmap("Copenhagen_RGB.jpg"))
using (var sdBitmap = (System.Drawing.Bitmap)gmBitmap1)
{
    // Here we modify System.Drawing.Bitmap
    Utils.ApplyWatermark(sdBitmap);

    // If all you need is to copy pixels, just cast your System.Drawing.Bitmap
    // to Aurigma.GraphicsMill.Bitmap.
    using (var gmBitmap2 = (Bitmap)sdBitmap)
    {
        gmBitmap2.Save("SimpleConversion.jpg");
    }
}]]></code>
    <io>
      <in_preview>
        <file>Copenhagen_RGB.jpg</file>
      </in_preview>
      <out_preview>
        <file>SimpleConversion.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="LargeImages/ChannelManipulations/SplitAndCombineChannels.cs">
    <title>Split And Combine Channels</title>
    <description>Splits an image into its RGB channels, adjusts each channel's brightness, and recombines them.</description>
    <instruction>Split the RGB channels of an image, adjust their brightness, and then recombine them to create a modified image.</instruction>
    <output><![CDATA[The code:

- Reads the image "Chicago.jpg".
- Splits the image into its red, green, and blue channels.
- Adjusts the brightness of the red, green, and blue channels individually.
- Combines the modified channels back together into a single image.
- Saves the result as "SplitAndCombineChannels.png".]]></output>
    <tags>
      <tag id="branched-pipeline" title="Branched Pipeline" description="Building branched processing pipelines" />
      <tag id="channels" title="Channels" description="Reading and combining image channels" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[using (var reader = ImageReader.Create("Chicago.jpg"))
using (var channelSplitter = new RgbChannelSplitter())
using (var brightnessR = new Brightness(0.1f))
using (var brightnessG = new Brightness(-0.05f))
using (var brightnessB = new Brightness(0.2f))
using (var channelCombiner = new RgbChannelCombiner())
using (var writer = ImageWriter.Create("SplitAndCombineChannels.png"))
{
    reader.Receivers.Add(channelSplitter);

    channelCombiner.R = channelSplitter.R + brightnessR;
    channelCombiner.G = channelSplitter.G + brightnessG;
    channelCombiner.B = channelSplitter.B + brightnessB;

    Pipeline.Run(channelCombiner + writer);
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>SplitAndCombineChannels.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="ColorManagement/Channels/SplitChannels.cs">
    <title>Split channels</title>
    <description>Extracts individual channels from a CMYK image using channel splitter and saves them as separate files.</description>
    <instruction>Demonstrates how to split a CMYK image into separate channels and save each channel as a TIFF file.</instruction>
    <output><![CDATA[The following code:

- Reads a CMYK image (`Copenhagen_CMYK.jpg`) using `ImageReader`.
- Splits the image into its C, M, Y, and K channels using `CmykChannelSplitter`.
- Saves each channel into separate TIFF files: `Copenhagen_C.tif`, `Copenhagen_M.tif`, `Copenhagen_Y.tif`, and `Copenhagen_K.tif`.]]></output>
    <tags>
      <tag id="channels" title="Channels" description="Reading and combining image channels" />
      <tag id="read" title="Read" description="Reading images with codecs" />
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var reader = ImageReader.Create("Copenhagen_CMYK.jpg"))
using (var splitter = new CmykChannelSplitter())
using (var writerC = new PngWriter("Copenhagen_C.png"))
using (var writerM = new PngWriter("Copenhagen_M.png"))
using (var writerY = new PngWriter("Copenhagen_Y.png"))
using (var writerK = new PngWriter("Copenhagen_K.png"))
{
    splitter.C = writerC;
    splitter.M = writerM;
    splitter.Y = writerY;
    splitter.K = writerK;

    Pipeline.Run(reader + splitter);
}]]></code>
    <io>
      <in_preview>
        <file>Copenhagen_CMYK.jpg</file>
      </in_preview>
      <out_preview>
        <file>Copenhagen_C.png</file>
        <file>Copenhagen_M.png</file>
        <file>Copenhagen_Y.png</file>
        <file>Copenhagen_K.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="LargeImages/ChannelManipulations/SplitChannels.cs">
    <title>Split Channels</title>
    <description>Split the RGB channels of an image, adjust their brightness individually, and save each channel as a separate image.</description>
    <instruction>Split the RGB channels of an image, adjust their brightness individually, and save each channel as a separate image.</instruction>
    <output><![CDATA[The code:

- Reads the image "Chicago.jpg".
- Splits the image into its red, green, and blue channels.
- Adjusts the brightness of the red channel by 0.1, the green channel by 0.2, and the blue channel by -0.1.
- Saves the modified red channel as "Chicago_R.png", the green channel as "Chicago_G.png", and the blue channel as "Chicago_B.png".]]></output>
    <tags>
      <tag id="branched-pipeline" title="Branched Pipeline" description="Building branched processing pipelines" />
      <tag id="channels" title="Channels" description="Reading and combining image channels" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[using (var reader = ImageReader.Create("Chicago.jpg"))
using (var splitter = new RgbChannelSplitter())
using (var brightnessR = new Brightness(0.1f))
using (var writerR = new PngWriter("Chicago_R.png"))
using (var brightnessG = new Brightness(0.2f))
using (var writerG = new PngWriter("Chicago_G.png"))
using (var brightnessB = new Brightness(-0.1f))
using (var writerB = new PngWriter("Chicago_B.png"))
{
    splitter.R = brightnessR;
    brightnessR.Receivers.Add(writerR);

    splitter.G = brightnessG;
    brightnessG.Receivers.Add(writerG);

    splitter.B = brightnessB;
    brightnessB.Receivers.Add(writerB);

    Pipeline.Run(reader + splitter);
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>Chicago_R.png</file>
        <file>Chicago_G.png</file>
        <file>Chicago_B.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Text/EnhancedText/SubscriptSuperscript.cs">
    <title>Subscript and Superscript</title>
    <description>Draws subscript and superscript text.</description>
    <instruction>This code demonstrates the use of superscript and subscript formatting in text rendering.</instruction>
    <output><![CDATA[The code:

- Creates a `Bitmap` object with a white background (`RgbColor.White`) and dimensions of 200x200 pixels.
- Initializes an `AdvancedGraphics` object for drawing on the bitmap.
- Defines a `PlainText` object with the string "X2" and applies HTML-like tags to render the "2" as a superscript (`sup:true`) and subscript (`sub:true`) with specified positions and sizes.
- The superscript is positioned at 33% of the height and resized to 58.3% of the original font size, while the subscript follows a similar positioning and sizing.
- The text is drawn on the bitmap at the position `(30, 80)` with a font size of 50 points using the "Verdana" font.
- The final image is saved as a PNG file (`SubscriptSuperscript.png`).]]></output>
    <tags>
      <tag id="text" title="Text" description="Rendering and formatting text" />
      <tag id="formatted-text" title="Formatted Text" description="XML-based formatted text syntax" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;]]></usings>
    <code language="csharp"><![CDATA[// Here one may find all possible tags
// https://www.graphicsmill.com/docs/gm/advanced-formatted-text.htm

using (var bitmap = new Bitmap(200, 200, PixelFormat.Format24bppRgb, RgbColor.White))
using (var gr = bitmap.GetAdvancedGraphics())
{
    var text = new PlainText("X<span style='sup:true;sup-position:0.333;sup-size:0.583'>2</span>\nX<span style='sub:true;sub-position:0.333;sub-size:0.583'>2</span>", gr.CreateFont("Verdana", 50))
    {
        Position = new System.Drawing.PointF(30, 80),
    };

    gr.DrawText(text);

    bitmap.Save("SubscriptSuperscript.png");
}]]></code>
    <io>
      <out_preview>
        <file>SubscriptSuperscript.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/VectorFormats/SVGToPdf.cs">
    <title>SVG To PDF</title>
    <description>Converts SVG file to PDF format.</description>
    <instruction>Converts an SVG file to PDF format.</instruction>
    <output><![CDATA[The following code:

- Loads an SVG file using a specified DPI setting for scaling.
- Initializes a `PdfWriter` and adds a page with dimensions and DPI matching the SVG.
- Extracts the vector content from the SVG using `GetContent()` and draws it into the PDF graphics context.
- Saves the result as a PDF file.]]></output>
    <tags>
      <tag id="svg" title="SVG" description="Importing and exporting SVG graphics" />
      <tag id="pdf" title="PDF" description="Importing and exporting PDF documents" />
      <tag id="format-conversion" title="Format Conversion" description="Converting images between formats" />
      <tag id="container" title="Graphics Container" description="Using graphics containers for grouped items" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[float dpi = 150;

using (var reader = new SvgReader("Seal.svg", dpi, dpi))
using (var writer = new PdfWriter("Seal_out.pdf"))
using (var gr = writer.GetGraphics())
{
    writer.AddPage(reader.Width, reader.Height, dpi, dpi);
    using (var container = reader.GetContent())
    {
        gr.DrawContainer(container, 0, 0);
    }
}]]></code>
    <io>
      <in_preview>
        <file>Seal.svg</file>
      </in_preview>
      <out_preview>
        <file>Seal_out.png</file>
      </out_preview>
      <out_download>
        <file>Seal_out.pdf</file>
      </out_download>
    </io>
  </sample>
  <sample path="ColorManagement/Channels/SwapChannels.cs">
    <title>Swap Channels</title>
    <description>Demonstrates how to swap color channels of an image (in this case, blue and green channels).</description>
    <instruction>Demonstrates how to swap color channels of an image (in this case, blue and green channels).</instruction>
    <output><![CDATA[The following code:

- Reads the image (`Chicago.jpg`) into a `Bitmap` object.
- Swaps the blue and green channels using `SwapChannels` method.
- Saves the modified image as `SwapChannels.jpg` with the blue and green channels swapped.]]></output>
    <tags>
      <tag id="channels" title="Channels" description="Reading and combining image channels" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Chicago.jpg"))
{
    // http://www.graphicsmill.com/docs/gm/accessing-pixel-data.htm
    // Format24bppRgb - [Blue] = 0|[Green] = 1|[Red] = 2
    // Swap blue (0) and green (1) channels
    bitmap.Channels.SwapChannels(new int[] { 1, 0, 2 });

    bitmap.Save("SwapChannels.jpg");
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>SwapChannels.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="ColorManagement/Channels/SwapChannelsMemoryFriendly.cs">
    <title>Swap Channels Memory Friendly</title>
    <description>Demonstrates how to swap the Red and Green channels of an image using a memory-friendly pipeline approach.</description>
    <instruction>Demonstrates how to swap the Red and Green channels of an image using a memory-friendly pipeline approach.</instruction>
    <output><![CDATA[The following code:

- Reads the image (`Chicago.jpg`) using `ImageReader`.
- Splits the image into separate RGB channels with `RgbChannelSplitter`.
- Swaps the Red and Green channels by assigning the `R` channel to the `B` and the `G` channel to the `R`.
- Combines the swapped channels back using `RgbChannelCombiner`.
- Saves the resulting image as `SwapChannelsMemoryFriendly.jpg`.]]></output>
    <tags>
      <tag id="channels" title="Channels" description="Reading and combining image channels" />
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[////                         /-- (R) ------- (R)--\
////                        /                      \
//// reader --->  splitter  ---- (G) --\ /-- (B)----  combiner  ---> writer
////                        \           X          /
////                         \-- (B) --/ \-- (G)--/
using (var reader = ImageReader.Create("Chicago.jpg"))
using (var splitter = new RgbChannelSplitter())
using (var combiner = new RgbChannelCombiner())
using (var writer = ImageWriter.Create("SwapChannelsMemoryFriendly.jpg"))
{
    reader.Receivers.Add(splitter);

    combiner.R = splitter.R;
    combiner.G = splitter.B;
    combiner.B = splitter.G;

    combiner.Receivers.Add(writer);

    Pipeline.Run(combiner);
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>SwapChannelsMemoryFriendly.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Text/EnhancedText/TextEffects.cs">
    <title>Text Effects</title>
    <description>Demonstrates how to use shadow and glow effects for drawing text.</description>
    <instruction>This code demonstrates how to apply shadow and glow effects to text rendering.</instruction>
    <output><![CDATA[The code:

- Creates a `Bitmap` object with a white background (`RgbColor(255, 255, 255, 255)`) and dimensions of 600x400 pixels.
- Initializes an `AdvancedGraphics` object for drawing on the bitmap.
- Draws the first text, "Text with shadow", using the "Arial" font with a size of 50 points and red color. A shadow effect is applied to the text with a black color, an offset of (3, 3), opacity of 50%, and size 2.0f.
- Draws the second text, "Text with glow", with a black color and similar font size. A glow effect is applied with a red color, 75% opacity, and size 2.0f.
- Both texts are positioned at different locations on the bitmap: the first text at `(50, 50)` and the second at `(50, 250)`.
- The final image is saved as a PNG file (`TextEffects.png`).]]></output>
    <tags>
      <tag id="text" title="Text" description="Rendering and formatting text" />
      <tag id="formatted-text" title="Formatted Text" description="XML-based formatted text syntax" />
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;
using Aurigma.GraphicsMill.AdvancedDrawing.Effects;]]></usings>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap(600, 400, PixelFormat.Format24bppRgb, new RgbColor(255, 255, 255, 255)))
using (var gr = bitmap.GetAdvancedGraphics())
{
    // Draw text with shadow effect
    var textWithShadow = new PlainText("Text with shadow.", gr.CreateFont("Arial", 50))
    {
        Position = new System.Drawing.PointF(50, 50),
        Brush = new SolidBrush(RgbColor.Red),
    };

    textWithShadow.Effect = new Shadow()
    {
        Color = RgbColor.Black,
        OffsetX = 3,
        OffsetY = 3,
        Opacity = 0.5f,
        Size = 2.0f,
    };

    gr.DrawText(textWithShadow);

    // Draw text with glow effect
    var textWithGlow = new PlainText("Text with glow.", gr.CreateFont("Arial", 50))
    {
        Position = new System.Drawing.PointF(50, 250),
        Brush = new SolidBrush(RgbColor.Black),
    };

    textWithGlow.Effect = new Glow()
    {
        Color = RgbColor.Red,
        Opacity = 0.75f,
        Size = 2.0f,
    };

    gr.DrawText(textWithGlow);

    bitmap.Save("TextEffects.png");
}]]></code>
    <io>
      <out_preview>
        <file>TextEffects.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Text/TextLayout/TextFrames.cs">
    <title>Text Frames</title>
    <description>Render text in multiple columns and along a path using the Frames collection.</description>
    <instruction>This code demonstrates how to create and render text in multiple shapes and along a path using `Text`, `ShapeTextFrame`, and `PathTextFrame` classes.
Two rectangular shapes are defined for text frames, and a curved path is used for rendering text along the path.
The text is displayed within these shapes and along the path, with all paths outlined for visualization.</instruction>
    <output><![CDATA[The code:

- Creates two rectangular paths for text shapes (text is fitted inside these rectangles).
- Adds these shapes as `ShapeTextFrame` to the `Text` object.
- Creates a curved path for placing text along the path and adds it as a `PathTextFrame`.
- Draws the paths outlining the shapes and the curved path using a blue pen for visualization.
- Renders the text inside the defined shapes and along the path.
- Saves the result as "TextFrames.png".]]></output>
    <tags>
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="text-layout" title="Text Layout" description="Controlling advanced text layout" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;]]></usings>
    <code language="csharp"><![CDATA[var text = new Text();
text.String = Texts.LoremIpsum;
text.CharStyle.Size = 40;

var textShape1 = new Path();
textShape1.DrawRectangle(20, 20, 270, 450);

var textShape2 = new Path();
textShape2.DrawRectangle(310, 20, 270, 450);

var shapeTextFrame1 = new ShapeTextFrame()
{
    Shape = textShape1,
};

var shapeTextFrame2 = new ShapeTextFrame()
{
    Shape = textShape2,
};

text.Frames.Add(shapeTextFrame1);
text.Frames.Add(shapeTextFrame2);

var textPath = new Path();
textPath.MoveTo(20, 580);
textPath.CurveTo(250, 500, 480, 580);

var pathText = new PathTextFrame()
{
    Baseline = textPath,
};

text.Frames.Add(pathText);

using (var bitmap = new Bitmap(600, 600, PixelFormat.Format32bppArgb, RgbColor.White))
using (var gr = bitmap.GetAdvancedGraphics())
{
    gr.DrawPath(new Pen(RgbColor.Blue), textShape1);
    gr.DrawPath(new Pen(RgbColor.Blue), textShape2);

    gr.DrawPath(new Pen(RgbColor.Blue), textPath);

    gr.DrawText(text);

    bitmap.Save("TextFrames.png");
}]]></code>
    <io>
      <out_preview>
        <file>TextFrames.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/SpotColors/TiffExtraChannelsToPdfSpot.cs">
    <title>TIFF Extra Channels To Spot Color Space</title>
    <description>Converts a TIFF file with extra channels to PDF with separation color space.</description>
    <instruction>Write a C# program that reads a TIFF file with extra channels, processes the extra channels, and saves the output in a PDF format with separation color space.</instruction>
    <output><![CDATA[Below is a C# code sample that demonstrates how to process extra channels in a TIFF file and convert them to a PDF format, applying separation color space.
It reads the TIFF file, extracts extra channels, applies spot color inks, and saves the result into a PDF.

This code handles extra channels in TIFF images, extracts color and opacity information, and writes the result into a PDF file with spot color separation.]]></output>
    <tags>
      <tag id="tiff" title="TIFF" description="Reading and writing TIFF images" />
      <tag id="extra-channels" title="Extra Channels" description="Working with TIFF extra channels" />
      <tag id="spot" title="Spot Color" description="Using spot colors in images" />
      <tag id="adobe-resources" title="Adobe Resources" description="Working with Adobe image resource blocks" />
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
    </tags>
    <usings><![CDATA[using System.Collections.Generic;
using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[public static void Run()
{
    using (var reader = new TiffReader("TiffWithExtraChannels.tif"))
    using (var writer = new PdfWriter("TiffWithExtraChannels.pdf"))
    {
        reader.TreatFirstExtraChannelAsAlpha = false;

        Pipeline.Run(reader + writer);

        var names = ParseChannelNames(reader.AdobeResources);

        var displayInfos = ParseDisplayInfo(reader.AdobeResources);

        using (var gr = writer.GetGraphics())
        {
            for (int i = 0; i < reader.Frames[0].ExtraChannels.Count; i++)
            {
                var extraChannel = reader.Frames[0].ExtraChannels[i];

                using (var extraChannelBitmap = extraChannel.GetBitmap())
                using (var spotImage = new Bitmap(extraChannelBitmap.Width, extraChannelBitmap.Height, PixelFormat.Format16bppAspot, RgbColor.White))
                {
                    spotImage.DpiX = extraChannelBitmap.DpiX;
                    spotImage.DpiY = extraChannelBitmap.DpiY;

                    Color color = GetColor(displayInfos[i]);

                    var ink = new Ink(names[i], color)
                    {
                        Solidity = displayInfos[i].Opacity / 100.0f,
                    };

                    spotImage.Ink = ink;
                    extraChannelBitmap.Transforms.Invert();
                    spotImage.Channels[1] = extraChannelBitmap;

                    spotImage.Channels.ScaleAlpha(ink.Solidity);

                    gr.DrawImage(spotImage, 0, 0);
                }
            }
        }
    }
}

private static string[] ParseChannelNames(AdobeResourceDictionary ar)
{
    // https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/
    const int unicodeAlphaNames = 0x0415;

    var block = (AdobeResourceBlock)ar[unicodeAlphaNames];

    var names = new List<string>();

    int i = 0;

    while (i < block.Data.Length)
    {
        // skip zeros
        i += 2;

        var length = (block.Data[i] << 8) | block.Data[i + 1];
        i += 2;

        if (length * 2 > block.Data.Length - i)
        {
            throw new System.ArgumentException("Invalid block data.");
        }

        // Get the name without trailing zero
        var name = System.Text.Encoding.BigEndianUnicode.GetString(block.Data, i, (length - 1) * 2);

        i += length * 2;

        names.Add(name);
    }

    return names.ToArray();
}

private static DisplayInfo[] ParseDisplayInfo(AdobeResourceDictionary ar)
{
    // https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/
    const int displayInfo = 0x0435;

    var block = (AdobeResourceBlock)ar[displayInfo];

    var displayInfos = new List<DisplayInfo>();

    int i = 4;

    while (i < block.Data.Length)
    {
        var di = new DisplayInfo
        {
            Color = new int[4],
        };

        // Read color space
        di.ColorSpace = (block.Data[i] << 8) | block.Data[i + 1];
        i += 2;

        // Read colors
        for (int j = 0; j < 4; j++)
        {
            di.Color[j] = (block.Data[i] << 8) | block.Data[i + 1];
            i += 2;
        }

        // Read opacity
        di.Opacity = (block.Data[i] << 8) | block.Data[i + 1];
        i += 2;

        di.Kind = block.Data[i++];

        displayInfos.Add(di);
    }

    return displayInfos.ToArray();
}

private static Color GetColor(DisplayInfo di)
{
    if (di.ColorSpace == 0)
    {
        return new RgbColor(
            (byte)(di.Color[0] / 256),
            (byte)(di.Color[1] / 256),
            (byte)(di.Color[2] / 256));
    }
    else if (di.ColorSpace == 2)
    {
        return new CmykColor(
            (byte)(di.Color[0] / 256),
            (byte)(di.Color[1] / 256),
            (byte)(di.Color[2] / 256),
            (byte)(di.Color[3] / 256));
    }
    else
    {
        throw new System.ArgumentException("Unsupported color space.");
    }
}

private struct DisplayInfo
{
    public int ColorSpace;
    public int[] Color;
    public int Opacity;
    public int Kind;
}]]></code>
    <io>
      <in_download>
        <file>TiffWithExtraChannels.tif</file>
      </in_download>
      <out_preview>
        <file>TiffWithExtraChannels.png</file>
      </out_preview>
      <out_download>
        <file>TiffWithExtraChannels.pdf</file>
      </out_download>
    </io>
  </sample>
  <sample path="Transforms/Tint/TintUsingAlpha.cs">
    <title>Tint Using Alpha</title>
    <description>Tints using alpha channel.</description>
    <instruction>Apply tint using alpha channel and invert colors.</instruction>
    <output><![CDATA[The code:

- Loads the image from the file "Chicago.jpg".
- Converts the image to 8bpp grayscale format and inverts the colors.
- Creates a new result image with a green background, then sets the alpha channel from the original bitmap.
- Removes the white color from the alpha channel to use as transparency.
- Saves the final result to a new file, "TintUsingAlpha.jpg".]]></output>
    <tags>
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
      <tag id="transform" title="Transform" description="Image transforms and effects" />
      <tag id="color-conversion" title="Color Conversion" description="Converting colors between color spaces" />
      <tag id="channels" title="Channels" description="Reading and combining image channels" />
    </tags>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Chicago.jpg"))
{
    using (var result = new Aurigma.GraphicsMill.Bitmap(bitmap.Width, bitmap.Height, PixelFormat.Format24bppRgb, RgbColor.Green))
    {
        bitmap.ColorManagement.Convert(PixelFormat.Format8bppGrayscale);
        bitmap.Transforms.Invert();

        result.Channels.SetAlpha(bitmap);
        result.Channels.RemoveAlpha(RgbColor.White);

        result.Save("TintUsingAlpha.jpg");
    }
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>TintUsingAlpha.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Transforms/Tint/TintUsingAlphaMemoryFriendly.cs">
    <title>Tint Using Alpha (Memory Friendly)</title>
    <description>Tints using alpha channel and memory-friendly Pipeline API.</description>
    <instruction>Apply tint using alpha channel and invert colors in a memory-friendly way.</instruction>
    <output><![CDATA[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".]]></output>
    <tags>
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
      <tag id="transform" title="Transform" description="Image transforms and effects" />
      <tag id="color-conversion" title="Color Conversion" description="Converting colors between color spaces" />
      <tag id="channels" title="Channels" description="Reading and combining image channels" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[// 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);
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>TintUsingAlphaMemoryFriendly.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Transforms/Tint/TintUsingLab.cs">
    <title>Tint Using Lab</title>
    <description>Tints using Lab color space.</description>
    <instruction>Apply a tint to an image using Lab color space by manipulating the A and B channels, based on a specified color.</instruction>
    <output><![CDATA[The code:

- Defines an RGB color (250, 178, 79) and converts it to Lab color space, extracting the A and B values.
- Reads an image from "Chicago.jpg" and converts it to Lab color space, extracting the lightness channel.
- Creates new A and B channels based on the Lab color (adjusting with the extracted values).
- Combines the L, A, and B channels, then converts back to RGB color space.
- Saves the result to "TintUsingLab.jpg".]]></output>
    <tags>
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
      <tag id="transform" title="Transform" description="Image transforms and effects" />
      <tag id="color-conversion" title="Color Conversion" description="Converting colors between color spaces" />
      <tag id="channels" title="Channels" description="Reading and combining image channels" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;
using ColorConverter = Aurigma.GraphicsMill.Transforms.ColorConverter;]]></usings>
    <code language="csharp"><![CDATA[var color = new RgbColor(250, 178, 79);

var labColor = (LabColor)color.Convert(PixelFormat.Format24bppLab);
var a = labColor.A;
var b = labColor.B;

using (var lChannel = new Bitmap())
{
    // Convert to Lab color space and get lightness channel
    using (var reader = ImageReader.Create("Chicago.jpg"))
    using (var labConverter = new ColorConverter(PixelFormat.Format24bppLab))
    using (var splitter = new LabChannelSplitter())
    {
        splitter.L = lChannel;

        Pipeline.Run(reader + labConverter + splitter);
    }

    // Create a and b channels, combine with lightness channel and convert to RGB color space
    using (var combiner = new LabChannelCombiner())
    using (var aChannel = new Bitmap(lChannel.Width, lChannel.Height, PixelFormat.Format8bppGrayscale, new GrayscaleColor((byte)(a + 127))))
    using (var bChannel = new Bitmap(lChannel.Width, lChannel.Height, PixelFormat.Format8bppGrayscale, new GrayscaleColor((byte)(b + 127))))
    using (var rgbConverter = new ColorConverter(PixelFormat.Format24bppRgb))
    using (var writer = ImageWriter.Create("TintUsingLab.jpg"))
    {
        combiner.L = lChannel;
        combiner.A = aChannel;
        combiner.B = bChannel;

        rgbConverter.DestinationProfile = ColorProfile.FromSrgb();

        Pipeline.Run(combiner + rgbConverter + writer);
    }
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>TintUsingLab.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="ColorManagement/Channels/Transparentize.cs">
    <title>Transparentize</title>
    <description>Sets alpha values of pixels with a given color to transparent.</description>
    <instruction>Demonstrates how to add transparency to an image by transparentizing a specific color using `Bitmap.Channels`</instruction>
    <output><![CDATA[The following code:

- Loads the image (`ImageOnWhite.png`) into a `Bitmap` object.
- Sets an alpha channel with full opacity using `bitmap.Channels.SetAlpha(1f)`.
- Transparentizes a specific color (RgbColor(0x8a, 0xb9, 0xed)) with 10% transparency using `bitmap.Channels.Transparentize()`.
- Saves the resulting image as `Transparentize.png`.]]></output>
    <tags>
      <tag id="channels" title="Channels" description="Reading and combining image channels" />
      <tag id="transparentize" title="Transparentize" description="Making pixels transparent with transforms" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("ImageOnWhite.png"))
{
    bitmap.Channels.SetAlpha(1f);
    bitmap.Channels.Transparentize(new RgbColor(255, 255, 244), 0.1f);

    bitmap.Save("Transparentize.png");
}]]></code>
    <io>
      <in_preview>
        <file>ImageOnWhite.png</file>
      </in_preview>
      <out_preview>
        <file>Transparentize.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/Jpeg/UpdateJpegMetadataLosslessly.cs">
    <title>Update JPEG metadata losslessly</title>
    <description>Updates metadata of JPEG image without recompression.</description>
    <instruction>Write a C# program that updates IPTC, EXIF, XMP, and Adobe image resource metadata in a JPEG image using the `LosslessJpeg` class. Ensure that the image is not recompressed in the process.</instruction>
    <output><![CDATA[Below is a C# code sample that modifies metadata fields of a JPEG image without recompression:

The code demonstrates how to edit IPTC, EXIF, and XMP metadata, and how to insert an Adobe resource block using `LosslessJpeg`.]]></output>
    <tags>
      <tag id="jpg" title="JPG" description="Reading and writing JPEG images" />
      <tag id="lossless" title="Lossless JPEG" description="Applying lossless JPEG operations" />
      <tag id="read" title="Read" description="Reading images with codecs" />
      <tag id="write" title="Write" description="Writing images with codecs" />
      <tag id="metadata" title="Metadata" description="Reading and writing image metadata" />
      <tag id="filesystem" title="Filesystem" description="Loading and saving images from files" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var losslessJpeg = new LosslessJpeg("Chicago.jpg"))
{
    // IPTC
    if (losslessJpeg.Iptc == null)
    {
        losslessJpeg.Iptc = new IptcDictionary();
    }

    losslessJpeg.Iptc[IptcDictionary.Caption] = "Mountain";

    // EXIF
    if (losslessJpeg.Exif == null)
    {
        losslessJpeg.Exif = new ExifDictionary();
    }

    losslessJpeg.Exif[ExifDictionary.Software] = "Aurigma Graphics Mill";

    // XMP
    var xmp = new XmpData();
    if (losslessJpeg.Xmp != null)
    {
        xmp.Load(losslessJpeg.Xmp);
    }

    var node = new XmpValueNode(XmpNodeType.SimpleProperty, "John Doe", XmpTagNames.DCContributor);
    xmp.AddNode(node);
    losslessJpeg.Xmp = xmp.Save();

    // Adobe image resource blocks
    if (losslessJpeg.AdobeResources == null)
    {
        losslessJpeg.AdobeResources = new AdobeResourceDictionary();
    }

    const int copyrightFlag = 0x040A;

    var arBlock = new AdobeResourceBlock("Copyright", new byte[] { 1 });
    losslessJpeg.AdobeResources[copyrightFlag] = arBlock;

    losslessJpeg.Write("UpdateJpegMetadataLosslessly.jpg");
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>UpdateJpegMetadataLosslessly.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="PSDFormat/RenderTemplates/UpdateText.cs">
    <title>Update Text</title>
    <description>Updates text layer of PSD image and saves to PDF file.</description>
    <instruction>Write a C# program that updates text content in "BusinessCard.psd" using PSD processor's StringCallback to intercept text frame processing, retrieve current formatted text via GetFormattedText, conditionally replace content for text frame named "Name" with "Type your name", and render the modified PSD with updated text layer to PDF "UpdateText.pdf" while preserving all other layers, styling, and formatting.</instruction>
    <output><![CDATA[Below is a C# code sample that dynamically updates PSD text layers:

The code demonstrates PSD text layer modification using StringCallback to intercept text frame rendering, selectively updating content based on layer name ("Name" → "Type your name") while preserving original text formatting, font, styling, and positioning. GetFormattedText retrieves the complete styled text content, enabling template-based personalization workflows where dynamic text replacement maintains typographic fidelity and layer relationships. Non-text layers render unchanged, supporting business card templates, certificates, and automated document generation with variable data substitution.]]></output>
    <tags>
      <tag id="psd-processor" title="PSD Processor" description="Automating PSD-based personalization" />
      <tag id="personalization" title="Personalization" description="Replacing placeholders with dynamic content" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Templates;]]></usings>
    <code language="csharp"><![CDATA[var psdProcessor = new PsdProcessor();

var psName = psdProcessor.FontResolver.FontRegistry.Add("ARIALUNI.TTF");
psdProcessor.FontResolver.FontRegistry.FallbackFonts.Add(psName);

psdProcessor.StringCallback = (processor, textFrame) =>
{
    var textString = textFrame.GetFormattedText();

    if (textFrame.Name == "Name")
    {
        textString = "Type your name";
    }

    return textString;
};

psdProcessor.Render("BusinessCard.psd", "UpdateText.pdf");]]></code>
    <io>
      <in_download>
        <file>BusinessCard.psd</file>
      </in_download>
      <out_preview>
        <file>UpdateText.png</file>
      </out_preview>
      <out_download>
        <file>UpdateText.pdf</file>
      </out_download>
    </io>
  </sample>
  <sample path="PSDFormat/RenderTemplates/UpdateTextAndShapeColor.cs">
    <title>Update Text And Shape Color</title>
    <description>Updates text and shape color of PSD image and saves to PDF file.</description>
    <instruction>Write a C# program that modifies "Seal.psd" using PSD processor with dual callbacks: TextCallback to update text content with custom string, apply DarkRed SolidBrush fill while preserving original text frame properties via processor.ProcessText, and FrameCallback to detect shape frames, create GraphicsContainer matching shape bounds/DPI, fill VectorMask path with DarkGreen SolidBrush using AdvancedGraphics, then render combined modifications to PDF "UpdateTextAndShapeColor.pdf" while preserving other layers unchanged.</instruction>
    <output><![CDATA[Below is a C# code sample that updates both text content/color and vector shape fills in PSD:

The code demonstrates advanced PSD modification using dual callbacks: TextCallback intercepts text rendering to customize content, apply DarkRed brush while maintaining original typography via processor.ProcessText; FrameCallback targets shape layers, extracts VectorMask paths, creates dimension-matched GraphicsContainer, and fills shapes with DarkGreen SolidBrush for color customization. This pattern enables complete design template personalization - updating both typographic content/color and vector graphics fills - supporting dynamic seal/logo generation, certificate customization, and variable data workflows with preserved layer structure and professional PDF output.]]></output>
    <tags>
      <tag id="psd-processor" title="PSD Processor" description="Automating PSD-based personalization" />
      <tag id="personalization" title="Personalization" description="Replacing placeholders with dynamic content" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;
using Aurigma.GraphicsMill.Codecs.Psd;
using Aurigma.GraphicsMill.Templates;]]></usings>
    <code language="csharp"><![CDATA[var psdProcessor = new PsdProcessor();

var psName = psdProcessor.FontResolver.FontRegistry.Add("ARIALUNI.TTF");
psdProcessor.FontResolver.FontRegistry.FallbackFonts.Add(psName);

psdProcessor.TextCallback = (processor, textFrame, textString) =>
{
    var text = processor.ProcessText(textFrame);
    text.String = textString;

    text.Brush = new SolidBrush(RgbColor.DarkRed);

    return text;
};

psdProcessor.FrameCallback = (processor, frame) =>
{
    if (frame.Type != FrameType.Shape)
    {
        return processor.ProcessFrame(frame);
    }

    var shapeFrame = (PsdShapeFrame)frame;

    var graphicsContainer = new GraphicsContainer(frame.X + frame.Width, frame.Y + frame.Height, frame.DpiX, frame.DpiY);

    using (var graphics = graphicsContainer.GetGraphics())
    {
        graphics.FillPath(new SolidBrush(RgbColor.DarkGreen), shapeFrame.VectorMask);
    }

    return graphicsContainer;
};

psdProcessor.Render("Seal.psd", "UpdateTextAndShapeColor.pdf");]]></code>
    <io>
      <in_download>
        <file>Seal.psd</file>
      </in_download>
      <out_preview>
        <file>UpdateTextAndShapeColor.png</file>
      </out_preview>
      <out_download>
        <file>UpdateTextAndShapeColor.pdf</file>
      </out_download>
    </io>
  </sample>
  <sample path="PSDFormat/RenderTemplates/UpdateTextColor.cs">
    <title>Update Text Color</title>
    <description>Updates text color of PSD image and saves to PDF file.</description>
    <instruction>Write a C# program that updates text color in "BusinessCard.psd" using PSD processor's TextCallback to process text frames via processor.ProcessText, conditionally apply Red SolidBrush to text frame named "Name" while preserving original content via textString parameter for other layers, and render the modified PSD with color-updated text to PDF "UpdateTextColor.pdf".</instruction>
    <output><![CDATA[Below is a C# code sample that selectively updates PSD text layer colors:

The code demonstrates targeted text color modification using TextCallback to intercept text rendering, preserving original content through textString parameter while applying conditional color changes (Red SolidBrush for "Name" layer) via layer name identification. processor.ProcessText maintains original typography, positioning, and effects while allowing Brush customization for specific layers, enabling template-based color variations where only designated text elements change color, supporting brand consistency, personalization, and automated design workflows with preserved typographic fidelity and PDF output.]]></output>
    <tags>
      <tag id="psd-processor" title="PSD Processor" description="Automating PSD-based personalization" />
      <tag id="personalization" title="Personalization" description="Replacing placeholders with dynamic content" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;
using Aurigma.GraphicsMill.Templates;]]></usings>
    <code language="csharp"><![CDATA[var psdProcessor = new PsdProcessor();

var psName = psdProcessor.FontResolver.FontRegistry.Add("ARIALUNI.TTF");
psdProcessor.FontResolver.FontRegistry.FallbackFonts.Add(psName);

psdProcessor.TextCallback = (processor, textFrame, textString) =>
{
    var text = processor.ProcessText(textFrame);
    text.String = textString;

    if (textFrame.Name == "Name")
    {
        text.Brush = new SolidBrush(RgbColor.Red);
    }

    return text;
};

psdProcessor.Render("BusinessCard.psd", "UpdateTextColor.pdf");]]></code>
    <io>
      <in_download>
        <file>BusinessCard.psd</file>
      </in_download>
      <out_preview>
        <file>UpdateTextColor.png</file>
      </out_preview>
      <out_download>
        <file>UpdateTextColor.pdf</file>
      </out_download>
    </io>
  </sample>
  <sample path="LargeImages/PipelineAPISyntax/OnInitEvent.cs">
    <title>Using the OnInit event to configure pipeline elements</title>
    <description>What if we want to adjust pipeline element settings depending on the actual input data? In most cases you have access to the source element, but in more sophisticated scenarios the pipeline may be large, and it may be hard to track all possible changes of the image parameters. Or you may decide to split the pipeline assembly logic into several methods.
In this case, it is possible to change pipeline element settings from an OnInit event handler. You get the actual image parameters that the element receives from its source, and change the properties according to those parameters.
In this example, we'll scale the original image by a factor of 2.5 while preserving its aspect ratio, and place a watermark image in the center. The watermark image will be half the size of the bottom image.&lt;br/&gt;&lt;br/&gt;
You can read more information about pipelines in the &lt;a href="https://www.graphicsmill.com/docs/gm/processing-large-images-using-pipelines.htm"&gt;documentation&lt;/a&gt;.</description>
    <instruction>Use the Pipeline API to resize an input image and overlay a watermark image,
configuring element properties inside OnInit event handlers instead of hard-coding
dimensions up front.</instruction>
    <output><![CDATA[The code:

- Reads the base image "Venice.jpg" with <c>ImageReader</c>.
- Uses a <c>Resize</c> element whose <c>Width</c>, <c>Height</c>, <c>ResizeMode</c>, and
<c>InterpolationMode</c> are set in its <c>OnInit</c> handler based on the actual input
image size (scaled by a factor of 2.5 while preserving aspect ratio).
- Reads the watermark image "Stamp.png" with another <c>ImageReader</c>.
- Resizes the watermark in a second <c>Resize</c> element, configuring its <c>ResizeMode</c>
and target size in <c>OnInit</c> so the watermark is half the width and height of the
resized base image.
- Combines the base image and watermark with a <c>Combiner</c> element, setting its <c>X</c>
and <c>Y</c> in the <c>OnInit</c> handler so the watermark is centered.
- Runs the pipeline <c>reader + resize + combiner + writer</c> with <c>Pipeline.Run</c>.
- Saves the result as "OnInitWatermark.jpg".]]></output>
    <tags>
      <tag id="branched-pipeline" title="Branched Pipeline" description="Building branched processing pipelines" />
      <tag id="resize" title="Resize" description="Resizing images" />
      <tag id="advanced" title="Advanced" description="Demonstrating advanced usage scenarios" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[// Create pipeline elements
using (var reader = ImageReader.Create("Venice.jpg"))
using (var resize = new Resize())
using (var writer = ImageWriter.Create("OnInitWatermark.jpg"))
{
    // Configure the resize element based on the input image size
    resize.OnInit += (sender, e) =>
    {
        var resizeSender = sender as Resize;
        resizeSender.Width = (int)(e.ImageParams.Width / 2.5f);
        resizeSender.Height = (int)(e.ImageParams.Height / 2.5f);
        resizeSender.ResizeMode = ResizeMode.Resize;
        resizeSender.InterpolationMode = ResizeInterpolationMode.Anisotropic9;
    };

    // Create pipeline elements for the watermark
    using (var topReader = ImageReader.Create("Stamp.png"))
    using (var topResize = new Resize(200, 200, ResizeInterpolationMode.High))
    using (var combiner = new Combiner(CombineMode.Alpha, (topReader + topResize).Build()))
    {
        // Configure the topResize element based on the resized base image size
        topResize.OnInit += (sender, e) =>
        {
            var topResizeSender = sender as Resize;
            topResizeSender.ResizeMode = ResizeMode.Fit;
            topResizeSender.Width = resize.Width / 2;
            topResizeSender.Height = resize.Height / 2;

            resize.InterpolationMode = ResizeInterpolationMode.Anisotropic9;
        };

        // Configure the combiner element to center the watermark
        combiner.OnInit += (sender, e) =>
        {
            var args = e as CombinerOnInitEventArgs;
            var combinerSender = sender as Combiner;
            combinerSender.X = (args.ImageParams.Width - args.TopImageParams.Width) / 2;
            combinerSender.Y = (args.ImageParams.Height - args.TopImageParams.Height) / 2;
        };

        // Run the pipeline
        Pipeline.Run(reader + resize + combiner + writer);
    }
}]]></code>
    <io>
      <in_preview>
        <file>Venice.jpg</file>
        <file>Stamp.png</file>
      </in_preview>
      <out_preview>
        <file>OnInitWatermark.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Text/TextLayout/VerticalText.cs">
    <title>Vertical Text</title>
    <description>Draws different vertical texts.</description>
    <instruction>This code demonstrates how to display vertical text both within a rectangular shape and at a specific point using `ShapeTextFrame` and `PointTextFrame`.
The `ShapeTextFrame` is used with a rectangular path, while the `PointTextFrame` places the text at a specified point in the canvas.
The text in both frames is oriented vertically.</instruction>
    <output><![CDATA[The code:

- Creates a rectangular path (300x300 pixels) and places text within it using `ShapeTextFrame` with vertical orientation.
- Also adds a `PointTextFrame` with vertical orientation, where the text is placed at a specified point.
- Both text placements are rendered on the canvas and saved as "VerticalText.png".]]></output>
    <tags>
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="text-layout" title="Text Layout" description="Controlling advanced text layout" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;]]></usings>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap(500, 500, PixelFormat.Format32bppArgb, RgbColor.White))
using (var gr = bitmap.GetAdvancedGraphics())
{
    var text = new Text();
    text.String = Texts.LoremIpsum;
    text.CharStyle.Size = 20;

    var shape = new Path();
    shape.DrawRectangle(200, 50, 300, 300);

    text.Frames.Add(new ShapeTextFrame()
    {
        Shape = shape,
        TextOrientation = TextOrientation.Vertical,
    });

    text.Frames.Add(new PointTextFrame()
    {
        Point = new System.Drawing.PointF(50, 50),
        TextOrientation = TextOrientation.Vertical,
    });

    gr.DrawText(text);

    bitmap.Save("VerticalText.png");
}]]></code>
    <io>
      <out_preview>
        <file>VerticalText.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Metadata/ClippingPath/VisualizeClippingPath.cs">
    <title>Visualize Clipping Path</title>
    <description>Visualizes clipping path for demonstration purposes.</description>
    <instruction>Write a C# program that visualizes clipping paths from various JPEG images by extracting the first clipping path using JpegReader.ClippingPaths[0], converting it to GraphicsPath with CreateGraphicsPath, drawing it on the bitmap using AdvancedGraphics.DrawPath with semi-transparent blue Pen (RGB 0,0,255,127 alpha), and saving visualized versions for demonstration of clipping path preservation through copy, crop, resize, and modification operations.</instruction>
    <output><![CDATA[Below is a C# code sample that visualizes clipping paths for demonstration and testing:

The code demonstrates clipping path visualization across multiple scenarios (copy, memory-friendly processing, crop preservation, resize transformation, explicit modification) by loading JPEG via JpegReader, extracting bitmap from first frame, retrieving clipping path metadata, converting to drawable GraphicsPath scaled to image dimensions, and rendering with 4px semi-transparent blue stroke (alpha 127 for visibility over content). This technique verifies clipping path integrity through image processing pipelines and supports quality assurance for pre-press workflows where clipping paths define transparent/silhouette regions.]]></output>
    <tags>
      <tag id="clipping-paths" title="Clipping Paths" description="Reading and writing Adobe resources clipping path" />
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;
using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[public static void Run()
{
    Visualize("CopyClippingPath.jpg", "CopyClippingPath_Visualized.jpg");
}

private static void Visualize(string inputPath, string outputPath)
{
    using (var reader = new JpegReader(inputPath))
    using (var bitmap = reader.Frames[0].GetBitmap())
    using (var graphics = bitmap.GetAdvancedGraphics())
    {
        var graphicsPath = reader.ClippingPaths[0].CreateGraphicsPath(reader.Width, reader.Height);

        graphics.DrawPath(new Pen(new RgbColor(0, 0, 255, 127), 4f), Path.Create(graphicsPath));

        bitmap.Save(outputPath);
    }
}]]></code>
    <io>
      <in_preview>
        <file>CopyClippingPath.jpg</file>
      </in_preview>
      <out_preview>
        <file>CopyClippingPath_Visualized.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Text/TextLayout/WrappingPaths.cs">
    <title>Wrapping Paths</title>
    <description>Illustrates the utilization of wrapping paths for excluding specific regions for text layout.</description>
    <instruction>This code demonstrates how to wrap text inside a bounded rectangle with a wrapping path (ellipse).
The text is placed inside a defined rectangle (`RectangleF`) and wraps around the given path (an ellipse).
The path (`wrappingPath`) is drawn, and the text is wrapped according to the boundaries of the path.</instruction>
    <output><![CDATA[The code:

- Draws an ellipse as a wrapping path within the defined area for text.
- The text (`Texts.LoremIpsum`) is bounded within a rectangle and wrapped around the ellipse.
- Both the rectangle and ellipse are drawn as frames, and the final output is saved as "WrappingPaths.png".]]></output>
    <tags>
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="text-layout" title="Text Layout" description="Controlling advanced text layout" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;]]></usings>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap(400, 400, PixelFormat.Format32bppArgb, RgbColor.White))
using (var gr = bitmap.GetAdvancedGraphics())
{
    var wrappingPath = new Path();
    wrappingPath.DrawEllipse(180, 0, 70, 350);

    var text = new BoundedText(Texts.LoremIpsum, gr.CreateFont("Arial", 20))
    {
        Rectangle = new System.Drawing.RectangleF(50, 50, 300, 300),
    };

    text.WrappingPaths.Add(wrappingPath);

    gr.DrawRectangle(new Pen(RgbColor.Blue), text.Rectangle);
    gr.DrawPath(new Pen(RgbColor.Red), wrappingPath);

    gr.DrawText(text);

    bitmap.Save("WrappingPaths.png");
}]]></code>
    <io>
      <out_preview>
        <file>WrappingPaths.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Metadata/AdobeImageResourceBlocks/WriteAdobeResourceBlock.cs">
    <title>Write Adobe Image Resource Block</title>
    <description>Write copyright XMP block.</description>
    <instruction>Write a copyright XMP block to an image file using AdobeResourceBlock and save the result.</instruction>
    <output><![CDATA[The code:

- Reads the JPEG image from the specified input path.
- Retrieves and modifies the Adobe resource block by adding a new copyright block (0x040A) with specific metadata.
- Removes the thumbnail data block (0x0409).
- Writes the modified Adobe resources back to the output image file.]]></output>
    <tags>
      <tag id="adobe-resources" title="Adobe Resources" description="Working with Adobe image resource blocks" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[public static void Run()
{
    Write("Chicago.jpg", "Chicago_AdobeResourceBlock.jpg");
    Write("Venice.jpg", "Venice_AdobeResourceBlock.jpg");
}

private static void Write(string inputPath, string outputPath)
{
    using (var reader = new JpegReader(inputPath))
    using (var writer = new JpegWriter(outputPath))
    {
        var adobeResources = reader.AdobeResources;
        if (adobeResources == null)
        {
            adobeResources = new AdobeResourceDictionary();
        }

        // Create new adobe image resource block with the required metadata
        var arBlock = new AdobeResourceBlock("Copyright", new byte[] { 1 });

        // Set this block to the item with 0x040A ID (copyright flag)
        adobeResources[0x040A] = arBlock;

        // Remove a block with 0x0409 (thumbnail data)
        adobeResources.Remove(0x0409);

        writer.AdobeResources = adobeResources;
        Pipeline.Run(reader + writer);
    }
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
        <file>Venice.jpg</file>
      </in_preview>
      <out_preview>
        <file>Chicago_AdobeResourceBlock.jpg</file>
        <file>Venice_AdobeResourceBlock.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/Gif/WriteAnimatedGif.cs">
    <title>Write Animated Gif</title>
    <description>Writes simple animated image in GIF format.</description>
    <instruction>Create an animated GIF by generating multiple frames programmatically. Each frame should contain a green circle drawn at a different horizontal position on a yellow background. Use the memory-friendly Pipeline API to write the animation.</instruction>
    <output><![CDATA[Here is a C# program that generates an animated GIF with a moving green circle on a yellow background:

This code creates an animated GIF `WriteAnimatedGif.gif` that is 400x100 pixels in size. It draws a green circle moving horizontally across a yellow background by generating frames in a loop. Each frame is converted to 8-bit indexed format and added to the GIF using the memory-efficient Pipeline API.]]></output>
    <tags>
      <tag id="gif" title="GIF" description="Reading, writing and animating GIFs" />
      <tag id="filesystem" title="Filesystem" description="Loading and saving images from files" />
      <tag id="multi-frame" title="Multiple frames" description="Handling multi-frame image formats" />
      <tag id="write" title="Write" description="Writing images with codecs" />
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="color-conversion" title="Color Conversion" description="Converting colors between color spaces" />
      <tag id="indexed" title="Indexed format" description="Working with indexed-color images" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;
using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var writer = new GifWriter("WriteAnimatedGif.gif"))
{
    writer.Width = 400;
    writer.Height = 100;
    writer.FrameOptions.Delay = 25;

    for (int i = 0; i < 400; i += 25)
    {
        var bitmap = new Bitmap(400, 100, PixelFormat.Format24bppRgb, RgbColor.Yellow);

        using (var graphics = bitmap.GetAdvancedGraphics())
        {
            graphics.FillEllipse(new SolidBrush(RgbColor.Green), new System.Drawing.RectangleF(i, 0, 100, 100));
        }

        bitmap.ColorManagement.Convert(PixelFormat.Format8bppIndexed);

        Pipeline.Run(bitmap + writer);
    }
}]]></code>
    <io>
      <out_preview>
        <file>WriteAnimatedGif.gif</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/WebP/WriteAnimatedWebP.cs">
    <title>Write Animated WebP</title>
    <description>Writes simple animated image in WebP format.</description>
    <instruction>Writes a simple animated image in WebP format using generated bitmap frames.</instruction>
    <output><![CDATA[The following code:

- Creates a new WebP animation with a frame delay of 250 milliseconds.
- Loops through positions horizontally from 0 to 375, incrementing by 25.
- For each frame, creates a 400x100 yellow bitmap.
- Draws a green ellipse at the current position to simulate animation.
- Writes each frame to the WebP output using `Pipeline.Run()` for efficient streaming.]]></output>
    <tags>
      <tag id="webp" title="WEBP" description="Reading and writing WebP images" />
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="multi-frame" title="Multiple frames" description="Handling multi-frame image formats" />
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;
using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var writer = new WebPWriter("WriteAnimatedWebP.webp"))
{
    writer.FrameOptions.Delay = 250;

    for (int i = 0; i < 400; i += 25)
    {
        var bitmap = new Bitmap(400, 100, PixelFormat.Format24bppRgb, RgbColor.Yellow);

        using (var graphics = bitmap.GetAdvancedGraphics())
        {
            graphics.FillEllipse(new SolidBrush(RgbColor.Green), new System.Drawing.RectangleF(i, 0, 100, 100));
        }

        Pipeline.Run(bitmap + writer);
    }
}]]></code>
    <io>
      <out_preview>
        <file>WriteAnimatedWebP.webp</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/Eps/WriteBitmapToEps.cs">
    <title>Write bitmap to EPS</title>
    <description>Saves bitmap to EPS format.</description>
    <instruction>Load a JPEG image and save it as an EPS file.</instruction>
    <output><![CDATA[Here is a C# program that loads a JPEG image and exports it to the EPS format:

This code reads `Chicago.jpg` and saves it as `WriteEps.eps`. It performs a direct conversion without using the memory-friendly Pipeline API.]]></output>
    <tags>
      <tag id="read" title="Read" description="Reading images with codecs" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
      <tag id="jpg" title="JPG" description="Reading and writing JPEG images" />
      <tag id="write" title="Write" description="Writing images with codecs" />
      <tag id="eps" title="EPS" description="Importing and exporting EPS files" />
      <tag id="format-conversion" title="Format Conversion" description="Converting images between formats" />
      <tag id="filesystem" title="Filesystem" description="Loading and saving images from files" />
    </tags>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Chicago.jpg"))
{
    bitmap.Save("WriteEps.eps");
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_download>
        <file>WriteEps.eps</file>
      </out_download>
    </io>
  </sample>
  <sample path="Codecs/Pdf/WriteBitmapToPdfMemoryFriendly.cs">
    <title>Write Bitmap To PDF Memory Friendly</title>
    <description>Saved bitmap to PDF format using memory-friendly Pipeline API.</description>
    <instruction>Write a C# program that reads a JPEG image and saves it to a PDF format using a memory-friendly Pipeline API.</instruction>
    <output><![CDATA[Below is a C# code sample that demonstrates how to read a JPEG image and save it to a PDF using a memory-friendly approach with the Pipeline API:

This code reads an image from a JPEG file and writes it to a PDF document without loading the entire image into memory at once, making the operation more memory efficient.]]></output>
    <tags>
      <tag id="jpg" title="JPG" description="Reading and writing JPEG images" />
      <tag id="pdf" title="PDF" description="Importing and exporting PDF documents" />
      <tag id="format-conversion" title="Format Conversion" description="Converting images between formats" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var reader = new JpegReader("Chicago.jpg"))
using (var writer = new PdfWriter("WritePdfMemoryFriendly.pdf"))
{
    Pipeline.Run(reader + writer);
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>WritePdfMemoryFriendly.png</file>
      </out_preview>
      <out_download>
        <file>WritePdfMemoryFriendly.pdf</file>
      </out_download>
    </io>
  </sample>
  <sample path="Metadata/EXIFAndIPTC/WriteExifIptc.cs">
    <title>Write EXIF and IPTC</title>
    <description>Writes EXIF and IPTC metadata.</description>
    <instruction>Write custom EXIF and IPTC metadata to a JPEG image using Aurigma Graphics Mill, setting values for the software and keywords.</instruction>
    <output><![CDATA[The code:

- Creates a new JPEG settings object with a quality setting of 70.
- Sets custom EXIF data for the "Software" tag to "Aurigma Graphics Mill".
- Sets custom IPTC data, including a keyword "mountain" and a city "Olympia".
- Saves the modified JPEG image with the custom EXIF and IPTC metadata to the specified file.]]></output>
    <tags>
      <tag id="exif" title="EXIF" description="Managing EXIF metadata" />
      <tag id="iptc" title="IPTC" description="Managing IPTC metadata" />
      <tag id="write" title="Write" description="Writing images with codecs" />
    </tags>
    <code language="csharp"><![CDATA[using (var bitmap = new Aurigma.GraphicsMill.Bitmap("Chicago.jpg"))
{
    var settings = new Aurigma.GraphicsMill.Codecs.JpegSettings(70);

    var exif = new Aurigma.GraphicsMill.Codecs.ExifDictionary();
    exif[Aurigma.GraphicsMill.Codecs.ExifDictionary.Software] = "Aurigma Graphics Mill";
    settings.Exif = exif;

    var iptc = new Aurigma.GraphicsMill.Codecs.IptcDictionary();
    iptc[Aurigma.GraphicsMill.Codecs.IptcDictionary.Keyword] = "mountain";
    iptc[Aurigma.GraphicsMill.Codecs.IptcDictionary.City] = "Olympia";
    settings.Iptc = iptc;

    bitmap.Save("WriteExifIptc.jpg", settings);
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>WriteExifIptc.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Metadata/EXIFAndIPTC/WriteExifIptcMemoryFriendly.cs">
    <title>Write EXIF and IPTC (Memory Friendly)</title>
    <description>Writes EXIF and IPTC metadata using memory-friendly Pipeline API.</description>
    <instruction>Write custom EXIF and IPTC metadata to a JPEG image using memory-friendly pipeline processing.</instruction>
    <output><![CDATA[The code:

- Creates a new `JpegReader` to read the input image.
- Sets custom EXIF metadata, including the "Software" tag with the value "Aurigma Graphics Mill".
- Sets custom IPTC metadata, including a keyword "mountain" and a city "Olympia".
- Uses the `Pipeline` to process the image and write the modified metadata to a new JPEG file with the specified quality.]]></output>
    <tags>
      <tag id="exif" title="EXIF" description="Managing EXIF metadata" />
      <tag id="iptc" title="IPTC" description="Managing IPTC metadata" />
      <tag id="write" title="Write" description="Writing images with codecs" />
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var jpegReader = new JpegReader("Chicago.jpg"))
using (var jpegWriter = new JpegWriter("WriteExifIptcMemoryFriendly.jpg", 70))
{
    var exif = new ExifDictionary();
    exif[ExifDictionary.Software] = "Aurigma Graphics Mill";
    jpegWriter.Exif = exif;

    var iptc = new IptcDictionary();
    iptc[IptcDictionary.Keyword] = "mountain";
    iptc[IptcDictionary.City] = "Olympia";
    jpegWriter.Iptc = iptc;

    Pipeline.Run(jpegReader + jpegWriter);
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>WriteExifIptcMemoryFriendly.jpg</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/Tiff/WriteExtraChannel.cs">
    <title>Write Extra Channel</title>
    <description>Creates a TIFF image with an extra channel.</description>
    <instruction>Add an extra alpha channel to a base TIFF image using a grayscale bitmap as the source.</instruction>
    <output><![CDATA[The following code reads a base TIFF file and adds an extra grayscale image as an alpha channel, then saves the result:

Ensure the extra channel image is grayscale and matches the base image in size and DPI.]]></output>
    <tags>
      <tag id="tiff" title="TIFF" description="Reading and writing TIFF images" />
      <tag id="extra-channels" title="Extra Channels" description="Working with TIFF extra channels" />
      <tag id="write" title="Write" description="Writing images with codecs" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var reader = new TiffReader("Copenhagen_Resized.tif"))
using (var writer = new TiffWriter("CopenhagenWithExtraChannel.tif"))
{
    // Load bitmap for the extra channel.
    // Note: image for extra channel must be grayscale and have the same dimensions and DPI as the source one.
    using (var extraBitmap = new Bitmap("Copenhagen_Extra.tif"))
    {
        // Create extra channel options based on extraBitmap.
        var extraChannel = new TiffExtraChannelEntry(extraBitmap, TiffChannelType.Alpha);

        writer.ExtraChannels.Add(extraChannel);
        Pipeline.Run(reader + writer);
    }
}]]></code>
    <io>
      <in_download>
        <file>Copenhagen_Resized.tif</file>
        <file>Copenhagen_Extra.tif</file>
      </in_download>
      <out_download>
        <file>CopenhagenWithExtraChannel.tif</file>
      </out_download>
    </io>
  </sample>
  <sample path="Codecs/Tiff/WriteExtraChannelWithDisplayInfo.cs">
    <title>Write Extra Channel With Display Info</title>
    <description>Saves extra channels with display info to Adobe Resources.</description>
    <instruction>Create a TIFF image with multiple extra channels, each representing a different color space, and save display information into Adobe resources.</instruction>
    <output><![CDATA[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.]]></output>
    <tags>
      <tag id="tiff" title="TIFF" description="Reading and writing TIFF images" />
      <tag id="extra-channels" title="Extra Channels" description="Working with TIFF extra channels" />
      <tag id="adobe-resources" title="Adobe Resources" description="Working with Adobe image resource blocks" />
      <tag id="write" title="Write" description="Writing images with codecs" />
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
    </tags>
    <usings><![CDATA[using System.Collections.Generic;
using Aurigma.GraphicsMill;
using Aurigma.GraphicsMill.AdvancedDrawing;
using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[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.GetAdvancedGraphics())
    {
        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());
}]]></code>
    <io>
      <out_download>
        <file>AdobeResourcesWithDisplayInfo.tif</file>
      </out_download>
    </io>
  </sample>
  <sample path="Codecs/Tiff/WriteExtraChannelWithName.cs">
    <title>Write Extra Channel With Name</title>
    <description>Save the name of an extra channel to Adobe Resources.</description>
    <instruction>Save an extra channel with a custom name to a TIFF image using Adobe resources.</instruction>
    <output><![CDATA[The following code:

- Adds a grayscale extra channel to a base TIFF image.
- Assigns the channel type as `Color`.
- Encodes the name `"MyChannelName"` using the Adobe Photoshop resource ID `0x0415` for Unicode Alpha Names.
- Stores this information in the `AdobeResourceDictionary` associated with the TIFF writer.
This ensures that the extra channel has a meaningful label that compatible applications can recognize.]]></output>
    <tags>
      <tag id="tiff" title="TIFF" description="Reading and writing TIFF images" />
      <tag id="extra-channels" title="Extra Channels" description="Working with TIFF extra channels" />
      <tag id="adobe-resources" title="Adobe Resources" description="Working with Adobe image resource blocks" />
      <tag id="write" title="Write" description="Writing images with codecs" />
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
    </tags>
    <usings><![CDATA[using System.Collections.Generic;
using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[public static void Run()
{
    string channelName = "MyChannelName";

    using (var reader = new TiffReader("Copenhagen_Resized.tif"))
    using (var writer = new TiffWriter("BusinessCardExtraChannelWithName.tif"))
    using (var extraChannel = new Bitmap(reader.Width, reader.Height, PixelFormat.Format8bppGrayscale))
    {
        writer.ExtraChannels.Add(new TiffExtraChannelEntry(extraChannel, TiffChannelType.Color));

        var ar = new AdobeResourceDictionary();

        // https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/
        const int unicodeAlphaNames = 0x0415;

        ar[unicodeAlphaNames] = ChannelNameToResource(channelName);
        writer.AdobeResources = ar;
        Pipeline.Run(reader + writer);
    }
}

private static AdobeResourceBlock ChannelNameToResource(string name)
{
    var arr = new List<byte>();

    arr.AddRange(new byte[] { 0, 0 });
    arr.AddRange(new byte[] { 0, (byte)(name.Length + 1) });

    foreach (var ch in name)
    {
        arr.AddRange(new byte[] { 0, (byte)ch });
    }

    arr.AddRange(new byte[] { 0, 0 });

    return new AdobeResourceBlock(string.Empty, arr.ToArray());
}]]></code>
    <io>
      <in_download>
        <file>Copenhagen_Resized.tif</file>
      </in_download>
      <out_download>
        <file>BusinessCardExtraChannelWithName.tif</file>
      </out_download>
    </io>
  </sample>
  <sample path="Codecs/CustomCodecs/WriteImageWithWPF.cs">
    <title>Write image with WPF</title>
    <description>Demonstrates writing an image from a pipeline with the custom image writer.</description>
    <instruction>Demonstrate how to pass an image to a pipeline using a custom image writer.</instruction>
    <output><![CDATA[Here is a C# program that utilizes a custom image writer to save an image using the memory-friendly Pipeline API:

This code defines `WPFImageWriter`, a custom image writer that processes image data in stripes and saves it as a TIFF file with ZIP compression. The `WriteImageWithWPF.Run()` method reads a JPEG image and writes it to `WroteByWPF.tif` using the Pipeline API.]]></output>
    <tags>
      <tag id="read" title="Read" description="Reading images with codecs" />
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
      <tag id="metadata" title="Metadata" description="Reading and writing image metadata" />
      <tag id="tiff" title="TIFF" description="Reading and writing TIFF images" />
      <tag id="write" title="Write" description="Writing images with codecs" />
      <tag id="format-conversion" title="Format Conversion" description="Converting images between formats" />
      <tag id="wpf" title="WPF" description="Interoperability and conversion with WPF images" />
      <tag id="stream" title="Stream" description="Reading and writing images from streams" />
    </tags>
    <usings><![CDATA[using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Media.Imaging;
using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[public sealed class WPFImageWriter : IImageWriter
{
    private readonly Stream stream;
    private WriteableBitmap writeableBitmap;
    private int offset = 0;

    public WPFImageWriter(Stream stream)
    {
        this.stream = stream;
    }

    public void Init(ImageParams imageParams)
    {
        this.writeableBitmap = new WriteableBitmap(
            imageParams.Width,
            imageParams.Height,
            (double)imageParams.DpiX,
            (double)imageParams.DpiY,
            ConvertFormat(imageParams.PixelFormat),
            null);
    }

    public void WriteStripe(Bitmap stripe)
    {
        try
        {
            this.writeableBitmap.Lock();

            IntPtr backBufferLine = this.writeableBitmap.BackBuffer + (this.writeableBitmap.BackBufferStride * this.offset);

            IntPtr stripeLine = stripe.Scan0;

            unsafe
            {
                for (int i = 0; i < stripe.Height; i++)
                {
                    Buffer.MemoryCopy(stripeLine.ToPointer(), backBufferLine.ToPointer(), this.writeableBitmap.BackBufferStride, stripe.Stride);
                    backBufferLine += this.writeableBitmap.BackBufferStride;
                    stripeLine += stripe.Stride;
                }
            }
        }
        finally
        {
            this.writeableBitmap.Unlock();
        }

        this.offset += stripe.Height;

        if (this.offset == this.writeableBitmap.PixelHeight)
        {
            var encoder = new TiffBitmapEncoder();

            encoder.Compression = TiffCompressOption.Zip;
            encoder.Frames.Add(BitmapFrame.Create(this.writeableBitmap));

            encoder.Save(this.stream);
        }
    }

    /// <summary>
    /// Converts Graphics Mill pixel format to corresponding one for WPF.
    /// </summary>
    private static System.Windows.Media.PixelFormat ConvertFormat(Aurigma.GraphicsMill.PixelFormat format)
    {
        var dict = new Dictionary<Aurigma.GraphicsMill.PixelFormat, System.Windows.Media.PixelFormat>
        {
            { Aurigma.GraphicsMill.PixelFormat.Format24bppRgb, System.Windows.Media.PixelFormats.Bgr24 },
            { Aurigma.GraphicsMill.PixelFormat.Format32bppRgb, System.Windows.Media.PixelFormats.Bgr32 },
            { Aurigma.GraphicsMill.PixelFormat.Format32bppArgb, System.Windows.Media.PixelFormats.Bgra32 },
            { Aurigma.GraphicsMill.PixelFormat.Format8bppGrayscale, System.Windows.Media.PixelFormats.Gray8 },
            { Aurigma.GraphicsMill.PixelFormat.Format16bppGrayscale, System.Windows.Media.PixelFormats.Gray16 },
        };

        if (!dict.ContainsKey(format))
        {
            throw new Aurigma.GraphicsMill.UnsupportedPixelFormatException();
        }

        return dict[format];
    }
}

internal class WriteImageWithWPF
{
    public static void Run()
    {
        using (var reader = ImageReader.Create("flower.jpg"))
        using (var fs = new FileStream("WroteByWPF.tif", FileMode.Create, FileAccess.Write))
        using (var writer = new CustomImageWriter(new WPFImageWriter(fs)))
        {
            Pipeline.Run(reader + writer);
        }
    }
}]]></code>
    <io>
      <in_download>
        <file>flower.jpg</file>
      </in_download>
      <out_download>
        <file>WroteByWPF.tif</file>
      </out_download>
    </io>
  </sample>
  <sample path="Codecs/Tiff/WriteMultiframeTiff.cs">
    <title>Write Multiframe TIFF</title>
    <description>Demonstrates how to create a TIFF file with multiple frames.</description>
    <instruction>Create a TIFF file containing multiple frames, each with its own compression configuration.</instruction>
    <output><![CDATA[The following code:

- Creates a new multiframe TIFF file using `TiffWriter`.
- Adds two frames to the TIFF:
- `frame1` (from "Chicago.jpg") is saved using JPEG compression with 85% quality.
- `frame2` (from "Copenhagen_RGB.jpg") is saved using LZW compression.
- Each frame is written to the TIFF using the `Pipeline.Run()` method, allowing memory-friendly processing.]]></output>
    <tags>
      <tag id="tiff" title="TIFF" description="Reading and writing TIFF images" />
      <tag id="multi-frame" title="Multiple frames" description="Handling multi-frame image formats" />
      <tag id="write" title="Write" description="Writing images with codecs" />
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var writer = new TiffWriter("WriteMultiframeTiff.tif"))
{
    using (var frame1 = new Bitmap("Chicago.jpg"))
    {
        // You can specify the compression of each frame separately
        writer.Compression = CompressionType.Jpeg;
        writer.Quality = 85;

        Pipeline.Run(frame1 + writer);
    }

    using (var frame2 = new Bitmap("Copenhagen_RGB.jpg"))
    {
        writer.Compression = CompressionType.Lzw;

        Pipeline.Run(frame2 + writer);
    }
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
        <file>Copenhagen_RGB.jpg</file>
      </in_preview>
      <out_download>
        <file>WriteMultiframeTiff.tif</file>
      </out_download>
    </io>
  </sample>
  <sample path="Codecs/Png/WritePng.cs">
    <title>Write PNG Image</title>
    <description>Reads image in JPEG format and saves to PNG format.</description>
    <instruction>Write a C# program that reads an image in JPEG format and saves it as a PNG format image. The program should flip the image vertically before saving it.</instruction>
    <output><![CDATA[Below is a C# code sample that demonstrates how to read an image in JPEG format, flip it vertically, and then save it as a PNG format image:

This code reads a JPEG image, applies a vertical flip transformation, and saves it as a PNG file.]]></output>
    <tags>
      <tag id="jpg" title="JPG" description="Reading and writing JPEG images" />
      <tag id="png" title="PNG" description="Reading and writing PNG images" />
      <tag id="format-conversion" title="Format Conversion" description="Converting images between formats" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Chicago.jpg"))
{
    bitmap.Transforms.Flip(FlipType.Vertical);
    bitmap.Save("WritePng.png");
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>WritePng.png</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/Eps/WriteRasterAndVectorGraphicsToEps.cs">
    <title>Write raster and vector graphics to EPS</title>
    <description>Saves raster and vector graphics to EPS format.</description>
    <instruction>Create an EPS file and draw both a bitmap and vector graphics (a rectangle and text) onto it.</instruction>
    <output><![CDATA[Here is a C# program that creates an EPS file containing a bitmap image, a rectangle, and a styled text label:

This code uses `EpsWriter` to create `WriteRasterAndVectorGraphicsToEPS.eps`, draws a bitmap (`Chicago.jpg`), a gray rectangle, and the word "Confidential" in large orange-red text. It demonstrates combining raster and vector elements in a single EPS file.]]></output>
    <tags>
      <tag id="eps" title="EPS" description="Importing and exporting EPS files" />
      <tag id="filesystem" title="Filesystem" description="Loading and saving images from files" />
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="text" title="Text" description="Rendering and formatting text" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;
using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var writer = new EpsWriter("WriteRasterAndVectorGraphicsToEPS.eps", 800, 650))
using (var graphics = writer.GetGraphics())
{
    // Draw bitmap
    using (var bitmap = new Bitmap("Chicago.jpg"))
    {
        graphics.DrawImage(bitmap, 100f, 100f);
    }

    // Draw rectangle
    graphics.DrawRectangle(new Pen(RgbColor.Gray, 4f), 50f, 50f, 700f, 550f);

    // Draw text
    var font = graphics.CreateFont("Arial", 56f);
    var text = new PlainText("Confidential", font, new SolidBrush(RgbColor.OrangeRed), 400f, 340f, TextAlignment.Center);

    graphics.DrawText(text);
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_download>
        <file>WriteRasterAndVectorGraphicsToEPS.eps</file>
      </out_download>
    </io>
  </sample>
  <sample path="Codecs/Pdf/WriteRasterAndVectorGraphicsToPdf.cs">
    <title>Write Raster And Vector Graphics To PDF</title>
    <description>Saves raster and vector graphics to PDF format.</description>
    <instruction>Write a C# program that saves both raster and vector graphics to a PDF file, with compression applied to reduce file size.</instruction>
    <output><![CDATA[Below is a C# code sample that demonstrates how to save both raster (bitmap) and vector graphics (rectangle and text) to a PDF file, with file size reduction using JPEG compression:

This code creates a PDF document with both raster and vector elements. It draws a bitmap image, a rectangle, and some text, applying compression to reduce the output file size.]]></output>
    <tags>
      <tag id="pdf" title="PDF" description="Importing and exporting PDF documents" />
      <tag id="drawing" title="Drawing" description="Drawing vector shapes and text" />
      <tag id="text" title="Text" description="Rendering and formatting text" />
      <tag id="write" title="Write" description="Writing images with codecs" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;
using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var writer = new PdfWriter("WriteRasterAndVectorGraphicsToPdf.pdf"))
{
    // Reduce output file size
    writer.Compression = CompressionType.Jpeg;
    writer.Quality = 80;

    writer.AddPage(800, 650, RgbColor.White);

    using (var graphics = writer.GetGraphics())
    {
        // Draw bitmap
        using (var bitmap = new Bitmap("Chicago.jpg"))
        {
            graphics.DrawImage(bitmap, 100f, 100f);
        }

        // Draw rectangle
        graphics.DrawRectangle(new Pen(RgbColor.Gray, 4f), 50f, 50f, 700f, 550f);

        // Draw text
        var font = graphics.CreateFont("Arial", 56f);
        var text = new PlainText("Confidential", font, new SolidBrush(RgbColor.OrangeRed), 400f, 340f, TextAlignment.Center);

        graphics.DrawText(text);
    }
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>WriteRasterAndVectorGraphicsToPdf.png</file>
      </out_preview>
      <out_download>
        <file>WriteRasterAndVectorGraphicsToPdf.pdf</file>
      </out_download>
    </io>
  </sample>
  <sample path="Codecs/Pdf/WriteTextToPDF.cs">
    <title>Write Text To PDF</title>
    <description>Demonstrates writing text as PDF text.</description>
    <instruction>Write a C# program that demonstrates how to write text as PDF text (using embedded fonts) to a PDF file, including both plain and round text.</instruction>
    <output><![CDATA[Below is a C# code sample that demonstrates how to write text as PDF text to a PDF file. It includes both plain text and round text, ensuring that text is stored as PDF text rather than graphics.

This code creates a PDF document containing both plain text and round text, with embedded fonts for both types of text.]]></output>
    <tags>
      <tag id="pdf" title="PDF" description="Importing and exporting PDF documents" />
      <tag id="art-text" title="Art Text" description="Creating artistic text" />
      <tag id="write" title="Write" description="Writing images with codecs" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.AdvancedDrawing;
using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var writer = new PdfWriter("TextToPDF.pdf"))
{
    int width = 350;
    int height = 200;

    using (var graphics = writer.GetGraphics())
    {
        // Text objects will be saved as a PDF text with embedded fonts.
        // The only type of text that can't be saved as text is DoublePath text.
        writer.TextOutputMode = PdfTextOutputMode.Text;

        writer.AddPage(width, height, RgbColor.White);

        var font = graphics.CreateFont("Arial", 18f);

        // Plain text
        var plainText = new PlainText("plain text", font, new SolidBrush(RgbColor.Black), 95f, 41f, TextAlignment.Center);
        graphics.DrawText(plainText);

        // Round text
        var roundText = new Aurigma.GraphicsMill.AdvancedDrawing.Art.RoundText("round text", font)
        {
            Center = new System.Drawing.PointF(width / 2.0f, height / 2.0f),
            Bend = 0.5f,
        };

        graphics.DrawText(roundText);
    }
}]]></code>
    <io>
      <out_preview>
        <file>TextToPDF.png</file>
      </out_preview>
      <out_download>
        <file>TextToPDF.pdf</file>
      </out_download>
    </io>
  </sample>
  <sample path="Codecs/Tga/WriteTga.cs">
    <title>Write TGA</title>
    <description>Reads an image in JPEG format, flips it vertically, and saves it in TARGA format.</description>
    <instruction>Write a C# program that reads an image in JPEG format, flips it vertically, and saves it in TARGA format.</instruction>
    <output><![CDATA[Below is a C# code sample that demonstrates how to read a JPEG image, flip it vertically, and save it in TARGA format.

This code reads a JPEG image, applies a vertical flip, and saves the result as a TARGA image.]]></output>
    <tags>
      <tag id="tga" title="TGA" description="Reading and writing TGA images" />
      <tag id="jpg" title="JPG" description="Reading and writing JPEG images" />
      <tag id="format-conversion" title="Format Conversion" description="Converting images between formats" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Chicago.jpg"))
{
    bitmap.Transforms.Flip(FlipType.Vertical);
    bitmap.Save("WriteTga.tga");
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_download>
        <file>WriteTga.tga</file>
      </out_download>
    </io>
  </sample>
  <sample path="Codecs/Tiff/WriteTiff.cs">
    <title>Write TIFF</title>
    <description>Loads a JPEG image and converts it to TIFF format.</description>
    <instruction>Read an image in JPEG format and save it to TIFF format with JPEG compression.</instruction>
    <output><![CDATA[The following code:

- Loads a JPEG image ("Chicago.jpg") into a `Bitmap`.
- Applies a vertical flip transformation to the image.
- Creates a `TiffSettings` object with JPEG compression and sets quality to 85.
- Saves the modified image to a TIFF file ("WriteTiff.tif") using the specified compression settings.]]></output>
    <tags>
      <tag id="tiff" title="TIFF" description="Reading and writing TIFF images" />
      <tag id="jpg" title="JPG" description="Reading and writing JPEG images" />
      <tag id="format-conversion" title="Format Conversion" description="Converting images between formats" />
      <tag id="bitmap" title="Bitmap" description="Working with images via the Bitmap API" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Transforms;]]></usings>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Chicago.jpg"))
{
    bitmap.Transforms.Flip(FlipType.Vertical);

    var tiffSettings = new TiffSettings()
    {
        Compression = CompressionType.Jpeg,
        Quality = 85,
    };

    bitmap.Save("WriteTiff.tif", tiffSettings);
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_download>
        <file>WriteTiff.tif</file>
      </out_download>
    </io>
  </sample>
  <sample path="Codecs/WebP/WriteWebP.cs">
    <title>Write WebP</title>
    <description>Reads image in JPEG format and saves to WebP format.</description>
    <instruction>Reads an image in JPEG format and saves it to WebP format with specified quality settings.</instruction>
    <output><![CDATA[The following code:

- Loads the JPEG image into a bitmap.
- Specifies WebP settings with a quality of 100 (maximum quality).
- Saves the bitmap as a WebP image using the specified settings.]]></output>
    <tags>
      <tag id="webp" title="WEBP" description="Reading and writing WebP images" />
      <tag id="jpg" title="JPG" description="Reading and writing JPEG images" />
      <tag id="format-conversion" title="Format Conversion" description="Converting images between formats" />
    </tags>
    <usings><![CDATA[using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var bitmap = new Bitmap("Chicago.jpg"))
{
    var webPSettings = new WebPSettings(100);

    bitmap.Save("WriteWebP.webp", webPSettings);
}]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>WriteWebP.webp</file>
      </out_preview>
    </io>
  </sample>
  <sample path="Codecs/WebP/WriteWebPLossyAndLossless.cs">
    <title>Write WebP Lossy And Lossless</title>
    <description>Writes image in WebP lossy and lossless format.</description>
    <instruction>Reads an image in JPEG format and saves it to WebP format in both lossy and lossless compression formats.</instruction>
    <output><![CDATA[The following code:

- Loads the JPEG image using the `JpegReader`.
- Creates two WebP writers: one for lossy compression and one for lossless compression.
- Saves the image to WebP with lossy compression at a quality of 85.
- Saves the image to WebP with lossless compression.
- Prints the file sizes of the lossy and lossless WebP files.]]></output>
    <tags>
      <tag id="webp" title="WEBP" description="Reading and writing WebP images" />
      <tag id="jpg" title="JPG" description="Reading and writing JPEG images" />
      <tag id="format-conversion" title="Format Conversion" description="Converting images between formats" />
      <tag id="pipeline" title="Pipeline" description="Working with images via the Pipeline API" />
      <tag id="compression" title="Compression" description="Tuning image compression settings" />
    </tags>
    <usings><![CDATA[using System;
using Aurigma.GraphicsMill.Codecs;]]></usings>
    <code language="csharp"><![CDATA[using (var reader = new JpegReader("Chicago.jpg"))
using (var writerLossy = new WebPWriter("WriteWebPLossy.webp"))
using (var writerLossless = new WebPWriter("WriteWebPLossless.webp"))
{
    writerLossy.Quality = 85f;
    Pipeline.Run(reader + writerLossy);

    writerLossy.FrameOptions.Lossless = true;
    Pipeline.Run(reader + writerLossless);
}

var lossy = new System.IO.FileInfo("WriteWebPLossy.webp");
var lossless = new System.IO.FileInfo("WriteWebPLossless.webp");

Console.WriteLine("Lossy WebP: {0} b", lossy.Length);
Console.WriteLine("Lossless WebP: {0} b", lossless.Length);]]></code>
    <io>
      <in_preview>
        <file>Chicago.jpg</file>
      </in_preview>
      <out_preview>
        <file>WriteWebPLossy.webp</file>
        <file>WriteWebPLossless.webp</file>
      </out_preview>
    </io>
  </sample>
</samples>