FrameworkExtensions.System.Drawing 1.0.0.49

There is a newer version of this package available.
See the version list below for details.
dotnet add package FrameworkExtensions.System.Drawing --version 1.0.0.49
                    
NuGet\Install-Package FrameworkExtensions.System.Drawing -Version 1.0.0.49
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FrameworkExtensions.System.Drawing" Version="1.0.0.49" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FrameworkExtensions.System.Drawing" Version="1.0.0.49" />
                    
Directory.Packages.props
<PackageReference Include="FrameworkExtensions.System.Drawing" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FrameworkExtensions.System.Drawing --version 1.0.0.49
                    
#r "nuget: FrameworkExtensions.System.Drawing, 1.0.0.49"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package FrameworkExtensions.System.Drawing@1.0.0.49
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FrameworkExtensions.System.Drawing&version=1.0.0.49
                    
Install as a Cake Addin
#tool nuget:?package=FrameworkExtensions.System.Drawing&version=1.0.0.49
                    
Install as a Cake Tool

Extensions to System.Drawing

Build Tests

Last Commit NuGet Version License

Extension methods for System.Drawing types (bitmaps, images, colors, graphics).


Extension Methods

Bitmap Extensions (Bitmap)

Bitmap Locking
  • Lock(...) - Lock bitmap for direct pixel access (8 overloads for different combinations)
    • Lock() - Lock entire bitmap with ReadWrite mode
    • Lock(Rectangle) - Lock region
    • Lock(ImageLockMode) - Lock with specific mode
    • Lock(PixelFormat) - Lock with specific format
    • Lock(Rectangle, ImageLockMode)
    • Lock(Rectangle, PixelFormat)
    • Lock(ImageLockMode, PixelFormat)
    • Lock(Rectangle, ImageLockMode, PixelFormat) - Full control
    • Returns format-specific IBitmapLocker implementation
Transformations
  • ConvertPixelFormat(PixelFormat) - Convert bitmap to different pixel format
  • Crop(Rectangle, PixelFormat = DontCare) - Extract region from bitmap
  • Resize(int width, int height, InterpolationMode = Bicubic) - Resize bitmap
  • Rotated(float angle, Point? center = null) - Create rotated copy of bitmap
  • RotateInplace(float angle, Point? center = null) - Rotate bitmap in-place
  • RotateTo(Bitmap target, float angle, Point? center = null) - Rotate to target bitmap

Image Extensions (Image)

Multi-Page Support
  • GetPageAt(int page) - Get specific page from multi-page image (e.g., TIFF)
  • GetPageCount() - Get total number of pages in image
Save Operations
  • SaveToPng(FileInfo/string) - Save image as PNG
  • SaveToTiff(string) - Save image as TIFF
  • SaveToJpeg(string/Stream, double quality = 1) - Save as JPEG with quality (0.0-1.0)
Conversions
  • ToIcon(int targetRes = 0) - Convert image to Icon
  • ToBase64DataUri() - Convert to Base64 data URI string
  • FromBase64DataUri(string) (static-like extension on string) - Create image from Base64 data URI
Image Processing
  • MakeGrayscale() - Convert image to grayscale
  • Threshold(byte threshold = 127) - Apply threshold filter (black/white)
  • ApplyPixelProcessor(Func<Color, Color> processor) - Apply custom pixel transformation function
  • MirrorAlongX() - Mirror horizontally
  • MirrorAlongY() - Mirror vertically
  • Resize(int longSide) - Resize to fit within square, keep aspect
  • Resize(int longSide, Color fillColor) - Resize with fill color
  • Resize(int width, int height, bool keepAspect = true, Color? fillColor = null) - Resize with options
  • Resize(int width = -1, int height = -1, InterpolationMode = Default) - Resize with interpolation
  • Rotate(float angle) - Rotate image by angle
  • GetRectangle(Rectangle) - Extract rectangular region
  • ReplaceColorWithTransparency(Color) - Replace specific color with transparency

Color Extensions (Color)

Color Space Conversion
  • GetLuminance() - Calculate luminance (Y component in YUV)
  • GetChrominanceU() - Calculate U chrominance component
  • GetChrominanceV() - Calculate V chrominance component
Color Comparison
  • IsLike(Color other, byte luminanceDelta = 24, byte chromaUDelta = 7, byte chromaVDelta = 6) - Compare colors in YUV space with tolerance
  • IsLikeNaive(Color other, int tolerance = 2) - Simple RGB comparison with tolerance
Color Blending
  • BlendWith(Color other, float current, float max) - Interpolate between two colors

Graphics Extensions (Graphics)

  • DrawString(float x, float y, string text, Font font, Brush brush, ContentAlignment anchor) - Draw text with anchor positioning
  • DrawCross(float/int x, float/int y, float/int size, Pen pen) - Draw cross marker (4 overloads including Point/PointF)
  • DrawCircle(Pen pen, float centerX, float centerY, float radius) - Draw circle outline
  • FillCircle(Brush brush, float centerX, float centerY, float radius) - Draw filled circle

Rectangle Extensions (Rectangle)

  • MultiplyBy(int factor) - Scale rectangle uniformly
  • MultiplyBy(int xfactor, int yfactor) - Scale rectangle with different X/Y factors
  • CollidesWith(Rectangle/RectangleF) - Check rectangle collision
  • CollidesWith(Point/PointF) - Check if point is inside
  • CollidesWith(int x, int y) / CollidesWith(float x, float y) - Check if coordinates are inside
  • Center() - Get center point
  • SetLeft/SetRight/SetTop/SetBottom(int) - Create new rectangle with modified edge

RectangleF Extensions (RectangleF)

(Similar methods to Rectangle, for floating-point rectangles)


Size Extensions (Size)

  • Center() - Get center point

Point Extensions (Point)

(Generated from T4 template - numeric operations on points)


FileInfo Extensions (FileInfo)

  • GetIcon(bool smallIcon = false, bool linkOverlay = false) - Get Windows shell icon for file
    • Uses native SHGetFileInfo API

Custom Types

IBitmapLocker Interface

Format-specific bitmap pixel access implementations:

  • ARGB32BitmapLocker - 32-bit ARGB (Format32bppArgb)
  • RGB32BitmapLocker - 32-bit RGB (Format32bppRgb)
  • RGB24BitmapLocker - 24-bit RGB (Format24bppRgb)
  • RGB565BitmapLocker - 16-bit RGB 565 (Format16bppRgb565)
  • ARGB1555BitmapLocker - 16-bit ARGB 1555 (Format16bppArgb1555)
  • Gray16BitmapLocker - 16-bit grayscale (Format16bppGrayScale)
  • RGB555BitmapLocker - 16-bit RGB 555 (Format16bppRgb555)
  • Indexed8BitmapLocker - 8-bit indexed (Format8bppIndexed)
  • IndexedBitmapLocker - 1-bit and 4-bit indexed (Format1bppIndexed, Format4bppIndexed)
  • UnsupportedDrawingBitmapLocker - Fallback for unsupported formats

Each locker provides optimized pixel access for its specific format.


Installation

dotnet add package FrameworkExtensions.System.Drawing

License

LGPL 3.0 or later - See LICENSE for details

Product 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.  net6.0-windows7.0 is compatible.  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 netcoreapp3.1 is compatible. 
.NET Framework net35 is compatible.  net40 is compatible.  net403 was computed.  net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0.91 82 1/19/2026
1.0.0.79 92 1/5/2026
1.0.0.70 102 12/29/2025
1.0.0.55 181 12/22/2025
1.0.0.49 213 12/15/2025
1.0.0.46 206 9/29/2025
1.0.0.45 197 8/4/2025
1.0.0.37 191 7/7/2025
1.0.0.36 226 2/24/2025
1.0.0.35 310 6/24/2024
1.0.0.33 190 6/17/2024
1.0.0.31 194 6/10/2024
1.0.0.30 179 5/27/2024
1.0.0.29 199 5/6/2024
1.0.0.27 196 4/29/2024
1.0.0.25 208 4/1/2024
1.0.0.24 191 3/25/2024
1.0.0.23 185 3/5/2024
1.0.0.22 260 7/23/2023
1.0.0.21 236 7/21/2023
1.0.0.20 241 7/19/2023
1.0.0.19 222 7/19/2023
1.0.0.17 247 7/19/2023