using IronSoftware.Drawing;
using System;
using System.IO;
AnyBitmap bitmap;
// Generate AnyBitmap using filepath
bitmap = AnyBitmap.FromFile(@"FILE_PATH");
bitmap.SaveAs("output.bmp");
// Generate AnyBitmap from bytes
byte[] bytes = File.ReadAllBytes(@"FILE_PATH");
bitmap = AnyBitmap.FromBytes(bytes);
bitmap.SaveAs("result.bmp");
// Generate AnyBitmap from memory stream
byte[] bytes2 = File.ReadAllBytes(@"FILE_PATH");
MemoryStream ms = new MemoryStream(bytes2);
bitmap = AnyBitmap.FromStream(ms);
bitmap.SaveAs("output.bmp");
// Generate AnyBitmap from Uri
Uri uri = new Uri("URI_PATH");
bitmap = await AnyBitmap.FromUriAsync(uri);
bitmap.SaveAs("uriImage.bmp");
// Generate AnyBitmap file from SVG file
bitmap = AnyBitmap.FromFile(@"FILE_PATH.svg");
bitmap.SaveAs("result.jpg");
Imports IronSoftware.Drawing
Imports System
Imports System.IO
Private bitmap As AnyBitmap
' Generate AnyBitmap using filepath
bitmap = AnyBitmap.FromFile("FILE_PATH")
bitmap.SaveAs("output.bmp")
' Generate AnyBitmap from bytes
Dim bytes() As Byte = File.ReadAllBytes("FILE_PATH")
bitmap = AnyBitmap.FromBytes(bytes)
bitmap.SaveAs("result.bmp")
' Generate AnyBitmap from memory stream
Dim bytes2() As Byte = File.ReadAllBytes("FILE_PATH")
Dim ms As New MemoryStream(bytes2)
bitmap = AnyBitmap.FromStream(ms)
bitmap.SaveAs("output.bmp")
' Generate AnyBitmap from Uri
Dim uri As New Uri("URI_PATH")
bitmap = Await AnyBitmap.FromUriAsync(uri)
bitmap.SaveAs("uriImage.bmp")
' Generate AnyBitmap file from SVG file
bitmap = AnyBitmap.FromFile("FILE_PATH.svg")
bitmap.SaveAs("result.jpg")
IronDrawing 也可以直接從 URI 生成 AnyBitmap。使用者需要初始化並將 URI 路徑存儲到 URI 類型變數 Uri uri = new Uri("URI_PATH")將 Uri 變數使用 AnyBitmap.FromUri 存儲到 AnyBitmap 類型變數,並生成 AnyBitmap 文件(URI)` 方法。