Cast to AnyBitmap

In order to use and manipulate any image file in IronDrawing, all files must be converted to AnyBitmap file, and for files from other platforms, IronDrawing are able to cast the files to AnyBitmap files. Following are examples of image files from other platforms that can be cast to AnyBitmap file

System.Drawing.Bitmap

Bitmap from System.Drawing can be casted to AnyBitmap files by loading a System Drawing file from file path using System.Drawing.Bitmap(@"FILE_PATH") then cast the file by assigning it to a variable initialized with AnyBitmap type.

System.Drawing.Image

Casting images from System Image can be done by loading the file from a file path using System.Drawing.Image.FromFile(@"FILE_PATH") and store it in a variable with AnyBitmap type.

SkiaSharp.SKBitmap

Casting bitmap from SkiaSharp can be done by initializing a SkiaSharp.SKBitmap variable and store the file loaded from a file path using SkiaSharp.SKBitmap.Decode(@"FILE_PATH"). The file can then be cast to AnyBitmap type by storing it in a variable with AnyBitmap type.

SkiaSharp.SKImage

To load SkiaSharp image load the file using SkiaSharp.SKImage.FromBitmap(SkiaSharp.SKBitmap.Decode(@"FILE_PATH") and store inside a SkiaSharp.SKImage variable. It can then be cast to AnyBitmap file by assigning it to a variable of AnyBitmap type.

SixLabors

Images from SixLabors can be loaded from file path using the code SixLabors.ImageSharp.Image.Load<SixLabors.ImageSharp.PixelFormats.Rgba32>(@"FILE_PATH") and store it in SixLabors.ImageSharp.Image<SixLabors.ImageSharp.PixelFormats.Rgba32> variable. It can then be casted into AnyBitmap file by assigning it to an AnyBitmap variable.

MAUI Image

Casting of Maui image to AnyBitmap file can only be done in environments other than NET4.7.2. Maui image file can be loaded by read the bytes of the image obtained from a file path using File.ReadAllBytes(@"FILE_PATH") and store the bytes in an array byte []. The bytes must be translated into image by using Microsoft.Maui.Graphics.Platform.PlatformImage.FromStream(new MemoryStream(byte [])) and can then be casted to AnyBitmap file by assigning it to a variable of AnyBitmap type.