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)使用 AnyBitmap.FromUri 将 Uri 变量存储到 AnyBitmap 类型变量中,生成 AnyBitmap 文件。(uri)方法。