IronSoftware.System.Drawing
v2024.12.3
ironsoftware.drawing是最初由Iron軟件開發的開源庫,可幫助C#軟件工程師替換.NET項目中的drawing.common。
IronSoftware.Drawing.AnyBitmap和支持流行的位圖/圖像格式之間的隱式鑄造:| 隱性鑄造支持 | 支持AnyBitmap | 來自AnyBitmap支持 |
|---|---|---|
System.Drawing.Bitmap | ✅ | ✅ |
System.Drawing.Image | ✅ | ✅ |
SkiaSharp.SKBitmap | ✅ | ✅ |
SkiaSharp.SKImage | ✅ | ✅ |
SixLabors.ImageSharp | ✅ | ✅ |
Microsoft.Maui.Graphics.Platform.PlatformImage | ✅ | ✅ |
IronSoftware.Drawing.Color和以下流行顏色格式之間的隱式鑄造:| 隱性鑄造支持 | Color支持 | 來自Color支持 |
|---|---|---|
SkiaSharp.SKColor | ✅ | ✅ |
SixLabors.ImageSharp.Color | ✅ | ✅ |
SixLabors.ImageSharp.PixelFormats | ✅ | ✅ |
IronSoftware.Drawing.Rectangle和支持流行的矩形格式之間的隱式鑄造:| 隱性鑄造支持 | 支撐Rectangle | 從Rectangle支撐 | 支持RectangleF | 從RectangleF支撐 |
|---|---|---|---|---|
System.Drawing.Rectangle | ✅ | ✅ | ||
System.Drawing.RectangleF | ✅ | ✅ | ||
SkiaSharp.SKRect | ✅ | ✅ | ||
SkiaSharp.SKRectI | ✅ | ✅ | ||
SixLabors.ImageSharp.Rectangle | ✅ | ✅ | ||
SixLabors.ImageSharp.RectangleF | ✅ | ✅ |
IronSoftware.Drawing.Size和以下流行大小格式之間的隱式鑄造:| 隱性鑄造支持 | 支撐Size | 來自支撐的Size | 支持SizeF | 從支持的SizeF |
|---|---|---|---|---|
System.Drawing.Size | ✅ | ✅ | ||
System.Drawing.SizeF | ✅ | ✅ | ||
SkiaSharp.SKSize | ✅ | ✅ | ||
SkiaSharp.SKSizeI | ✅ | ✅ | ||
SixLabors.ImageSharp.Size | ✅ | ✅ | ||
SixLabors.ImageSharp.SizeF | ✅ | ✅ | ||
Microsoft.Maui.Graphics.Size | ✅ | ✅ | ||
Microsoft.Maui.Graphics.SizeF | ✅ | ✅ |
IronSoftware.Drawing.Font和遵循支持的流行字體格式之間的隱式鑄造:| 隱性鑄造支持 | 支持Font | 從Font支撐 |
|---|---|---|
System.Drawing.Font | ✅ | ✅ |
SkiaSharp.SKFont | ✅ | ✅ |
SixLabors.Fonts.Font | ✅ | ✅ |
IronSoftware.Drawing.Point和IronSoftware.Drawing.PointF和以下支持之間的隱式鑄造:| 隱性鑄造支持 | Point支持 | 從支持Point | 支持PointF | 來自PointF支持 |
|---|---|---|---|---|
System.Drawing.Point | ✅ | ✅ | ||
System.Drawing.PointF | ✅ | ✅ | ||
SixLabors.ImageSharp.Point | ✅ | ✅ | ||
SixLabors.ImageSharp.PointF | ✅ | ✅ | ||
Microsoft.Maui.Graphics.Point | ✅ | ✅ | ||
Microsoft.Maui.Graphics.PointF | ✅ | ✅ | ||
SkiaSharp.SKPoint | ✅ | ✅ | ||
SkiaSharp.SKPointI | ✅ | ✅ |
安裝ironsoftware.drawing nuget軟件包快速簡便,請這樣安裝包裝:
PM> Install-Package IronSoftware.System.Drawing
或者,直接從Nuget官方網站下載。
安裝後,您可以using IronSoftware.Drawing;到您的C#代碼頂部。
AnyBitmap代碼示例 using IronSoftware . Drawing ;
// Create a new AnyBitmap object
var bitmap = AnyBitmap . FromFile ( "FILE_PATH" ) ;
bitmap . SaveAs ( "result.jpg" ) ;
var bytes = bitmap . ExportBytes ( ) ;
var resultExport = new System . IO . MemoryStream ( ) ;
bitmap . ExportStream ( resultExport , AnyBitmap . ImageFormat . Jpeg , 100 ) ;
// Casting between System.Drawing.Bitmap and IronSoftware.Drawing.AnyBitmap
System . Drawing . Bitmap image = new System . Drawing . Bitmap ( "FILE_PATH" ) ;
IronSoftware . Drawing . AnyBitmap anyBitmap = image ;
anyBitmap . SaveAs ( "result-from-casting.png" ) ;
// Creates a Multi-page Tiff-style AnyBitmap from an Image array
List < AnyBitmap > bitmaps = new List < AnyBitmap > ( )
{
AnyBitmap . FromFile ( "FILE_PATH_1" ) ,
AnyBitmap . FromFile ( "FILE_PATH_2" )
} ;
AnyBitmap anyBitmap = AnyBitmap . CreateMultiFrameTiff ( bitmaps ) ;
// Creates a Multi-page Tiff-style AnyBitmap from a fully qualified file path array
List < string > imagePaths = new List < string > ( )
{
"FILE_PATH_1" ,
"FILE_PATH_2"
} ;
AnyBitmap anyBitmap = AnyBitmap . CreateMultiFrameTiff ( imagePaths ) ;
// Manipulate image frames
int frameCount = anyBitmap . FrameCount ;
List < AnyBitmap > frames = ( List < AnyBitmap > ) anyBitmap . GetAllFrames ;Color代碼示例 using IronSoftware . Drawing ;
// Create a new Color object
Color fromHex = new Color ( "#191919" ) ;
Color fromRgb = new Color ( 255 , 255 , 0 ) ;
Color fromEnum = Color . Crimson ;
// Casting between System.Drawing.Color and IronSoftware.Drawing.Color
System . Drawing . Color drawingColor = System . Drawing . Color . Red ;
IronSoftware . Drawing . Color ironColor = drawingColor ;
ironColor . A ;
ironColor . R ;
ironColor . G ;
ironColor . B ;
// Luminance is a value from 0 (black) to 100 (white) where 50 is the perceptual "middle grey"
ironColor . GetLuminance ( ) ;
// Gets the 32-bit ARGB value of this Color structure.
ironColor . ToArgb ( ) ;Rectangle代碼示例 using IronSoftware . Drawing ;
// Create a new Rectangle object
Rectangle rectangle = new Rectangle ( 5 , 5 , 50 , 50 ) ;
// Create a new Rectangle object with MeasurementUnits
Rectangle mmRectangle = new Rectangle ( 5 , 5 , 50 , 50 , MeasurementUnits . Millimeters ) ;
// Convert between MeasurementUnits
Rectangle pxRectangle = mmRectangle . ConvertTo ( MeasurementUnits . Millimeters ) ;
// Or specify DPI
Rectangle pxRectangleWithDPI = mmRectangle . ConvertTo ( MeasurementUnits . Millimeters , 200 ) ;
// Casting between System.Drawing.Rectangle and IronSoftware.Drawing.Rectangle
System . Drawing . Rectangle rectangle = new System . Drawing . Rectangle ( 10 , 10 , 150 , 150 ) ;
IronSoftware . Drawing . Rectangle ironRectangle = rectangle ;
ironRectangle . X ;
ironRectangle . Y ;
ironRectangle . Width ;
ironRectangle . Height ;Size代碼示例 using IronSoftware . Drawing ;
// Create a new Size object
Size size = new Size ( 50 , 50 ) ;
// Casting between System.Drawing.Size and IronSoftware.Drawing.Size
System . Drawing . Size systemSize = new System . Drawing . Size ( 150 , 150 ) ;
IronSoftware . Drawing . Size ironSize = systemSize ;
ironSize . Width ;
ironSize . Height ;Font代碼示例 using IronSoftware . Drawing ;
// Create a new Font object
Font font = new Font ( "Times New Roman" , FontStyle . Italic | FontStyle . Bold , 30 ) ;
// Casting between System.Drawing.Font and IronSoftware.Drawing.Font
System . Drawing . Font drawingFont = new System . Drawing . Font ( "Courier New" , 30 ) ;
IronSoftware . Drawing . Font ironFont = drawingFont ;
ironFont . FamilyName ;
ironFont . Style ;
ironFont . Size ;
ironFont . Italic ;
ironFont . Bold ; 有關鐵軟件的更多信息,請訪問我們的網站:https://ironsoftware.com/
有關一般支持和技術查詢,請給我們發送電子郵件:[email protected]