DRIT.Drawing
26.7.874
dotnet add package DRIT.Drawing --version 26.7.874
NuGet\Install-Package DRIT.Drawing -Version 26.7.874
<PackageReference Include="DRIT.Drawing" Version="26.7.874" />
<PackageVersion Include="DRIT.Drawing" Version="26.7.874" />
<PackageReference Include="DRIT.Drawing" />
paket add DRIT.Drawing --version 26.7.874
#r "nuget: DRIT.Drawing, 26.7.874"
#:package DRIT.Drawing@26.7.874
#addin nuget:?package=DRIT.Drawing&version=26.7.874
#tool nuget:?package=DRIT.Drawing&version=26.7.874
DRIT.Drawing
Pure-Managed 2D Graphics Library for .NET
System.Drawing.Common Replacement with Vector SVG, Metafile, and APNG Support
DRIT.Drawing is a pure-managed, cross-platform 2D graphics library for .NET that provides a direct replacement for System.Drawing.Common. It offers an intuitive API for drawing bitmap images, geometric shapes, and applying graphic transformations without relying on any third-party native libraries — and captures any drawing as true vector SVG or EMF/WMF metafile output.
Key Benefits
- Zero native dependencies – pure managed C# implementation, no
System.Drawing.Commonrequired- Consistent rendering results across Windows, Linux, macOS, and Azure
- Seamless migration path from
System.Drawing.Common- Vector-first architecture – draw to true vector SVG or record EMF/WMF, not just raster
- Built-in font support with comprehensive TrueType/OpenType/CFF/Type1/WOFF/WOFF2 parsing
- Integrated WMF/EMF/EMF+ metafile support for reading and writing vector graphics
- Full Unicode bidirectional text (UAX #9), font fallback, rich text runs, and text-on-path
- Animated PNG (APNG) read/write through the standard multi-frame API
Cross-Platform Graphics Library
DRIT.Drawing supports 32-bit and 64-bit systems across multiple platforms:
- Operating Systems: Windows, Linux, macOS, Azure
- Frameworks: .NET Standard 2.0, .NET 6.0+
- Environments: ASP.NET Core, Blazor WebAssembly, Console applications
Features
Geometric Drawing API
Draw lines, shapes, rectangles, polygons, arcs, and Bezier curves with a cross-platform C# API:
Graphics.DrawLine,DrawRectangle,DrawEllipse,DrawPolygonGraphics.DrawArc,DrawBezier,DrawCurveGraphicsPathfor complex shape constructionRegionfor clipping and hit-testing
Transformations Support
Apply different transformations to 2D objects:
Graphics.TranslateTransform,RotateTransform,ScaleTransformMatrixclass for custom transformationsGraphics.Transformproperty for coordinate system changes
Drawing Tools
Working with Pens
- Set pen width and color
- Line join styles (miter, bevel, round)
- Dash patterns and line caps
Working with Brushes
SolidBrush– fill with solid colorsLinearGradientBrush– create gradient fillsPathGradientBrush– complex gradient patternsHatchBrush– patterned fillsTextureBrush– image-based fills
Image Rendering
- Antialiasing: 4× MSAA with per-edge coverage for smooth edges
- Clipping: Define clip regions with
Graphics.SetClip - Alpha Blending: Transparency support for layered compositions
- Interpolation: Nearest-neighbor, bilinear, and bicubic image scaling
- ImageAttributes: Color matrix, gamma, color key, remap table, threshold
Working with Text and Fonts
DrawStringfor text rendering with full font support- Built-in TrueType, OpenType, CFF, Type1, WOFF/WOFF2 font loading
- Font metrics: ascender, descender, line gap, units per EM
- Glyph outline rendering with
IGlyphOutlinePainter - Text hinting and anti-aliasing options
- Font family and style support
Integrated Font Capabilities
DRIT.Drawing includes a comprehensive font engine that provides text measurement and rendering without any external dependencies:
- Font Loading: Load fonts from files or byte arrays in TTF, OTF, CFF, Type1, WOFF, and WOFF2 formats
- Font Metrics: Access ascender, descender, line gap, and units-per-EM values for precise text layout
- Glyph Access: Query glyph bounding boxes and advance widths for accurate text measurement
- Glyph Rendering: Use
IGlyphOutlinePainterto render glyph outlines with custom implementations - Font Collections: Support for TTC (TrueType Collection) files with multiple fonts
- Font Subsetting: Create optimized font subsets containing only required glyphs
Bidirectional Text (UAX #9)
- Full Unicode Bidirectional Algorithm — RTL scripts (Arabic, Hebrew, …) and mixed-direction text
StringFormatFlags.DirectionRightToLeftsets the paragraph embedding direction- Mirroring of bracket/punctuation characters in RTL runs
- Enabled by default on existing
DrawString(matches GDI+ behavior)
Font Fallback
- Automatic glyph substitution from a fallback font chain when the primary font lacks a glyph
StringFormatFlags.NoFontFallbackopts out (matches GDI+ behavior)- Curated per-OS default chain (Segoe UI → Segoe UI Symbol → Segoe UI Emoji on Windows; DejaVu Sans → Noto Sans on Linux)
- Custom
FontFallbackChainconfigurable perGraphicssurface
Rich Text Runs
DrawRichText/MeasureRichText/AddRichTextfor mixed fonts, sizes, styles, and brushes in a single layoutRichTextOptions+RichTextRundescribe per-range overrides- Word wrapping across run boundaries; shared baseline for mixed-size runs
Text on Path
DrawStringOnPath/AddStringOnPathrender text along an arbitrary vector baseline- Each glyph is positioned and rotated tangent to the path
TextOnPathOptionscontrols start offset, perpendicular offset, alignment, and overflow
Vector Graphics (SVG + Vector Domain Model)
DRIT.Drawing is vector-first: any drawing performed through a Graphics surface can be captured as true vector output via a format-agnostic VectorScene domain model.
RecordingGraphics– aGraphicssurface that records drawing commands instead of rasterizing; same public API asGraphicsSvgImage– a vectorImagesubclass; load/save SVG, rasterize toBitmap, or convert to EMF/WMF- SVG Writer –
VectorScene→ SVG with<path>,<linearGradient>/<radialGradient>,<pattern>,<clipPath>,<text>(path or text mode), and embedded<image>elements - SVG Reader – SVG →
VectorScenevia a streamingXmlReader-based parser; tolerant of malformed input - EMF/WMF Bridge – bidirectional transcoding between
VectorSceneand metafile records - EMF/WMF Recording – capture any
Graphicsdrawing as EMF/WMF (previously playback-only) - Conversions – Graphics ↔ SVG ↔ EMF/WMF ↔ Bitmap, all through the single
VectorScenepivot
Metafile Support (WMF/EMF/EMF+)
DRIT.Drawing includes integrated metafile support for Windows Metafile (WMF), Enhanced Metafile (EMF), and EMF+ formats:
- Metafile Reading: Parse WMF, EMF, and EMF+ metafiles with full record support
- Metafile Writing: Create and save metafiles in WMF, EMF, and EMF+ formats
- Record Types: Support for all standard WMF, EMF, and EMF+ record types
- Placeable Metafiles: Read and write placeable WMF headers for device-independent rendering
- Playback Integration: Render metafiles directly to
Graphicsobjects for display or conversion
Supported File Formats
| Format | Description | Read | Write |
|---|---|---|---|
| BMP | Bitmap Image Format | ✔️ | ✔️ |
| PNG | Portable Network Graphics | ✔️ | ✔️ |
| APNG | Animated PNG (Mozilla APNG 1.0) | ✔️ | ✔️ |
| JPEG | Baseline (SOF0/SOF1) + Progressive (SOF2) | ✔️ | ✔️ |
| GIF | Graphics Interchange Format | ✔️ | ✔️ |
| TIFF | Tagged Image File Format | ✔️ | ✔️ |
| ICO | Icon Format | ✔️ | ✔️ |
| SVG | Scalable Vector Graphics (SVG 1.1) | ✔️ | ✔️ |
| WMF | Windows Metafile | ✔️ | ✔️ |
| EMF | Enhanced Metafile | ✔️ | ✔️ |
| EMF+ | Enhanced Metafile Plus | ✔️ | ✔️ |
Installation
1. Install via NuGet
- Open Microsoft Visual Studio and the NuGet package manager
- Search for "DRIT.Drawing"
- Click Install to download and reference it in your project
2. Install via Package Manager Console
Install-Package DRIT.Drawing
3. Install via .NET CLI
dotnet add package DRIT.Drawing
Code Examples
Create a Bitmap and Draw Shapes
// Create a bitmap object
using var bitmap = new Bitmap(1000, 800);
// Initialize a Graphics object
using var graphics = Graphics.FromImage(bitmap);
// Define a pen with color and width
using var pen = new Pen(Color.Blue, 2);
// Draw a rectangle
graphics.DrawRectangle(pen, new Rectangle(100, 100, 300, 200));
// Draw an ellipse
graphics.DrawEllipse(pen, new Rectangle(500, 100, 300, 200));
// Save the image as PNG
bitmap.Save("output_shapes.png");
Draw Text with Anti-Aliasing
// Create a bitmap object
using var bitmap = new Bitmap(1000, 800);
// Initialize a Graphics object with anti-aliasing
using var graphics = Graphics.FromImage(bitmap);
graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
// Define font, brush, and format for the text
var font = new Font("Arial", 24);
var brush = new SolidBrush(Color.Black);
var format = new StringFormat { Alignment = StringAlignment.Center };
// Draw the string
graphics.DrawString("Hello World!", font, brush, new RectangleF(100, 300, 800, 100), format);
// Save the image
bitmap.Save("output_text.png");
Create a Gradient Fill
// Create a bitmap object
using var bitmap = new Bitmap(800, 600);
// Initialize a Graphics object
using var graphics = Graphics.FromImage(bitmap);
// Create a linear gradient brush
var brush = new LinearGradientBrush(
new Point(0, 0),
new Point(800, 600),
Color.Red,
Color.Blue);
// Fill a rectangle with the gradient
graphics.FillRectangle(brush, new Rectangle(100, 100, 600, 400));
// Save the image
bitmap.Save("output_gradient.png");
Draw a Bezier Curve
// Create a bitmap object
using var bitmap = new Bitmap(1000, 800);
// Initialize a Graphics object
using var graphics = Graphics.FromImage(bitmap);
// Define a pen for drawing
using var pen = new Pen(Color.Green, 3);
// Define control points for Bezier curve
Point pt1 = new Point(100, 100);
Point pt2 = new Point(200, 10);
Point pt3 = new Point(350, 400);
Point pt4 = new Point(500, 300);
// Draw the Bezier curve
graphics.DrawBezier(pen, pt1, pt2, pt3, pt4);
// Save the image
bitmap.Save("output_bezier.png");
Draw to Vector SVG
// A vector canvas — drawing is captured as vector commands, not rasterized
using var svg = new SvgImage(800, 600);
using var g = svg.CreateGraphics(); // RecordingGraphics, same API as Graphics
g.Clear(Color.White);
g.DrawEllipse(new Pen(Color.Blue, 2), 100, 100, 200, 200);
g.DrawString("Hello", new Font("Arial", 16), Brushes.Black, 200, 200);
svg.Save("drawing.svg", ImageFormat.Svg); // true vector SVG
Convert Between SVG, EMF, and Bitmap
// Load SVG, rasterize, or convert to EMF
using var svg = new SvgImage("input.svg");
svg.RenderToBitmap().Save("output.png", ImageFormat.Png);
svg.Save("output.emf", ImageFormat.Emf); // SVG → EMF
// Convert EMF to SVG
using var emf = new Metafile("chart.emf");
emf.Save("chart.svg", ImageFormat.Svg);
Animated PNG (APNG)
using var bmp = new Bitmap("animated.apng");
int frames = bmp.GetFrameCount(FrameDimension.Time);
for (int i = 0; i < frames; i++)
{
bmp.SelectActiveFrame(FrameDimension.Time, i);
bmp.Save($"frame{i}.png", ImageFormat.Png);
}
Text on a Path
using var circle = new GraphicsPath();
circle.AddEllipse(100, 50, 400, 300);
graphics.DrawStringOnPath("Around the circle we go",
new Font("Arial", 20f), brush, circle,
new StringFormat { Alignment = StringAlignment.Center });
Rich Text, Bidi, and Font Fallback
// RTL Hebrew — renders right-to-left automatically
graphics.DrawString("שלום עולם", new Font("Arial", 24f), brush,
new RectangleF(0, 20, 600, 40),
new StringFormat(StringFormatFlags.DirectionRightToLeft));
// Fallback — CJK chars render from a fallback font
graphics.DrawString("Hello 世界", new Font("Arial", 24f), brush, 20f, 80f);
// Rich text — mixed fonts/styles/colors
var rich = new RichTextOptions(new FontFamily("Arial"), 18f)
{
Runs =
{
new RichTextRun(0, 6),
new RichTextRun(6, 5) { FontStyle = FontStyle.Bold },
new RichTextRun(11, 4) { EmSize = 28f },
new RichTextRun(15, 5) { Brush = new SolidBrush(Color.Red) },
}
};
graphics.DrawRichText("Hello WorldBig!Red!", rich, brush, new RectangleF(20, 160, 560, 60));
System Requirements
- Target Frameworks: .NET Standard 2.0, .NET 6.0+
- Dependencies: None – all font, graphics, vector, and metafile functionality is built-in
Documentation
- DRIT.Drawing Implementation Plan
- SVG + Vector Domain Model Plan
- APNG Implementation Plan
- Text-on-Path Plan
- Rich Text / Bidi / Fallback Plan
- API Reference (coming soon)
© 2021-2026 DR-IT Ltd. All Rights Reserved.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
This package has no dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on DRIT.Drawing:
| Package | Downloads |
|---|---|
|
DRIT.Spreadsheet
DRIT.Spreadsheet is a pure-managed, cross-platform .NET library for creating, reading, and manipulating spreadsheet documents (XLSX, XLS, XLSB, CSV, TSV). It offers comprehensive spreadsheet capabilities including a formula calculation engine, charts, pivot tables, tables, conditional formatting, data validation, digital signatures (PKCS#12, XAdES-BES), AES-256 encryption, form controls, VBA macros, and PDF export — built on a clean-room implementation with minimal NuGet dependencies. |
|
|
DRIT.Pdf
DRIT.Pdf is a pure-managed, cross-platform .NET library for creating, reading, and manipulating PDF documents. It offers comprehensive PDF capabilities including AcroForms, digital signatures (PKCS#12, PKCS#11, PAdES), encryption, a full annotation hierarchy, tagged PDFs and PDF/UA, PDF/A and PDF/X conformance writing, portfolios, document comparison, and image conversion — built on a clean-room PDF 1.7/2.0 implementation with minimal NuGet dependencies. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 26.7.874 | 34 | 7/30/2026 |
-.NET 6.0 support added.