Initial introduction and getting started guides for ImageSharp.Drawing and Fonts

This commit is contained in:
Scott Williams 2020-04-19 12:55:09 +01:00
Родитель 6ce98a7dc0
Коммит 10dae47624
35 изменённых файлов: 1621 добавлений и 63137 удалений

Просмотреть файл

@ -0,0 +1,134 @@
# Custom Rendering
>[!WARNING]
>Fonts is still considered BETA quality and we still reserve the rights to change the API shapes. We are yet to priorities performance in our font loading and layout APIs.
>[!NOTE]
>ImageSharp.Drawing already implements the glyph rendering for you unless you are rendering on other platforms we would recommend using the version build into that library.. this is a more advanced topic.
### Implementing a glyph renderer
The abstraction used by `Fonts` to allow implementing glyph rendering is the `IGlyphRenderer` and its brother `IColoredGlypheRenderer` (for colored emoji support).
```c#
// `IColoredGlyphRenderer` implements `IGlyphRenderer` so if you don't want colored font support just implement `IGlyphRenderer`.
public class CustomGlyphRenderer : IColoredGlyphRenderer
{
/// <summary>
/// Called before any glyphs have been rendered.
/// </summary>
/// <param name="bounds">The bounds the text will be rendered at and at whats size.</param>
void IGlyphRenderer.BeginText(FontRectangle bounds)
{
// called before any thing else to provide access to the total required size to redner the text
}
/// <summary>
/// Begins the glyph.
/// </summary>
/// <param name="bounds">The bounds the glyph will be rendered at and at what size.</param>
/// <param name="paramaters">The set of paramaters that uniquely represents a version of a glyph in at particular font size, font family, font style and DPI.</param>
/// <returns>Returns true if the glyph should be rendered othersie it returns false.</returns>
bool IGlyphRenderer.BeginGlyph(FontRectangle bounds, GlyphRendererParameters paramaters)
{
// called before each glyph/glyph layer is rendered.
// The paramaters can be used to detect the exact details
// of the glyph so that duplicate glyphs could optionally
// be cached to reduce processing.
// You can return false to skip all the figures within the glyph (if you return false EndGlyph will still be called)
}
/// <summary>
/// Sets the color to use for the current glyph.
/// </summary>
/// <param name="color">The color to override the renders brush with.</param>
void IColorGlyphRenderer.SetColor(GlyphColor color)
{
// from the IColorGlyphRenderer version, onlt called if the current glyph should override the forgound color of current glyph/layer
}
/// <summary>
/// Begins the figure.
/// </summary>
void IGlyphRenderer.BeginFigure()
{
// called at the start of the figure within the single glyph/layer
// glyphs are rendered as a serise of arcs, lines and movements
// which together describe a complex shape.
}
/// <summary>
/// Sets a new start point to draw lines from
/// </summary>
/// <param name="point">The point.</param>
void IGlyphRenderer.MoveTo(Vector2 point)
{
// move current point to location marked by point without describing a line;
}
/// <summary>
/// Draw a quadratic bezier curve connecting the previous point to <paramref name="point"/>.
/// </summary>
/// <param name="secondControlPoint">The second control point.</param>
/// <param name="point">The point.</param>
void IGlyphRenderer.QuadraticBezierTo(Vector2 secondControlPoint, Vector2 point)
{
// describes Quadratic Bezier curve from the 'current point' using the
// 'second control point' and final 'point' leaving the 'current point'
// at 'point'
}
/// <summary>
/// Draw a Cubics bezier curve connecting the previous point to <paramref name="point"/>.
/// </summary>
/// <param name="secondControlPoint">The second control point.</param>
/// <param name="thirdControlPoint">The third control point.</param>
/// <param name="point">The point.</param>
void IGlyphRenderer.CubicBezierTo(Vector2 secondControlPoint, Vector2 thirdControlPoint, Vector2 point)
{
// describes Cubic Bezier curve from the 'current point' using the
// 'second control point', 'third control point' and final 'point'
// leaving the 'current point' at 'point'
}
/// <summary>
/// Draw a straight line connecting the previous point to <paramref name="point"/>.
/// </summary>
/// <param name="point">The point.</param>
void IGlyphRenderer.LineTo(Vector2 point)
{
// describes straight line from the 'current point' to the final 'point'
// leaving the 'current point' at 'point'
}
/// <summary>
/// Ends the figure.
/// </summary>
void IGlyphRenderer.EndFigure()
{
// Called after the figure has completed denoting a straight line should
// be drawn from the current point to the first point
}
/// <summary>
/// Ends the glyph.
/// </summary>
void IGlyphRenderer.EndGlyph()
{
// says the all figures have completed for the current glyph/layer.
// NOTE this will be called even if BeginGlyph return false.
}
/// <summary>
/// Called once all glyphs have completed rendering
/// </summary>
void IGlyphRenderer.EndText()
{
//once all glyphs/layers have been drawn this is called.
}
}
```

Просмотреть файл

@ -0,0 +1,59 @@
# Getting Started
>[!WARNING]
>Fonts is still considered BETA quality and we still reserve the rights to change the API shapes. We are yet to priorities performance in our font loading and layout APIs.
>[!NOTE]
>The official guide assumes intermediate level knowledge of C# and .NET. If you are totally new to .NET development, it might not be the best idea to jump right into a framework as your first step - grasp the basics then come back. Prior experience with other languages and frameworks helps, but is not required.
### Fonts
Fonts provides the core to your text layout and loading subsystems.
- `SixLabors.Fonts.FontCollection` is the root type you will configure and load up with all the TrueType/OpenType/Woff fonts. (font loading is deemed expensive and should be done once and shared across multiple rasterizations)
- `SixLabors.Fonts.Font` is our currying type for passing information about your chosen font face.
### Loading Fonts
Fonts provides several options for loading fonts, you can load then from a streams or files, we also support loading collections out of *.TTC files and well as single variants out if individual *.TTF files. We also support loading *.woff files.
#### Minimal Example
```c#
using SixLabors.Fonts;
FontCollection collection = new FontCollection();
FontFamily family = collection.Install("path/to/font.ttf");
Font font = family.Create(12, FontStyle.Italic);
// "font" can now be used in calls to DrawText from our ImageSharp.Drawing library.
```
#### Expanded Example
```c#
using SixLabors.Fonts;
FontCollection collection = new FontCollection();
collection.Install("path/to/font.ttf");
collection.Install("path/to/font2.ttf");
collection.Install("path/to/emojiFont.ttf");
collection.InstallCollection("path/to/font.ttc");
if(collection.TryFind("Font Name", out FontFamily family))
if(collection.TryFind("Emoji Font Name", out FontFamily emojiFamily))
{
// family will not be null here
Font font = family.Create(12, FontStyle.Italic);
RendererOptions options = new RendererOptions(font, dpi: 72)
{
ApplyKerning = true,
FallbackFontFamilies = new []
{
emojiFamily // will be used if a particular code point doesn't exist in the font passed into the constructor. (e.g. emoji)
}
};
FontRectangle rect = TextMeasurer.Measure("Text to measure", options);
}
```

46
articles/fonts/index.md Normal file
Просмотреть файл

@ -0,0 +1,46 @@
# Introduction
>[!WARNING]
>Fonts is still considered BETA quality and we still reserve the rights to change the API shapes. WE are yet to priorities performance in our drawing APIs.
### What is Fonts?
Fonts is a font loading and layout library built primarily to provide text drawing support to ImageSharp.Drawing.
Built against [.NET Standard 1.3](https://docs.microsoft.com/en-us/dotnet/standard/net-standard), Fonts can be used in device, cloud, and embedded/IoT scenarios.
### License
Fonts is licensed under under the terms of [GNU Affero General
Public License, version 3](https://www.gnu.org/licenses/agpl-3.0.en.html). Commercial licensing options are available in addition to this license, see https://sixlabors.com/pricing for details.
### Installation
ImageSharp.Drawing is installed via [Nuget](https://www.nuget.org/packages/SixLabors.Fonts) with nightly builds available on [MyGet](https://www.myget.org/feed/sixlabors/package/nuget/SixLabors.Fonts).
# [Package Manager](#tab/tabid-1)
```bash
PM > Install-Package SixLabors.Fonts -Version VERSION_NUMBER
```
# [.NET CLI](#tab/tabid-2)
```bash
dotnet add package SixLabors.Fonts --version VERSION_NUMBER
```
# [PackageReference](#tab/tabid-3)
```xml
<PackageReference Include="SixLabors.Fonts" Version="VERSION_NUMBER" />
```
# [Paket CLI](#tab/tabid-4)
```bash
paket add SixLabors.Fonts --version VERSION_NUMBER
```
***
>[!WARNING]
>Prerelease versions installed via the [Visual Studio Nuget Package Manager](https://docs.microsoft.com/en-us/nuget/consume-packages/install-use-packages-visual-studio) require the "include prerelease" checkbox to be checked.

Просмотреть файл

@ -0,0 +1,112 @@
# Getting Started
>[!WARNING]
>ImageSharp.Drawing is still considered BETA quality and we still reserve the rights to change the API shapes. WE are yet to priorities performance in our drawing APIs.
>[!NOTE]
>The official guide assumes intermediate level knowledge of C# and .NET. If you are totally new to .NET development, it might not be the best idea to jump right into a framework as your first step - grasp the basics then come back. Prior experience with other languages and frameworks helps, but is not required.
### ImageSharp.Drawing - Paths and Polygons
ImageSharp.Drawing provides several classes for build and manipulating various shapes and paths.
- @"SixLabors.ImageSharp.Drawing.IPath" Root interface defining a path/polygon and the type that the rasterizer uses to generate pixel output.
- This `SixLabors.ImageSharp.Drawing` namespace contains a variety of available polygons to speed up your drawing process.
In addition to the vector manipulation APIs we also have the rasterization APIs that can convert your @"SixLabors.ImageSharp.Drawing.IPath"s to pixels.
### Drawing Polygons
ImageSharp provides several options for drawing polygons weather you want to draw outlines or fill the shapes.
#### Minimal Example
```c#
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Drawing.Processing;
Image image = ...; // create any way you like.
IPath yourPolygon = new Star(x: 100.0f, y: 100.0f, prongs: 5, innerRadii: 20.0f, outerRadii:30.0f)
image.Mutate( x=> x.Fill(Color.Red, yourPolygon)); // fill the star with red
```
#### Expanded Example
```c#
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Drawing.Processing;
using SixLabors.ImageSharp.PixelFormats;
Image image = ...; // create any way you like.
// The options are optional
ShapeGraphicsOptions options = new ShapeGraphicsOptions()
{
ColorBlendingMode = PixelColorBlendingMode.Multiply
};
IBrush brush = Brushes.Horizontal(Color.Red, Color.Blue);
IPen pen = Pens.DashDot(Color.Green, 5);
IPath yourPolygon = new Star(x: 100.0f, y: 100.0f, prongs: 5, innerRadii: 20.0f, outerRadii:30.0f)
// draws a star with Horizontal red and blue hatching with a dash dot pattern outline.
image.Mutate( x=> x.Fill(options, brush, yourPolygon)
.Draw(option, pen, yourPolygon));
```
### API Cornerstones for Polygon Rasterization
Our `Fill` APIs always work off a `Brush` (some helpers create the brush for you) and will take your provided set of paths and polygons filling in all the pixels inside the vector with the color the brush provides.
Our `Draw` APIs always work off the `Pen` where we processes your vector to create an outline with a certain pattern and fill in the outline with an internal brush inside the pen.
### Drawing Text
ImageSharp.Drawing provides several options for drawing text all overloads of a single `DrawText` API. Our text drawing infrastructure is build on top of our [Fonts](../fonts) library. (See [SixLabors.Fonts](../fonts) for details on handling fonts.)
#### Minimal Example
```c#
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Drawing.Processing;
Image image = ...; // create any way you like.
Font font = ...; // see our Fonts library for best practices on retriving one of these.
string yourText = "this is some sample text";
image.Mutate( x=> x.DrawText(yourText, font, Color.Black, new PointF(10, 10)));
```
#### Expanded Example
```c#
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Drawing.Processing;
using SixLabors.ImageSharp.PixelFormats;
Image image = ...; // create any way you like.
Font font = ...; // see our Fonts library for best practices on retriving one of these.
// The options are optional
TextGraphicsOptions options = new TextGraphicsOptions()
{
ApplyKerning = true,
TabWidth = 8, // a tab renders as 8 spaces wide
WrapTextWidth = 100, // greater than zero so we will word wrap at 100 pixels wide
HorizontalAlignment = HorizontalAlignment.Right // right align
};
IBrush brush = Brushes.Horizontal(Color.Red, Color.Blue);
IPen pen = Pens.DashDot(Color.Green, 5);
string text = "sample text";
// draws a star with Horizontal red and blue hatching with a dash dot pattern outline.
image.Mutate( x=> x.DrawText(options, text, font, brush, pen, new PointF(100, 100));
```

Просмотреть файл

@ -0,0 +1,48 @@
# Introduction
>[!WARNING]
>ImageSharp.Drawing is still considered BETA quality and we still reserve the rights to change the API shapes. WE are yet to priorities performance in our drawing APIs.
### What is ImageSharp.Drawing?
ImageSharp.Drawing is a library build on top on ImageSharp to providing 2D Drawing extensions on top of ImageSharp.
ImageSharp.Drawing is designed from the ground up to be flexible and extensible. The library provides API endpoints for common vector and text processing operations adds the building blocks for building custom image.
Built against [.NET Standard 1.3](https://docs.microsoft.com/en-us/dotnet/standard/net-standard), ImageSharp.Drawing can be used in device, cloud, and embedded/IoT scenarios.
### License
ImageSharp.Drawing is licensed under under the terms of [GNU Affero General
Public License, version 3](https://www.gnu.org/licenses/agpl-3.0.en.html). Commercial licensing options are available in addition to this license, see https://sixlabors.com/pricing for details.
### Installation
ImageSharp.Drawing is installed via [Nuget](https://www.nuget.org/packages/SixLabors.ImageSharp.Drawing) with nightly builds available on [MyGet](https://www.myget.org/feed/sixlabors/package/nuget/SixLabors.ImageSharp.Drawing).
# [Package Manager](#tab/tabid-1)
```bash
PM > Install-Package SixLabors.ImageSharp.Drawing -Version VERSION_NUMBER
```
# [.NET CLI](#tab/tabid-2)
```bash
dotnet add package SixLabors.ImageSharp.Drawing --version VERSION_NUMBER
```
# [PackageReference](#tab/tabid-3)
```xml
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="VERSION_NUMBER" />
```
# [Paket CLI](#tab/tabid-4)
```bash
paket add SixLabors.ImageSharp.Drawing --version VERSION_NUMBER
```
***
>[!WARNING]
>Prerelease versions installed via the [Visual Studio Nuget Package Manager](https://docs.microsoft.com/en-us/nuget/consume-packages/install-use-packages-visual-studio) require the "include prerelease" checkbox to be checked.

Просмотреть файл

@ -1,9 +1,16 @@
# [Introduction](imagesharp/index.md)
# [Getting Started](imagesharp/gettingstarted.md)
## [Pixel Formats](imagesharp/pixelformats.md)
## [Image Formats](imagesharp/imageformats.md)
# [ImageSharp](imagesharp/index.md)
## [Getting Started](imagesharp/gettingstarted.md)
### [Pixel Formats](imagesharp/pixelformats.md)
### [Image Formats](imagesharp/imageformats.md)
## [Processing Images](imagesharp/Processing.md)
## [Working with Pixel Buffers](imagesharp/WorkingWithPixelBuffers.md)
## [Configuration](imagesharp/Configuration.md)
## [Memory Management](imagesharp/MemoryManagement.md)
### [Processing Images](imagesharp/Processing.md)
### [Working with Pixel Buffers](imagesharp/WorkingWithPixelBuffers.md)
### [Configuration](imagesharp/Configuration.md)
### [Memory Management](imagesharp/MemoryManagement.md)
# [ImageSharp.Drawing](imagesharp.drawing/index.md)
## [Getting Started](imagesharp.drawing/gettingstarted.md)
# [Fonts](fonts/index.md)
## [Getting Started](fonts/gettingstarted.md)
## [Custom Rendering](fonts/customrendering.md)

Просмотреть файл

@ -9,7 +9,7 @@
<title>API Documentation </title>
<meta name="viewport" content="width=device-width">
<meta name="title" content="API Documentation ">
<meta name="generator" content="docfx 2.50.0.0">
<meta name="generator" content="docfx 2.52.0.0">
<link rel="shortcut icon" href="../favicon.png">
<link rel="stylesheet" href="../styles/docfx.vendor.css">
@ -17,7 +17,7 @@
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.8/css/all.css" integrity="sha384-3AB7yXWz4OeoZcPbieVW64vVXEwADiYyAEhwilzWsLw+9FgqpyjjStpPnpBO8o8S" crossorigin="anonymous">
<link rel="stylesheet" href="../styles/main.css">
<meta property="docfx:navrel" content="../toc.html">
<meta property="docfx:tocrel" content="toc.html">
<meta property="docfx:tocrel" content="../toc.html">
<meta property="docfx:rel" content="../">
@ -67,14 +67,7 @@
</div>
</div>
<div role="main" class="container body-content hide-when-search">
<div class="sidenav hide-when-search">
<a class="btn toc-toggle collapse" data-toggle="collapse" href="#sidetoggle" aria-expanded="false" aria-controls="sidetoggle">Show / Hide Table of Contents</a>
<div class="sidetoggle collapse" id="sidetoggle">
<div id="sidetoc"></div>
</div>
</div>
<div class="article row grid-right">
<div class="article row grid">
<div class="col-md-10">
<article class="content wrap" id="_content" data-uid="">
<h1 id="api-documentation">API Documentation</h1>

Просмотреть файл

@ -9,7 +9,7 @@
<title> </title>
<meta name="viewport" content="width=device-width">
<meta name="title" content=" ">
<meta name="generator" content="docfx 2.50.0.0">
<meta name="generator" content="docfx 2.52.0.0">
<link rel="shortcut icon" href="../../favicon.png">
<link rel="stylesheet" href="../../styles/docfx.vendor.css">

Просмотреть файл

@ -9,7 +9,7 @@
<title>Getting Started </title>
<meta name="viewport" content="width=device-width">
<meta name="title" content="Getting Started ">
<meta name="generator" content="docfx 2.50.0.0">
<meta name="generator" content="docfx 2.52.0.0">
<link rel="shortcut icon" href="../../favicon.png">
<link rel="stylesheet" href="../../styles/docfx.vendor.css">
@ -84,13 +84,13 @@
<h3 id="imagesharp-images">ImageSharp Images</h3>
<p>ImageSharp provides several classes for storing pixel data:</p>
<ul>
<li><a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Image.html">Image</a> A pixel format agnostic image container used for general processing operations.</li>
<li><a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Image-1.html">Image&lt;TPixel&gt;</a> A generic image container that allows per-pixel access.</li>
<li>@&quot;SixLabors.ImageSharp.Image&quot; A pixel format agnostic image container used for general processing operations.</li>
<li>@&quot;SixLabors.ImageSharp.Image`1&quot; A generic image container that allows per-pixel access.</li>
</ul>
<p>In addition there are classes available that represent individual image frames:</p>
<ul>
<li><a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.ImageFrame.html">ImageFrame</a> A pixel format agnostic image frame container.</li>
<li><a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.ImageFrame-1.html">ImageFrame&lt;TPixel&gt;</a> A generic image frame container that allows per-pixel access.</li>
<li>@&quot;SixLabors.ImageSharp.ImageFrame&quot; A pixel format agnostic image frame container.</li>
<li>@&quot;SixLabors.ImageSharp.ImageFrame`1&quot; A generic image frame container that allows per-pixel access.</li>
<li>@&quot;SixLabors.ImageSharp.Processing.Processors.Quantization.IndexedImageFrame`1&quot; A generic image frame used for indexed image pixel data where each pixel buffer value represents an index in a color palette.</li>
</ul>
<p>For more information on pixel formats please see the following <a href="pixelformats.html">documentation</a>.</p>
@ -139,8 +139,8 @@ using(var image = new Image&lt;Rgba32&gt;(width, height))
<h3 id="api-cornerstones">API Cornerstones</h3>
<p>The easiest way to work with ImageSharp is to utilize our extension methods:</p>
<ul>
<li><a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.html">SixLabors.ImageSharp</a> for basic operations and primitives.</li>
<li><a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Processing.html">SixLabors.ImageSharp.Processing</a> for <code>Mutate()</code> and <code>Clone()</code>. All the processing extensions (eg. <code>Resize(...)</code>) live within this namespace. </li>
<li>@&quot;SixLabors.ImageSharp&quot; for basic operations and primitives.</li>
<li>@&quot;SixLabors.ImageSharp.Processing&quot; for <code>Mutate()</code> and <code>Clone()</code>. All the processing extensions (eg. <code>Resize(...)</code>) live within this namespace. </li>
</ul>
<h3 id="performance">Performance</h3>
<p>Achieving near-to-native performance is a major goal for the SixLabors team, and thanks to the improvements brought by the RyuJIT runtime, it&#39;s no longer mission impossible. We have made great progress and are constantly working on improvements.</p>

Просмотреть файл

@ -9,7 +9,7 @@
<title>Image Formats </title>
<meta name="viewport" content="width=device-width">
<meta name="title" content="Image Formats ">
<meta name="generator" content="docfx 2.50.0.0">
<meta name="generator" content="docfx 2.52.0.0">
<link rel="shortcut icon" href="../../favicon.png">
<link rel="stylesheet" href="../../styles/docfx.vendor.css">
@ -87,10 +87,10 @@
<li>Gif</li>
<li>Tga</li>
</ul>
<p>ImageSharp&#39;s API however, is designed to support extension by the registration of additional <a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Formats.IImageFormat.html"><code>IImageFormat</code></a> implementations.</p>
<p>ImageSharp&#39;s API however, is designed to support extension by the registration of additional <a href="xref:SixLabors.ImageSharp.Formats.IImageFormat"><code>IImageFormat</code></a> implementations.</p>
<h3 id="loading-and-saving-specific-image-formats">Loading and Saving Specific Image Formats</h3>
<p><a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Image-1.html"><code>Image&lt;TPixel&gt;</code></a> represents raw pixel data, stored in a contiguous memory block. It does not &quot;remember&quot; the original image format.</p>
<p>ImageSharp identifies image formats (Jpeg, Png, Gif etc.) by <a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Formats.IImageFormat.html"><code>IImageFormat</code></a> instances. There are several overloads of <a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Image.html"><code>Image.Load</code></a> capable of returning the format as an <code>out</code> parameter. It&#39;s possible to pass that value to <code>image.Save</code> after performing the operation:</p>
<p><a href="xref:SixLabors.ImageSharp.Image`1"><code>Image&lt;TPixel&gt;</code></a> represents raw pixel data, stored in a contiguous memory block. It does not &quot;remember&quot; the original image format.</p>
<p>ImageSharp identifies image formats (Jpeg, Png, Gif etc.) by <a href="xref:SixLabors.ImageSharp.Formats.IImageFormat"><code>IImageFormat</code></a> instances. There are several overloads of <a href="xref:SixLabors.ImageSharp.Image"><code>Image.Load</code></a> capable of returning the format as an <code>out</code> parameter. It&#39;s possible to pass that value to <code>image.Save</code> after performing the operation:</p>
<pre><code class="lang-C#">IImageFormat format;
using (var image = Image.Load(inputStream, out format))
@ -108,22 +108,22 @@ using (var image = Image.Load(inputStream, out format))
<li><code>image.SaveAsTga()</code> (shortcut for <code>image.Save(new TgaEncoder())</code>)</li>
</ul>
<h3 id="a-deeper-overview-of-imagesharp-format-management">A Deeper Overview of ImageSharp Format Management</h3>
<p>Real life image streams are usually stored / transferred in standardized formats like Jpeg, Png, Bmp, Gif etc. An image format is represented by an <a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Formats.IImageFormat.html"><code>IImageFormat</code></a> implementation.</p>
<p>Real life image streams are usually stored / transferred in standardized formats like Jpeg, Png, Bmp, Gif etc. An image format is represented by an <a href="xref:SixLabors.ImageSharp.Formats.IImageFormat"><code>IImageFormat</code></a> implementation.</p>
<ul>
<li><a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Formats.IImageDecoder.html"><code>IImageDecoder</code></a> is responsible for decoding streams (and files) in into <a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Image-1.html"><code>Image&lt;TPixel&gt;</code></a>. ImageSharp can <strong>auto-detect</strong> the image formats of streams/files based on their headers, selecting the correct <a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Formats.IImageFormat.html"><code>IImageFormat</code></a> (and thus <a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Formats.IImageDecoder.html"><code>IImageDecoder</code></a>). This logic is implemented by <a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Formats.IImageFormatDetector.html"><code>IImageFormatDetector</code></a>&#39;s.</li>
<li><a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Formats.IImageEncoder.html"><code>IImageEncoder</code></a> is responsible for writing <a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Image-1.html"><code>Image&lt;TPixel&gt;</code></a> into a stream using a given format.</li>
<li>Decoders/encoders and <a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Formats.IImageFormatDetector.html"><code>IImageFormatDetector</code></a>&#39;s are mapped to image formats in <a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Configuration.html#SixLabors_ImageSharp_Configuration_ImageFormatsManager"><code>ImageFormatsManager</code></a>. It&#39;s possible to register new formats, or drop existing ones. See <a href="configuration.html">Configuration</a> for more details.</li>
<li><a href="xref:SixLabors.ImageSharp.Formats.IImageDecoder"><code>IImageDecoder</code></a> is responsible for decoding streams (and files) in into <a href="xref:SixLabors.ImageSharp.Image`1"><code>Image&lt;TPixel&gt;</code></a>. ImageSharp can <strong>auto-detect</strong> the image formats of streams/files based on their headers, selecting the correct <a href="xref:SixLabors.ImageSharp.Formats.IImageFormat"><code>IImageFormat</code></a> (and thus <a href="xref:SixLabors.ImageSharp.Formats.IImageDecoder"><code>IImageDecoder</code></a>). This logic is implemented by <a href="xref:SixLabors.ImageSharp.Formats.IImageFormatDetector"><code>IImageFormatDetector</code></a>&#39;s.</li>
<li><a href="xref:SixLabors.ImageSharp.Formats.IImageEncoder"><code>IImageEncoder</code></a> is responsible for writing <a href="xref:SixLabors.ImageSharp.Image`1"><code>Image&lt;TPixel&gt;</code></a> into a stream using a given format.</li>
<li>Decoders/encoders and <a href="xref:SixLabors.ImageSharp.Formats.IImageFormatDetector"><code>IImageFormatDetector</code></a>&#39;s are mapped to image formats in <a href="xref:SixLabors.ImageSharp.Configuration.ImageFormatsManager"><code>ImageFormatsManager</code></a>. It&#39;s possible to register new formats, or drop existing ones. See <a href="configuration.html">Configuration</a> for more details.</li>
</ul>
<h3 id="metadata-only-decoding">Metadata-only Decoding</h3>
<p>Sometimes it&#39;s worth to efficiently decode image metadata ignoring the memory and CPU heavy pixel information inside the stream. ImageSharp allows this by using one of the several <a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Image.html">Image.Identify</a> overloads:</p>
<p>Sometimes it&#39;s worth to efficiently decode image metadata ignoring the memory and CPU heavy pixel information inside the stream. ImageSharp allows this by using one of the several <a href="xref:SixLabors.ImageSharp.Image">Image.Identify</a> overloads:</p>
<pre><code class="lang-C#">using (IImageInfo imageInfo = Image.Identify(inputStream))
{
Console.WriteLine($&quot;{imageInfo.Width}x{imageInfo.Height} | BPP: {imageInfo.PixelType.BitsPerPixel}&quot;);
}
</code></pre><p>See <a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.IImageInfo.html"><code>IImageInfo</code></a> for more details about the identification result. Note that <a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Image-1.html"><code>Image&lt;TPixel&gt;</code></a> also implements <code>IImageInfo</code>.</p>
</code></pre><p>See <a href="xref:SixLabors.ImageSharp.IImageInfo"><code>IImageInfo</code></a> for more details about the identification result. Note that <a href="xref:SixLabors.ImageSharp.Image`1"><code>Image&lt;TPixel&gt;</code></a> also implements <code>IImageInfo</code>.</p>
<h3 id="working-with-encoders">Working with Encoders</h3>
<p>Image formats are usually defined by complex standards allowing multiple representations for the same image. ImageSharp allows parameterizing the encoding process:
<a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Formats.IImageEncoder.html"><code>IImageEncoder</code></a> implementations are stateless, lightweight <strong>parametric</strong> objects. This means that if you want to encode a Png in a specific way (eg. changing the compression level), you need to new-up a custom <a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Formats.Png.PngEncoder.html"><code>PngEncoder</code></a> instance.</p>
<a href="xref:SixLabors.ImageSharp.Formats.IImageEncoder"><code>IImageEncoder</code></a> implementations are stateless, lightweight <strong>parametric</strong> objects. This means that if you want to encode a Png in a specific way (eg. changing the compression level), you need to new-up a custom <a href="xref:SixLabors.ImageSharp.Formats.Png.PngEncoder"><code>PngEncoder</code></a> instance.</p>
<p>Choosing the right encoder parameters allows to balance between conflicting tradeoffs:</p>
<ul>
<li>Image file size</li>

Просмотреть файл

@ -9,7 +9,7 @@
<title>Memory Management </title>
<meta name="viewport" content="width=device-width">
<meta name="title" content="Memory Management ">
<meta name="generator" content="docfx 2.50.0.0">
<meta name="generator" content="docfx 2.52.0.0">
<link rel="shortcut icon" href="../../favicon.png">
<link rel="stylesheet" href="../../styles/docfx.vendor.css">
@ -80,7 +80,7 @@
<h1 id="memory-management">Memory Management</h1>
<h3 id="imagesharp-seems-to-retain-300-400-mb-of-managed-memory-even-after-disposing-all-my-images-is-this-a-memory-leak">ImageSharp seems to retain ~300-400 MB of managed memory even after disposing all my images. Is this a memory leak?</h3>
<p>By default, ImageSharp uses <a href="http://adamsitnik.com/Array-Pool/">ArrayPool&#39;s</a> for performance reasons, however this behavior is fully configurable. All large buffers are managed by the <a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Memory.MemoryAllocator.html">MemoryAllocator</a> implementation associated to <a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Configuration.html">Configuration</a>&#39;s <a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Configuration.html#SixLabors_ImageSharp_Configuration_MemoryAllocator">MemoryAllocator</a> property. We are using <a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Memory.ArrayPoolMemoryAllocator.html">ArrayPoolMemoryAllocator</a> by default, in order to utilize the benefits of array pooling:</p>
<p>By default, ImageSharp uses <a href="http://adamsitnik.com/Array-Pool/">ArrayPool&#39;s</a> for performance reasons, however this behavior is fully configurable. All large buffers are managed by the @&quot;SixLabors.ImageSharp.Memory.MemoryAllocator&quot; implementation associated to @&quot;SixLabors.ImageSharp.Configuration&quot;&#39;s @&quot;SixLabors.ImageSharp.Configuration.MemoryAllocator&quot; property. We are using @&quot;SixLabors.ImageSharp.Memory.ArrayPoolMemoryAllocator&quot; by default, in order to utilize the benefits of array pooling:</p>
<ul>
<li>Less pressure on GC, because buffers are being reused most of the time</li>
<li>Reduced <a href="https://blogs.msdn.microsoft.com/maoni/2016/05/31/large-object-heap-uncovered-from-an-old-msdn-article/">LOH fragmentation</a></li>
@ -98,15 +98,15 @@
<li>Keep in mind that image processing is a <em>memory intensive</em> application! This may affect your scaling strategy. We don&#39;t recommend using containers with 1 GB or smaller memory limit!</li>
<li>Make sure that you are running your service in a <strong>64 bit process</strong>!</li>
</ul>
<p>There are several pre-defined factory methods to create an <a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Memory.ArrayPoolMemoryAllocator.html">ArrayPoolMemoryAllocator</a> instance for memory constrained environments. For example <a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Memory.ArrayPoolMemoryAllocator.html#SixLabors_ImageSharp_Memory_ArrayPoolMemoryAllocator_CreateWithModeratePooling">CreateWithModeratePooling()</a> might be suitable in most constrained situations:</p>
<p>There are several pre-defined factory methods to create an @&quot;SixLabors.ImageSharp.Memory.ArrayPoolMemoryAllocator&quot; instance for memory constrained environments. For example @&quot;SixLabors.ImageSharp.Memory.ArrayPoolMemoryAllocator.CreateWithModeratePooling&quot; might be suitable in most constrained situations:</p>
<pre><code class="lang-cs">Configuration.Default.MemoryAllocator = ArrayPoolMemoryAllocator.CreateWithModeratePooling();
</code></pre><p>Of course, you may also configure a MemoryAllocator on your own <a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Configuration.html">Configuration</a> instance.</p>
</code></pre><p>Of course, you may also configure a MemoryAllocator on your own @&quot;SixLabors.ImageSharp.Configuration&quot; instance.</p>
<p>You can find <a href="https://github.com/SixLabors/ImageSharp/pull/475">benchmark results in the original PR</a> which may help to select you a configuration, but they are bit outdated, because our throughput got better since then!</p>
<h3 id="releasing-pools-programatically">Releasing pools programatically</h3>
<p>If your application uses ImageSharp sporadically (eg. generating some images on startup, or on other non-frequent use-cases), you may want to release the retained pools using <a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Memory.MemoryAllocator.html#SixLabors_ImageSharp_Memory_MemoryAllocator_ReleaseRetainedResources">ReleaseRetainedResources()</a>:</p>
<p>If your application uses ImageSharp sporadically (eg. generating some images on startup, or on other non-frequent use-cases), you may want to release the retained pools using @&quot;SixLabors.ImageSharp.Memory.MemoryAllocator.ReleaseRetainedResources&quot;:</p>
<pre><code class="lang-cs">Configuration.Default.MemoryAllocator.ReleaseRetainedResources();
</code></pre><h3 id="using-multiple-memoryallocator-instances-in-the-same-process">Using multiple MemoryAllocator instances in the same process</h3>
<p>You need to create and maintain your own <a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Configuration.html">Configuration</a> instance, setting a specific MemoryAllocator on it. It&#39;s possible to pass custom Configuration instances to methods accross our whole API.</p>
<p>You need to create and maintain your own @&quot;SixLabors.ImageSharp.Configuration&quot; instance, setting a specific MemoryAllocator on it. It&#39;s possible to pass custom Configuration instances to methods accross our whole API.</p>
</article>
</div>

Просмотреть файл

@ -9,7 +9,7 @@
<title>Pixel Formats </title>
<meta name="viewport" content="width=device-width">
<meta name="title" content="Pixel Formats ">
<meta name="generator" content="docfx 2.50.0.0">
<meta name="generator" content="docfx 2.52.0.0">
<link rel="shortcut icon" href="../../favicon.png">
<link rel="stylesheet" href="../../styles/docfx.vendor.css">
@ -79,15 +79,15 @@
<article class="content wrap" id="_content" data-uid="">
<h1 id="pixel-formats">Pixel Formats</h1>
<h3 id="why-is-sixlaborsimagesharpimage1-a-generic-class">Why is <a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Image-1.html">Image&lt;TPixel&gt;</a> a generic class?</h3>
<h3 id="why-is-sixlaborsimagesharpimage1-a-generic-class">Why is @&quot;SixLabors.ImageSharp.Image`1&quot; a generic class?</h3>
<p>We support multiple pixel formats just like <em>System.Drawing</em> does. However, unlike their closed <a href="https://docs.microsoft.com/en-us/dotnet/api/system.drawing.imaging.pixelformat">PixelFormat</a> enumeration, our solution is extensible.
A pixel is basically a small value object (struct), describing the color at a given point according to a pixel model we call Pixel Format. <code>Image&lt;TPixel&gt;</code> represents a pixel graphic bitmap stored as a <strong>generic, contiguous memory block</strong> of pixels, of size <code>image.Width * image.Height</code>.</p>
<p>In the case of multi-frame images (usually decoded from gifs) multiple bitmaps are stored in <code>image.Frames</code> as <code>ImageFrame&lt;TPixel&gt;</code> instances.</p>
<h3 id="choosing-pixel-formats">Choosing Pixel Formats</h3>
<p>Have a look at the various pixel formats available under <a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.PixelFormats.html#structs">SixLabors.ImageSharp.PixelFormats</a> After picking the pixel format of your choice, use it as a generic argument for <a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Image-1.html">Image&lt;TPixel&gt;</a>, eg. by instantiating <code>Image&lt;Bgr24&gt;</code>.</p>
<p>Have a look at the various pixel formats available under @&quot;SixLabors.ImageSharp.PixelFormats#structs&quot; After picking the pixel format of your choice, use it as a generic argument for <a href="xref:SixLabors.ImageSharp.Image`1?displayProperty=name"></a>, eg. by instantiating <code>Image&lt;Bgr24&gt;</code>.</p>
<h3 id="defining-custom-pixel-formats">Defining Custom Pixel Formats</h3>
<p>Yes, you just need to define a struct implementing <a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.PixelFormats.IPixel-1.html">IPixel&lt;TSelf&gt;</a> and use it as a generic argument for <a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Image-1.html">Image&lt;TPixel&gt;</a>.
However, at the moment you won&#39;t be able to provide SIMD-optimized batched pixel-conversion primitives. We need to open up the <a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.PixelFormats.PixelOperations-1.html">PixelOperations&lt;TPixel&gt;</a> API to allow that.</p>
<p>Yes, you just need to define a struct implementing <a href="xref:SixLabors.ImageSharp.PixelFormats.IPixel`1"></a> and use it as a generic argument for <a href="xref:SixLabors.ImageSharp.Image`1?displayProperty=name"></a>.
However, at the moment you won&#39;t be able to provide SIMD-optimized batched pixel-conversion primitives. We need to open up the <a href="xref:SixLabors.ImageSharp.PixelFormats.PixelOperations`1"></a> API to allow that.</p>
<h3 id="i-have-a-monochrome-image-and-i-want-to-store-it-in-a-compact-way-can-i-store-a-pixel-on-a-single-bit">I have a monochrome image and I want to store it in a compact way. Can I store a pixel on a single bit?</h3>
<p>No. Our architecture does not allow sub-byte pixel formats at the moment. This feature is incredibly complex to implement, and you are going to pay the price of the low memory footprint in processing speed / CPU load.</p>
<h3 id="can-i-decode-into-pixel-formats-like-cmykhttpsenwikipediaorgwikicmykcolormodel-or-cielabhttpsenwikipediaorgwikilabcolorspace">Can I decode into pixel formats like <a href="https://en.wikipedia.org/wiki/CMYK_color_model">CMYK</a> or <a href="https://en.wikipedia.org/wiki/Lab_color_space">CIELAB</a>?</h3>

Просмотреть файл

@ -9,7 +9,7 @@
<title>Processing Image Operations </title>
<meta name="viewport" content="width=device-width">
<meta name="title" content="Processing Image Operations ">
<meta name="generator" content="docfx 2.50.0.0">
<meta name="generator" content="docfx 2.52.0.0">
<link rel="shortcut icon" href="../../favicon.png">
<link rel="stylesheet" href="../../styles/docfx.vendor.css">
@ -81,7 +81,7 @@
<p>The ImageSharp processing API is imperative. This means that the order in which you supply the individual processing operations is the order in which they are are compiled and applied. This allows the API to be very flexible, allowing you to combine processes in any order.</p>
<p>Processing operations are implemented using one of two available method calls.
<a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Processing.ProcessingExtensions.html#SixLabors_ImageSharp_Processing_ProcessingExtensions_Mutate_"><code>Mutate</code></a> and <a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Processing.ProcessingExtensions.html#SixLabors_ImageSharp_Processing_ProcessingExtensions_Clone_"><code>Clone</code></a></p>
<a href="xref:SixLabors.ImageSharp.Processing.ProcessingExtensions.Mutate*?displayProperty=name"><code>Mutate</code></a> and <a href="xref:SixLabors.ImageSharp.Processing.ProcessingExtensions.Clone*?displayProperty=name"><code>Clone</code></a></p>
<p>The difference being that the former applies the given processing operations to the current image whereas the latter applies the operations to a deep copy of the original image.</p>
<p>For example:</p>
<p><strong>Mutate</strong></p>

Просмотреть файл

@ -9,7 +9,7 @@
<title>Resizing Images </title>
<meta name="viewport" content="width=device-width">
<meta name="title" content="Resizing Images ">
<meta name="generator" content="docfx 2.50.0.0">
<meta name="generator" content="docfx 2.52.0.0">
<link rel="shortcut icon" href="../../favicon.png">
<link rel="stylesheet" href="../../styles/docfx.vendor.css">
@ -83,7 +83,7 @@
<h3 id="the-basics">The Basics</h3>
<p>Resizing an image involves the process of creating and iterating through the pixels of a target image and sampling areas of a source image to choose what color to implement for each pixel. The sampling algorithm chosen affects the target color and can dramatically alter the result. Different samplers are usually chosen based upon the use case - For example <code>NearestNeigbor</code> is often used for fast, low quality thumbnail generation, <code>Lanczos3</code> for high quality thumbnails due to it&#39;s sharpening effect, and <code>Spline</code> for high quality enlargment due to it&#39;s smoothing effect.</p>
<p>With ImageSharp we default to <code>Bicubic</code> as it is a very robust algorithm offering good quality output when both reducing and enlarging images but you can easily set the algorithm when processing.</p>
<p>A full list of supported sampling algorithms can be found <a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Processing.KnownResamplers.html">here</a>:</p>
<p>A full list of supported sampling algorithms can be found <a href="xref:SixLabors.ImageSharp.Processing.KnownResamplers">here</a>:</p>
<p><strong>Resize the given image using the default <code>Bicubic</code> sampler.</strong></p>
<pre><code class="lang-c#">using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Processing;

Просмотреть файл

@ -9,7 +9,7 @@
<title>Working with pixel buffers </title>
<meta name="viewport" content="width=device-width">
<meta name="title" content="Working with pixel buffers ">
<meta name="generator" content="docfx 2.50.0.0">
<meta name="generator" content="docfx 2.52.0.0">
<link rel="shortcut icon" href="../../favicon.png">
<link rel="stylesheet" href="../../styles/docfx.vendor.css">
@ -87,7 +87,7 @@
}
</code></pre><p>The idexer is much faster than the <code>.GetPixel(x, y)</code> and <code>.SetPixel(x,y)</code> methods of <code>System.Drawing</code> but, it&#39;s still quite slow.</p>
<h3 id="efficient-pixel-manipulation">Efficient pixel manipulation</h3>
<p>If you want to achieve killer speed in your own low-level pixel manipulation routines, you need to utilize extension methods within the <a class="xref" href="../../api/ImageSharp/SixLabors.ImageSharp.Advanced.AdvancedImageExtensions.html">AdvancedImageExtensions</a> class. These methods are using the <a href="https://www.codemag.com/Article/1807051/Introducing-.NET-Core-2.1-Flagship-Types-Span-T-and-Memory-T">brand-new <code>Span&lt;T&gt;</code>-based memory manipulation primitives</a> from <a href="https://www.nuget.org/packages/System.Memory/">System.Memory</a>, providing a fast, yet safe low-level solution to manipulate pixel data.</p>
<p>If you want to achieve killer speed in your own low-level pixel manipulation routines, you need to utilize extension methods within the <a href="xref:SixLabors.ImageSharp.Advanced.AdvancedImageExtensions?displayProperty=name"></a> class. These methods are using the <a href="https://www.codemag.com/Article/1807051/Introducing-.NET-Core-2.1-Flagship-Types-Span-T-and-Memory-T">brand-new <code>Span&lt;T&gt;</code>-based memory manipulation primitives</a> from <a href="https://www.nuget.org/packages/System.Memory/">System.Memory</a>, providing a fast, yet safe low-level solution to manipulate pixel data.</p>
<p>This is how you can implement efficient row-by-row pixel manipulation:</p>
<pre><code class="lang-C#">using SixLabors.ImageSharp.Advanced;

Просмотреть файл

@ -9,7 +9,7 @@
<title>Introduction </title>
<meta name="viewport" content="width=device-width">
<meta name="title" content="Introduction ">
<meta name="generator" content="docfx 2.50.0.0">
<meta name="generator" content="docfx 2.52.0.0">
<link rel="shortcut icon" href="../../favicon.png">
<link rel="stylesheet" href="../../styles/docfx.vendor.css">

Просмотреть файл

@ -0,0 +1,246 @@

<!DOCTYPE html>
<!--[if IE]><![endif]-->
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Custom Rendering </title>
<meta name="viewport" content="width=device-width">
<meta name="title" content="Custom Rendering ">
<meta name="generator" content="docfx 2.52.0.0">
<link rel="shortcut icon" href="../../favicon.png">
<link rel="stylesheet" href="../../styles/docfx.vendor.css">
<link rel="stylesheet" href="../../styles/docfx.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.8/css/all.css" integrity="sha384-3AB7yXWz4OeoZcPbieVW64vVXEwADiYyAEhwilzWsLw+9FgqpyjjStpPnpBO8o8S" crossorigin="anonymous">
<link rel="stylesheet" href="../../styles/main.css">
<meta property="docfx:navrel" content="../../toc.html">
<meta property="docfx:tocrel" content="../toc.html">
<meta property="docfx:rel" content="../../">
</head>
<body data-spy="scroll" data-target="#affix">
<div id="wrapper">
<header>
<nav id="autocollapse" class="navbar navbar-inverse ng-scope" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="../../index.html">
<img id="logo" class="svg" src="../../logo.svg" alt="">
</a>
</div>
<div class="collapse navbar-collapse" id="navbar">
<form class="navbar-form navbar-right" role="search" id="search">
<div class="form-group">
<input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off">
</div>
</form>
</div>
</div>
</nav>
<div class="subnav navbar navbar-default">
<div class="container hide-when-search" id="breadcrumb">
<ul class="breadcrumb">
<li></li>
</ul>
</div>
</div>
</header>
<div class="container body-content">
<div id="search-results">
<div class="search-list"></div>
<div class="sr-items"></div>
<ul id="pagination"></ul>
</div>
</div>
<div role="main" class="container body-content hide-when-search">
<div class="sidenav hide-when-search">
<a class="btn toc-toggle collapse" data-toggle="collapse" href="#sidetoggle" aria-expanded="false" aria-controls="sidetoggle">Show / Hide Table of Contents</a>
<div class="sidetoggle collapse" id="sidetoggle">
<div id="sidetoc"></div>
</div>
</div>
<div class="article row grid-right">
<div class="col-md-10">
<article class="content wrap" id="_content" data-uid="">
<h1 id="custom-rendering">Custom Rendering</h1>
<div class="WARNING"><h5>Warning</h5><p>Fonts is still considered BETA quality and we still reserve the rights to change the API shapes. We are yet to priorities performance in our font loading and layout APIs.</p>
</div>
<div class="NOTE"><h5>Note</h5><p>ImageSharp.Drawing already implements the glyph rendering for you unless you are rendering on other platforms we would recommend using the version build into that library.. this is a more advanced topic.</p>
</div>
<h3 id="implementing-a-glyph-renderer">Implementing a glyph renderer</h3>
<p>The abstraction used by <code>Fonts</code> to allow implementing glyph rendering is the <code>IGlyphRenderer</code> and its brother <code>IColoredGlypheRenderer</code> (for colored emoji support).</p>
<pre><code class="lang-c#"> // `IColoredGlyphRenderer` implements `IGlyphRenderer` so if you don&#39;t want colored font support just implement `IGlyphRenderer`.
public class CustomGlyphRenderer : IColoredGlyphRenderer
{
/// &lt;summary&gt;
/// Called before any glyphs have been rendered.
/// &lt;/summary&gt;
/// &lt;param name=&quot;bounds&quot;&gt;The bounds the text will be rendered at and at whats size.&lt;/param&gt;
void IGlyphRenderer.BeginText(FontRectangle bounds)
{
// called before any thing else to provide access to the total required size to redner the text
}
/// &lt;summary&gt;
/// Begins the glyph.
/// &lt;/summary&gt;
/// &lt;param name=&quot;bounds&quot;&gt;The bounds the glyph will be rendered at and at what size.&lt;/param&gt;
/// &lt;param name=&quot;paramaters&quot;&gt;The set of paramaters that uniquely represents a version of a glyph in at particular font size, font family, font style and DPI.&lt;/param&gt;
/// &lt;returns&gt;Returns true if the glyph should be rendered othersie it returns false.&lt;/returns&gt;
bool IGlyphRenderer.BeginGlyph(FontRectangle bounds, GlyphRendererParameters paramaters)
{
// called before each glyph/glyph layer is rendered.
// The paramaters can be used to detect the exact details
// of the glyph so that duplicate glyphs could optionally
// be cached to reduce processing.
// You can return false to skip all the figures within the glyph (if you return false EndGlyph will still be called)
}
/// &lt;summary&gt;
/// Sets the color to use for the current glyph.
/// &lt;/summary&gt;
/// &lt;param name=&quot;color&quot;&gt;The color to override the renders brush with.&lt;/param&gt;
void IColorGlyphRenderer.SetColor(GlyphColor color)
{
// from the IColorGlyphRenderer version, onlt called if the current glyph should override the forgound color of current glyph/layer
}
/// &lt;summary&gt;
/// Begins the figure.
/// &lt;/summary&gt;
void IGlyphRenderer.BeginFigure()
{
// called at the start of the figure within the single glyph/layer
// glyphs are rendered as a serise of arcs, lines and movements
// which together describe a complex shape.
}
/// &lt;summary&gt;
/// Sets a new start point to draw lines from
/// &lt;/summary&gt;
/// &lt;param name=&quot;point&quot;&gt;The point.&lt;/param&gt;
void IGlyphRenderer.MoveTo(Vector2 point)
{
// move current point to location marked by point without describing a line;
}
/// &lt;summary&gt;
/// Draw a quadratic bezier curve connecting the previous point to &lt;paramref name=&quot;point&quot;/&gt;.
/// &lt;/summary&gt;
/// &lt;param name=&quot;secondControlPoint&quot;&gt;The second control point.&lt;/param&gt;
/// &lt;param name=&quot;point&quot;&gt;The point.&lt;/param&gt;
void IGlyphRenderer.QuadraticBezierTo(Vector2 secondControlPoint, Vector2 point)
{
// describes Quadratic Bezier curve from the &#39;current point&#39; using the
// &#39;second control point&#39; and final &#39;point&#39; leaving the &#39;current point&#39;
// at &#39;point&#39;
}
/// &lt;summary&gt;
/// Draw a Cubics bezier curve connecting the previous point to &lt;paramref name=&quot;point&quot;/&gt;.
/// &lt;/summary&gt;
/// &lt;param name=&quot;secondControlPoint&quot;&gt;The second control point.&lt;/param&gt;
/// &lt;param name=&quot;thirdControlPoint&quot;&gt;The third control point.&lt;/param&gt;
/// &lt;param name=&quot;point&quot;&gt;The point.&lt;/param&gt;
void IGlyphRenderer.CubicBezierTo(Vector2 secondControlPoint, Vector2 thirdControlPoint, Vector2 point)
{
// describes Cubic Bezier curve from the &#39;current point&#39; using the
// &#39;second control point&#39;, &#39;third control point&#39; and final &#39;point&#39;
// leaving the &#39;current point&#39; at &#39;point&#39;
}
/// &lt;summary&gt;
/// Draw a straight line connecting the previous point to &lt;paramref name=&quot;point&quot;/&gt;.
/// &lt;/summary&gt;
/// &lt;param name=&quot;point&quot;&gt;The point.&lt;/param&gt;
void IGlyphRenderer.LineTo(Vector2 point)
{
// describes straight line from the &#39;current point&#39; to the final &#39;point&#39;
// leaving the &#39;current point&#39; at &#39;point&#39;
}
/// &lt;summary&gt;
/// Ends the figure.
/// &lt;/summary&gt;
void IGlyphRenderer.EndFigure()
{
// Called after the figure has completed denoting a straight line should
// be drawn from the current point to the first point
}
/// &lt;summary&gt;
/// Ends the glyph.
/// &lt;/summary&gt;
void IGlyphRenderer.EndGlyph()
{
// says the all figures have completed for the current glyph/layer.
// NOTE this will be called even if BeginGlyph return false.
}
/// &lt;summary&gt;
/// Called once all glyphs have completed rendering
/// &lt;/summary&gt;
void IGlyphRenderer.EndText()
{
//once all glyphs/layers have been drawn this is called.
}
}
</code></pre>
</article>
</div>
<div class="hidden-sm col-md-2" role="complementary">
<div class="sideaffix">
<div class="contribution">
<ul class="nav">
<li>
<a href="https://github.com/SixLabors/docs/blob/master/articles/fonts/customrendering.md/#L1" class="contribution-link">Improve this Doc</a>
</li>
</ul>
</div>
<nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
<!-- <p><a class="back-to-top" href="#top">Back to top</a><p> -->
</nav>
</div>
</div>
</div>
</div>
<footer>
<div class="grad-bottom"></div>
<div class="footer">
<div class="container">
<span class="pull-right">
<a href="#top">Back to top</a>
</span>
<span>Copyright © Six Labors<br>Generated by <strong>DocFX</strong></span>
</div>
</div>
</footer>
</div>
<script type="text/javascript" src="../../styles/docfx.vendor.js"></script>
<script type="text/javascript" src="../../styles/docfx.js"></script>
<script type="text/javascript" src="../../styles/main.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,165 @@

<!DOCTYPE html>
<!--[if IE]><![endif]-->
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Getting Started </title>
<meta name="viewport" content="width=device-width">
<meta name="title" content="Getting Started ">
<meta name="generator" content="docfx 2.52.0.0">
<link rel="shortcut icon" href="../../favicon.png">
<link rel="stylesheet" href="../../styles/docfx.vendor.css">
<link rel="stylesheet" href="../../styles/docfx.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.8/css/all.css" integrity="sha384-3AB7yXWz4OeoZcPbieVW64vVXEwADiYyAEhwilzWsLw+9FgqpyjjStpPnpBO8o8S" crossorigin="anonymous">
<link rel="stylesheet" href="../../styles/main.css">
<meta property="docfx:navrel" content="../../toc.html">
<meta property="docfx:tocrel" content="../toc.html">
<meta property="docfx:rel" content="../../">
</head>
<body data-spy="scroll" data-target="#affix">
<div id="wrapper">
<header>
<nav id="autocollapse" class="navbar navbar-inverse ng-scope" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="../../index.html">
<img id="logo" class="svg" src="../../logo.svg" alt="">
</a>
</div>
<div class="collapse navbar-collapse" id="navbar">
<form class="navbar-form navbar-right" role="search" id="search">
<div class="form-group">
<input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off">
</div>
</form>
</div>
</div>
</nav>
<div class="subnav navbar navbar-default">
<div class="container hide-when-search" id="breadcrumb">
<ul class="breadcrumb">
<li></li>
</ul>
</div>
</div>
</header>
<div class="container body-content">
<div id="search-results">
<div class="search-list"></div>
<div class="sr-items"></div>
<ul id="pagination"></ul>
</div>
</div>
<div role="main" class="container body-content hide-when-search">
<div class="sidenav hide-when-search">
<a class="btn toc-toggle collapse" data-toggle="collapse" href="#sidetoggle" aria-expanded="false" aria-controls="sidetoggle">Show / Hide Table of Contents</a>
<div class="sidetoggle collapse" id="sidetoggle">
<div id="sidetoc"></div>
</div>
</div>
<div class="article row grid-right">
<div class="col-md-10">
<article class="content wrap" id="_content" data-uid="">
<h1 id="getting-started">Getting Started</h1>
<div class="WARNING"><h5>Warning</h5><p>Fonts is still considered BETA quality and we still reserve the rights to change the API shapes. We are yet to priorities performance in our font loading and layout APIs.</p>
</div>
<div class="NOTE"><h5>Note</h5><p>The official guide assumes intermediate level knowledge of C# and .NET. If you are totally new to .NET development, it might not be the best idea to jump right into a framework as your first step - grasp the basics then come back. Prior experience with other languages and frameworks helps, but is not required.</p>
</div>
<h3 id="fonts">Fonts</h3>
<p>Fonts provides the core to your text layout and loading subsystems.</p>
<ul>
<li><code>SixLabors.Fonts.FontCollection</code> is the root type you will configure and load up with all the TrueType/OpenType/Woff fonts. (font loading is deemed expensive and should be done once and shared across multiple rasterizations)</li>
<li><code>SixLabors.Fonts.Font</code> is our currying type for passing information about your chosen font face.</li>
</ul>
<h3 id="loading-fonts">Loading Fonts</h3>
<p>Fonts provides several options for loading fonts, you can load then from a streams or files, we also support loading collections out of *.TTC files and well as single variants out if individual *.TTF files. We also support loading *.woff files.</p>
<h4 id="minimal-example">Minimal Example</h4>
<pre><code class="lang-c#">using SixLabors.Fonts;
FontCollection collection = new FontCollection();
FontFamily family = collection.Install(&quot;path/to/font.ttf&quot;);
Font font = family.Create(12, FontStyle.Italic);
// &quot;font&quot; can now be used in calls to DrawText from our ImageSharp.Drawing library.
</code></pre><h4 id="expanded-example">Expanded Example</h4>
<pre><code class="lang-c#">using SixLabors.Fonts;
FontCollection collection = new FontCollection();
collection.Install(&quot;path/to/font.ttf&quot;);
collection.Install(&quot;path/to/font2.ttf&quot;);
collection.Install(&quot;path/to/emojiFont.ttf&quot;);
collection.InstallCollection(&quot;path/to/font.ttc&quot;);
if(collection.TryFind(&quot;Font Name&quot;, out FontFamily family))
if(collection.TryFind(&quot;Emoji Font Name&quot;, out FontFamily emojiFamily))
{
// family will not be null here
Font font = family.Create(12, FontStyle.Italic);
RendererOptions options = new RendererOptions(font, dpi: 72)
{
ApplyKerning = true,
FallbackFontFamilies = new []
{
emojiFamily // will be used if a particular code point doesn&#39;t exist in the font passed into the constructor. (e.g. emoji)
}
};
FontRectangle rect = TextMeasurer.Measure(&quot;Text to measure&quot;, options);
}
</code></pre>
</article>
</div>
<div class="hidden-sm col-md-2" role="complementary">
<div class="sideaffix">
<div class="contribution">
<ul class="nav">
<li>
<a href="https://github.com/SixLabors/docs/blob/master/articles/fonts/gettingstarted.md/#L1" class="contribution-link">Improve this Doc</a>
</li>
</ul>
</div>
<nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
<!-- <p><a class="back-to-top" href="#top">Back to top</a><p> -->
</nav>
</div>
</div>
</div>
</div>
<footer>
<div class="grad-bottom"></div>
<div class="footer">
<div class="container">
<span class="pull-right">
<a href="#top">Back to top</a>
</span>
<span>Copyright © Six Labors<br>Generated by <strong>DocFX</strong></span>
</div>
</div>
</footer>
</div>
<script type="text/javascript" src="../../styles/docfx.vendor.js"></script>
<script type="text/javascript" src="../../styles/docfx.js"></script>
<script type="text/javascript" src="../../styles/main.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,161 @@

<!DOCTYPE html>
<!--[if IE]><![endif]-->
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Introduction </title>
<meta name="viewport" content="width=device-width">
<meta name="title" content="Introduction ">
<meta name="generator" content="docfx 2.52.0.0">
<link rel="shortcut icon" href="../../favicon.png">
<link rel="stylesheet" href="../../styles/docfx.vendor.css">
<link rel="stylesheet" href="../../styles/docfx.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.8/css/all.css" integrity="sha384-3AB7yXWz4OeoZcPbieVW64vVXEwADiYyAEhwilzWsLw+9FgqpyjjStpPnpBO8o8S" crossorigin="anonymous">
<link rel="stylesheet" href="../../styles/main.css">
<meta property="docfx:navrel" content="../../toc.html">
<meta property="docfx:tocrel" content="../toc.html">
<meta property="docfx:rel" content="../../">
</head>
<body data-spy="scroll" data-target="#affix">
<div id="wrapper">
<header>
<nav id="autocollapse" class="navbar navbar-inverse ng-scope" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="../../index.html">
<img id="logo" class="svg" src="../../logo.svg" alt="">
</a>
</div>
<div class="collapse navbar-collapse" id="navbar">
<form class="navbar-form navbar-right" role="search" id="search">
<div class="form-group">
<input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off">
</div>
</form>
</div>
</div>
</nav>
<div class="subnav navbar navbar-default">
<div class="container hide-when-search" id="breadcrumb">
<ul class="breadcrumb">
<li></li>
</ul>
</div>
</div>
</header>
<div class="container body-content">
<div id="search-results">
<div class="search-list"></div>
<div class="sr-items"></div>
<ul id="pagination"></ul>
</div>
</div>
<div role="main" class="container body-content hide-when-search">
<div class="sidenav hide-when-search">
<a class="btn toc-toggle collapse" data-toggle="collapse" href="#sidetoggle" aria-expanded="false" aria-controls="sidetoggle">Show / Hide Table of Contents</a>
<div class="sidetoggle collapse" id="sidetoggle">
<div id="sidetoc"></div>
</div>
</div>
<div class="article row grid-right">
<div class="col-md-10">
<article class="content wrap" id="_content" data-uid="">
<h1 id="introduction">Introduction</h1>
<div class="WARNING"><h5>Warning</h5><p>Fonts is still considered BETA quality and we still reserve the rights to change the API shapes. WE are yet to priorities performance in our drawing APIs.</p>
</div>
<h3 id="what-is-fonts">What is Fonts?</h3>
<p>Fonts is a font loading and layout library built primarily to provide text drawing support to ImageSharp.Drawing.</p>
<p>Built against <a href="https://docs.microsoft.com/en-us/dotnet/standard/net-standard">.NET Standard 1.3</a>, Fonts can be used in device, cloud, and embedded/IoT scenarios. </p>
<h3 id="license">License</h3>
<p>Fonts is licensed under under the terms of <a href="https://www.gnu.org/licenses/agpl-3.0.en.html">GNU Affero General
Public License, version 3</a>. Commercial licensing options are available in addition to this license, see <a href="https://sixlabors.com/pricing">https://sixlabors.com/pricing</a> for details.</p>
<h3 id="installation">Installation</h3>
<p>ImageSharp.Drawing is installed via <a href="https://www.nuget.org/packages/SixLabors.Fonts">Nuget</a> with nightly builds available on <a href="https://www.myget.org/feed/sixlabors/package/nuget/SixLabors.Fonts">MyGet</a>.</p>
<div class="tabGroup" id="tabgroup_cVma2RQCLN">
<ul role="tablist">
<li role="presentation">
<a href="#tabpanel_cVma2RQCLN_tabid-1" role="tab" aria-controls="tabpanel_cVma2RQCLN_tabid-1" data-tab="tabid-1" tabindex="0" aria-selected="true">Package Manager</a>
</li>
<li role="presentation">
<a href="#tabpanel_cVma2RQCLN_tabid-2" role="tab" aria-controls="tabpanel_cVma2RQCLN_tabid-2" data-tab="tabid-2" tabindex="-1">.NET CLI</a>
</li>
<li role="presentation">
<a href="#tabpanel_cVma2RQCLN_tabid-3" role="tab" aria-controls="tabpanel_cVma2RQCLN_tabid-3" data-tab="tabid-3" tabindex="-1">PackageReference</a>
</li>
<li role="presentation">
<a href="#tabpanel_cVma2RQCLN_tabid-4" role="tab" aria-controls="tabpanel_cVma2RQCLN_tabid-4" data-tab="tabid-4" tabindex="-1">Paket CLI</a>
</li>
</ul>
<section id="tabpanel_cVma2RQCLN_tabid-1" role="tabpanel" data-tab="tabid-1">
<pre><code class="lang-bash">PM &gt; Install-Package SixLabors.Fonts -Version VERSION_NUMBER
</code></pre></section>
<section id="tabpanel_cVma2RQCLN_tabid-2" role="tabpanel" data-tab="tabid-2" aria-hidden="true" hidden="hidden">
<pre><code class="lang-bash">dotnet add package SixLabors.Fonts --version VERSION_NUMBER
</code></pre></section>
<section id="tabpanel_cVma2RQCLN_tabid-3" role="tabpanel" data-tab="tabid-3" aria-hidden="true" hidden="hidden">
<pre><code class="lang-xml">&lt;PackageReference Include=&quot;SixLabors.Fonts&quot; Version=&quot;VERSION_NUMBER&quot; /&gt;
</code></pre></section>
<section id="tabpanel_cVma2RQCLN_tabid-4" role="tabpanel" data-tab="tabid-4" aria-hidden="true" hidden="hidden">
<pre><code class="lang-bash">paket add SixLabors.Fonts --version VERSION_NUMBER
</code></pre></section>
</div>
<div class="WARNING"><h5>Warning</h5><p>Prerelease versions installed via the <a href="https://docs.microsoft.com/en-us/nuget/consume-packages/install-use-packages-visual-studio">Visual Studio Nuget Package Manager</a> require the &quot;include prerelease&quot; checkbox to be checked.</p>
</div>
</article>
</div>
<div class="hidden-sm col-md-2" role="complementary">
<div class="sideaffix">
<div class="contribution">
<ul class="nav">
<li>
<a href="https://github.com/SixLabors/docs/blob/master/articles/fonts/index.md/#L1" class="contribution-link">Improve this Doc</a>
</li>
</ul>
</div>
<nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
<!-- <p><a class="back-to-top" href="#top">Back to top</a><p> -->
</nav>
</div>
</div>
</div>
</div>
<footer>
<div class="grad-bottom"></div>
<div class="footer">
<div class="container">
<span class="pull-right">
<a href="#top">Back to top</a>
</span>
<span>Copyright © Six Labors<br>Generated by <strong>DocFX</strong></span>
</div>
</div>
</footer>
</div>
<script type="text/javascript" src="../../styles/docfx.vendor.js"></script>
<script type="text/javascript" src="../../styles/docfx.js"></script>
<script type="text/javascript" src="../../styles/main.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,204 @@

<!DOCTYPE html>
<!--[if IE]><![endif]-->
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Getting Started </title>
<meta name="viewport" content="width=device-width">
<meta name="title" content="Getting Started ">
<meta name="generator" content="docfx 2.52.0.0">
<link rel="shortcut icon" href="../../favicon.png">
<link rel="stylesheet" href="../../styles/docfx.vendor.css">
<link rel="stylesheet" href="../../styles/docfx.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.8/css/all.css" integrity="sha384-3AB7yXWz4OeoZcPbieVW64vVXEwADiYyAEhwilzWsLw+9FgqpyjjStpPnpBO8o8S" crossorigin="anonymous">
<link rel="stylesheet" href="../../styles/main.css">
<meta property="docfx:navrel" content="../../toc.html">
<meta property="docfx:tocrel" content="../toc.html">
<meta property="docfx:rel" content="../../">
</head>
<body data-spy="scroll" data-target="#affix">
<div id="wrapper">
<header>
<nav id="autocollapse" class="navbar navbar-inverse ng-scope" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="../../index.html">
<img id="logo" class="svg" src="../../logo.svg" alt="">
</a>
</div>
<div class="collapse navbar-collapse" id="navbar">
<form class="navbar-form navbar-right" role="search" id="search">
<div class="form-group">
<input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off">
</div>
</form>
</div>
</div>
</nav>
<div class="subnav navbar navbar-default">
<div class="container hide-when-search" id="breadcrumb">
<ul class="breadcrumb">
<li></li>
</ul>
</div>
</div>
</header>
<div class="container body-content">
<div id="search-results">
<div class="search-list"></div>
<div class="sr-items"></div>
<ul id="pagination"></ul>
</div>
</div>
<div role="main" class="container body-content hide-when-search">
<div class="sidenav hide-when-search">
<a class="btn toc-toggle collapse" data-toggle="collapse" href="#sidetoggle" aria-expanded="false" aria-controls="sidetoggle">Show / Hide Table of Contents</a>
<div class="sidetoggle collapse" id="sidetoggle">
<div id="sidetoc"></div>
</div>
</div>
<div class="article row grid-right">
<div class="col-md-10">
<article class="content wrap" id="_content" data-uid="">
<h1 id="getting-started">Getting Started</h1>
<div class="WARNING"><h5>Warning</h5><p>ImageSharp.Drawing is still considered BETA quality and we still reserve the rights to change the API shapes. WE are yet to priorities performance in our drawing APIs.</p>
</div>
<div class="NOTE"><h5>Note</h5><p>The official guide assumes intermediate level knowledge of C# and .NET. If you are totally new to .NET development, it might not be the best idea to jump right into a framework as your first step - grasp the basics then come back. Prior experience with other languages and frameworks helps, but is not required.</p>
</div>
<h3 id="imagesharpdrawing---paths-and-polygons">ImageSharp.Drawing - Paths and Polygons</h3>
<p>ImageSharp.Drawing provides several classes for build and manipulating various shapes and paths.</p>
<ul>
<li>@&quot;SixLabors.ImageSharp.Drawing.IPath&quot; Root interface defining a path/polygon and the type that the rasterizer uses to generate pixel output.</li>
<li>This <code>SixLabors.ImageSharp.Drawing</code> namespace contains a variety of available polygons to speed up your drawing process.</li>
</ul>
<p>In addition to the vector manipulation APIs we also have the rasterization APIs that can convert your @&quot;SixLabors.ImageSharp.Drawing.IPath&quot;s to pixels.</p>
<h3 id="drawing-polygons">Drawing Polygons</h3>
<p>ImageSharp provides several options for drawing polygons weather you want to draw outlines or fill the shapes.</p>
<h4 id="minimal-example">Minimal Example</h4>
<pre><code class="lang-c#">using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Drawing.Processing;
Image image = ...; // create any way you like.
IPath yourPolygon = new Star(x: 100.0f, y: 100.0f, prongs: 5, innerRadii: 20.0f, outerRadii:30.0f)
image.Mutate( x=&gt; x.Fill(Color.Red, yourPolygon)); // fill the star with red
</code></pre><h4 id="expanded-example">Expanded Example</h4>
<pre><code class="lang-c#">using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Drawing.Processing;
using SixLabors.ImageSharp.PixelFormats;
Image image = ...; // create any way you like.
// The options are optional
ShapeGraphicsOptions options = new ShapeGraphicsOptions()
{
ColorBlendingMode = PixelColorBlendingMode.Multiply
};
IBrush brush = Brushes.Horizontal(Color.Red, Color.Blue);
IPen pen = Pens.DashDot(Color.Green, 5);
IPath yourPolygon = new Star(x: 100.0f, y: 100.0f, prongs: 5, innerRadii: 20.0f, outerRadii:30.0f)
// draws a star with Horizontal red and blue hatching with a dash dot pattern outline.
image.Mutate( x=&gt; x.Fill(options, brush, yourPolygon)
.Draw(option, pen, yourPolygon));
</code></pre><h3 id="api-cornerstones-for-polygon-rasterization">API Cornerstones for Polygon Rasterization</h3>
<p>Our <code>Fill</code> APIs always work off a <code>Brush</code> (some helpers create the brush for you) and will take your provided set of paths and polygons filling in all the pixels inside the vector with the color the brush provides.</p>
<p>Our <code>Draw</code> APIs always work off the <code>Pen</code> where we processes your vector to create an outline with a certain pattern and fill in the outline with an internal brush inside the pen.</p>
<h3 id="drawing-text">Drawing Text</h3>
<p>ImageSharp.Drawing provides several options for drawing text all overloads of a single <code>DrawText</code> API. Our text drawing infrastructure is build on top of our <a href="../fonts">Fonts</a> library. (See <a href="../fonts">SixLabors.Fonts</a> for details on handling fonts.)</p>
<h4 id="minimal-example-1">Minimal Example</h4>
<pre><code class="lang-c#">using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Drawing.Processing;
Image image = ...; // create any way you like.
Font font = ...; // see our Fonts library for best practices on retriving one of these.
string yourText = &quot;this is some sample text&quot;;
image.Mutate( x=&gt; x.DrawText(yourText, font, Color.Black, new PointF(10, 10)));
</code></pre><h4 id="expanded-example-1">Expanded Example</h4>
<pre><code class="lang-c#">using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Drawing.Processing;
using SixLabors.ImageSharp.PixelFormats;
Image image = ...; // create any way you like.
Font font = ...; // see our Fonts library for best practices on retriving one of these.
// The options are optional
TextGraphicsOptions options = new TextGraphicsOptions()
{
ApplyKerning = true,
TabWidth = 8, // a tab renders as 8 spaces wide
WrapTextWidth = 100, // greater than zero so we will word wrap at 100 pixels wide
HorizontalAlignment = HorizontalAlignment.Right // right align
};
IBrush brush = Brushes.Horizontal(Color.Red, Color.Blue);
IPen pen = Pens.DashDot(Color.Green, 5);
string text = &quot;sample text&quot;;
// draws a star with Horizontal red and blue hatching with a dash dot pattern outline.
image.Mutate( x=&gt; x.DrawText(options, text, font, brush, pen, new PointF(100, 100));
</code></pre>
</article>
</div>
<div class="hidden-sm col-md-2" role="complementary">
<div class="sideaffix">
<div class="contribution">
<ul class="nav">
<li>
<a href="https://github.com/SixLabors/docs/blob/master/articles/imagesharp.drawing/gettingstarted.md/#L1" class="contribution-link">Improve this Doc</a>
</li>
</ul>
</div>
<nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
<!-- <p><a class="back-to-top" href="#top">Back to top</a><p> -->
</nav>
</div>
</div>
</div>
</div>
<footer>
<div class="grad-bottom"></div>
<div class="footer">
<div class="container">
<span class="pull-right">
<a href="#top">Back to top</a>
</span>
<span>Copyright © Six Labors<br>Generated by <strong>DocFX</strong></span>
</div>
</div>
</footer>
</div>
<script type="text/javascript" src="../../styles/docfx.vendor.js"></script>
<script type="text/javascript" src="../../styles/docfx.js"></script>
<script type="text/javascript" src="../../styles/main.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,162 @@

<!DOCTYPE html>
<!--[if IE]><![endif]-->
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Introduction </title>
<meta name="viewport" content="width=device-width">
<meta name="title" content="Introduction ">
<meta name="generator" content="docfx 2.52.0.0">
<link rel="shortcut icon" href="../../favicon.png">
<link rel="stylesheet" href="../../styles/docfx.vendor.css">
<link rel="stylesheet" href="../../styles/docfx.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.8/css/all.css" integrity="sha384-3AB7yXWz4OeoZcPbieVW64vVXEwADiYyAEhwilzWsLw+9FgqpyjjStpPnpBO8o8S" crossorigin="anonymous">
<link rel="stylesheet" href="../../styles/main.css">
<meta property="docfx:navrel" content="../../toc.html">
<meta property="docfx:tocrel" content="../toc.html">
<meta property="docfx:rel" content="../../">
</head>
<body data-spy="scroll" data-target="#affix">
<div id="wrapper">
<header>
<nav id="autocollapse" class="navbar navbar-inverse ng-scope" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="../../index.html">
<img id="logo" class="svg" src="../../logo.svg" alt="">
</a>
</div>
<div class="collapse navbar-collapse" id="navbar">
<form class="navbar-form navbar-right" role="search" id="search">
<div class="form-group">
<input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off">
</div>
</form>
</div>
</div>
</nav>
<div class="subnav navbar navbar-default">
<div class="container hide-when-search" id="breadcrumb">
<ul class="breadcrumb">
<li></li>
</ul>
</div>
</div>
</header>
<div class="container body-content">
<div id="search-results">
<div class="search-list"></div>
<div class="sr-items"></div>
<ul id="pagination"></ul>
</div>
</div>
<div role="main" class="container body-content hide-when-search">
<div class="sidenav hide-when-search">
<a class="btn toc-toggle collapse" data-toggle="collapse" href="#sidetoggle" aria-expanded="false" aria-controls="sidetoggle">Show / Hide Table of Contents</a>
<div class="sidetoggle collapse" id="sidetoggle">
<div id="sidetoc"></div>
</div>
</div>
<div class="article row grid-right">
<div class="col-md-10">
<article class="content wrap" id="_content" data-uid="">
<h1 id="introduction">Introduction</h1>
<div class="WARNING"><h5>Warning</h5><p>ImageSharp.Drawing is still considered BETA quality and we still reserve the rights to change the API shapes. WE are yet to priorities performance in our drawing APIs.</p>
</div>
<h3 id="what-is-imagesharpdrawing">What is ImageSharp.Drawing?</h3>
<p>ImageSharp.Drawing is a library build on top on ImageSharp to providing 2D Drawing extensions on top of ImageSharp.</p>
<p>ImageSharp.Drawing is designed from the ground up to be flexible and extensible. The library provides API endpoints for common vector and text processing operations adds the building blocks for building custom image.</p>
<p>Built against <a href="https://docs.microsoft.com/en-us/dotnet/standard/net-standard">.NET Standard 1.3</a>, ImageSharp.Drawing can be used in device, cloud, and embedded/IoT scenarios. </p>
<h3 id="license">License</h3>
<p>ImageSharp.Drawing is licensed under under the terms of <a href="https://www.gnu.org/licenses/agpl-3.0.en.html">GNU Affero General
Public License, version 3</a>. Commercial licensing options are available in addition to this license, see <a href="https://sixlabors.com/pricing">https://sixlabors.com/pricing</a> for details.</p>
<h3 id="installation">Installation</h3>
<p>ImageSharp.Drawing is installed via <a href="https://www.nuget.org/packages/SixLabors.ImageSharp.Drawing">Nuget</a> with nightly builds available on <a href="https://www.myget.org/feed/sixlabors/package/nuget/SixLabors.ImageSharp.Drawing">MyGet</a>.</p>
<div class="tabGroup" id="tabgroup_K+be2w3wNW">
<ul role="tablist">
<li role="presentation">
<a href="#tabpanel_K+be2w3wNW_tabid-1" role="tab" aria-controls="tabpanel_K+be2w3wNW_tabid-1" data-tab="tabid-1" tabindex="0" aria-selected="true">Package Manager</a>
</li>
<li role="presentation">
<a href="#tabpanel_K+be2w3wNW_tabid-2" role="tab" aria-controls="tabpanel_K+be2w3wNW_tabid-2" data-tab="tabid-2" tabindex="-1">.NET CLI</a>
</li>
<li role="presentation">
<a href="#tabpanel_K+be2w3wNW_tabid-3" role="tab" aria-controls="tabpanel_K+be2w3wNW_tabid-3" data-tab="tabid-3" tabindex="-1">PackageReference</a>
</li>
<li role="presentation">
<a href="#tabpanel_K+be2w3wNW_tabid-4" role="tab" aria-controls="tabpanel_K+be2w3wNW_tabid-4" data-tab="tabid-4" tabindex="-1">Paket CLI</a>
</li>
</ul>
<section id="tabpanel_K+be2w3wNW_tabid-1" role="tabpanel" data-tab="tabid-1">
<pre><code class="lang-bash">PM &gt; Install-Package SixLabors.ImageSharp.Drawing -Version VERSION_NUMBER
</code></pre></section>
<section id="tabpanel_K+be2w3wNW_tabid-2" role="tabpanel" data-tab="tabid-2" aria-hidden="true" hidden="hidden">
<pre><code class="lang-bash">dotnet add package SixLabors.ImageSharp.Drawing --version VERSION_NUMBER
</code></pre></section>
<section id="tabpanel_K+be2w3wNW_tabid-3" role="tabpanel" data-tab="tabid-3" aria-hidden="true" hidden="hidden">
<pre><code class="lang-xml">&lt;PackageReference Include=&quot;SixLabors.ImageSharp.Drawing&quot; Version=&quot;VERSION_NUMBER&quot; /&gt;
</code></pre></section>
<section id="tabpanel_K+be2w3wNW_tabid-4" role="tabpanel" data-tab="tabid-4" aria-hidden="true" hidden="hidden">
<pre><code class="lang-bash">paket add SixLabors.ImageSharp.Drawing --version VERSION_NUMBER
</code></pre></section>
</div>
<div class="WARNING"><h5>Warning</h5><p>Prerelease versions installed via the <a href="https://docs.microsoft.com/en-us/nuget/consume-packages/install-use-packages-visual-studio">Visual Studio Nuget Package Manager</a> require the &quot;include prerelease&quot; checkbox to be checked.</p>
</div>
</article>
</div>
<div class="hidden-sm col-md-2" role="complementary">
<div class="sideaffix">
<div class="contribution">
<ul class="nav">
<li>
<a href="https://github.com/SixLabors/docs/blob/master/articles/imagesharp.drawing/index.md/#L1" class="contribution-link">Improve this Doc</a>
</li>
</ul>
</div>
<nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
<!-- <p><a class="back-to-top" href="#top">Back to top</a><p> -->
</nav>
</div>
</div>
</div>
</div>
<footer>
<div class="grad-bottom"></div>
<div class="footer">
<div class="container">
<span class="pull-right">
<a href="#top">Back to top</a>
</span>
<span>Copyright © Six Labors<br>Generated by <strong>DocFX</strong></span>
</div>
</div>
</footer>
</div>
<script type="text/javascript" src="../../styles/docfx.vendor.js"></script>
<script type="text/javascript" src="../../styles/docfx.js"></script>
<script type="text/javascript" src="../../styles/main.js"></script>
</body>
</html>

Просмотреть файл

@ -9,7 +9,7 @@
<title>Introduction </title>
<meta name="viewport" content="width=device-width">
<meta name="title" content="Introduction ">
<meta name="generator" content="docfx 2.50.0.0">
<meta name="generator" content="docfx 2.52.0.0">
<link rel="shortcut icon" href="../favicon.png">
<link rel="stylesheet" href="../styles/docfx.vendor.css">

Просмотреть файл

@ -10,31 +10,55 @@
<div class="toc" id="toc">
<ul class="nav level1">
<li>
<a href="imagesharp/index.html" name="" title="Introduction">Introduction</a>
</li>
<li>
<span class="expand-stub"></span>
<a href="imagesharp/gettingstarted.html" name="" title="Getting Started">Getting Started</a>
<a href="imagesharp/index.html" name="" title="ImageSharp">ImageSharp</a>
<ul class="nav level2">
<li>
<a href="imagesharp/pixelformats.html" name="" title="Pixel Formats">Pixel Formats</a>
<span class="expand-stub"></span>
<a href="imagesharp/gettingstarted.html" name="" title="Getting Started">Getting Started</a>
<ul class="nav level3">
<li>
<a href="imagesharp/pixelformats.html" name="" title="Pixel Formats">Pixel Formats</a>
</li>
<li>
<a href="imagesharp/imageformats.html" name="" title="Image Formats">Image Formats</a>
</li>
<li>
<a href="imagesharp/processing.html" name="" title="Processing Images">Processing Images</a>
</li>
<li>
<a href="imagesharp/workingwithpixelbuffers.html" name="" title="Working with Pixel Buffers">Working with Pixel Buffers</a>
</li>
<li>
<a href="imagesharp/configuration.html" name="" title="Configuration">Configuration</a>
</li>
<li>
<a href="imagesharp/memorymanagement.html" name="" title="Memory Management">Memory Management</a>
</li>
</ul> </li>
</ul> </li>
<li>
<span class="expand-stub"></span>
<a href="imagesharp.drawing/index.html" name="" title="ImageSharp.Drawing">ImageSharp.Drawing</a>
<ul class="nav level2">
<li>
<a href="imagesharp.drawing/gettingstarted.html" name="" title="Getting Started">Getting Started</a>
</li>
</ul> </li>
<li>
<span class="expand-stub"></span>
<a href="fonts/index.html" name="" title="Fonts">Fonts</a>
<ul class="nav level2">
<li>
<a href="fonts/gettingstarted.html" name="" title="Getting Started">Getting Started</a>
</li>
<li>
<a href="imagesharp/imageformats.html" name="" title="Image Formats">Image Formats</a>
</li>
<li>
<a href="imagesharp/processing.html" name="" title="Processing Images">Processing Images</a>
</li>
<li>
<a href="imagesharp/workingwithpixelbuffers.html" name="" title="Working with Pixel Buffers">Working with Pixel Buffers</a>
</li>
<li>
<a href="imagesharp/configuration.html" name="" title="Configuration">Configuration</a>
</li>
<li>
<a href="imagesharp/memorymanagement.html" name="" title="Memory Management">Memory Management</a>
<a href="fonts/customrendering.html" name="" title="Custom Rendering">Custom Rendering</a>
</li>
</ul> </li>
</ul> </div>

Просмотреть файл

@ -9,7 +9,7 @@
<title>Six Labors Documentation. </title>
<meta name="viewport" content="width=device-width">
<meta name="title" content="Six Labors Documentation. ">
<meta name="generator" content="docfx 2.50.0.0">
<meta name="generator" content="docfx 2.52.0.0">
<link rel="shortcut icon" href="favicon.png">
<link rel="stylesheet" href="styles/docfx.vendor.css">

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -71,6 +71,14 @@ h6 mark {
margin-left: 5em;
}
.level0.summary {
margin: 2em 0 2em 0;
}
.level1.summary {
margin: 1em 0 1em 0;
}
span.parametername,
span.paramref,
span.typeparamref {
@ -194,7 +202,9 @@ article h1, article h2, article h3, article h4{
}
article h4{
border-bottom: 1px solid #ccc;
border: 0;
font-weight: bold;
margin-top: 2em;
}
article span.small.pull-right{
@ -843,6 +853,33 @@ footer {
}
}
/* Code snippet */
code {
color: #717374;
background-color: #f1f2f3;
}
a code {
color: #337ab7;
background-color: #f1f2f3;
}
a code:hover {
text-decoration: underline;
}
.hljs-keyword {
color: rgb(86,156,214);
}
.hljs-string {
color: rgb(214, 157, 133);
}
pre {
border: 0;
}
/* For code snippet line highlight */
pre > code .line-highlight {
background-color: #ffffcc;
@ -960,3 +997,16 @@ div.embeddedvideo iframe {
.mainContainer[dir='rtl'] main ul[role="tablist"] {
margin: 0; }
/* Color theme */
/* These are not important, tune down **/
.decalaration, .fieldValue, .parameters, .returns {
color: #a2a2a2;
}
/* Major sections, increase visibility **/
#fields, #properties, #methods, #events {
font-weight: bold;
margin-top: 2em;
}

Просмотреть файл

@ -447,7 +447,11 @@ $(function () {
var val = this.value;
//Save filter string to local session storage
if (typeof(Storage) !== "undefined") {
sessionStorage.filterString = val;
try {
sessionStorage.filterString = val;
}
catch(e)
{}
}
if (val === '') {
// Clear 'filtered' class
@ -514,14 +518,22 @@ $(function () {
tocFilterInput.val("");
tocFilterInput.trigger('input');
if (typeof(Storage) !== "undefined") {
sessionStorage.filterString = "";
try {
sessionStorage.filterString = "";
}
catch(e)
{}
}
});
//Set toc filter from local session storage on page load
if (typeof(Storage) !== "undefined") {
tocFilterInput.val(sessionStorage.filterString);
tocFilterInput.trigger('input');
try {
tocFilterInput.val(sessionStorage.filterString);
tocFilterInput.trigger('input');
}
catch(e)
{}
}
}

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -14,7 +14,7 @@
<a href="articles/imagesharp/index.html" name="articles/toc.html" title="Articles">Articles</a>
</li>
<li>
<a href="api/index.html" name="api/toc.html" title="API Documentation">API Documentation</a>
<a href="api/index.html" name="" title="API Documentation">API Documentation</a>
</li>
</ul> </div>
</div>

Разница между файлами не показана из-за своего большого размера Загрузить разницу

@ -1 +1 @@
Subproject commit 729c8ba84d4c95f4e9930575d3447621e5dedd9f
Subproject commit 1ff1aaaf9445abdccfe6b244daa5c755d8c4899f

@ -1 +1 @@
Subproject commit 37fc697ba397cbe62a2ceffc0b15dfbc32f55832
Subproject commit 424d3886a8074093cbb87e1a15a9ffdf7afa03d3

@ -1 +1 @@
Subproject commit 355758d28d9bb0999dcd98fc81339b8ed1328cb8
Subproject commit bbb764e40cb587b57433329c9c3c376bc16bbe18

@ -1 +1 @@
Subproject commit 893c699757ee8ef82b9c4f22de38086adb20fdb2
Subproject commit dc45b69b09e4e803424939eef326eef0f912ba31