DMISharp 2.1.0
Prefix Reserveddotnet add package DMISharp --version 2.1.0
NuGet\Install-Package DMISharp -Version 2.1.0
<PackageReference Include="DMISharp" Version="2.1.0" />
paket add DMISharp --version 2.1.0
#r "nuget: DMISharp, 2.1.0"
// Install DMISharp as a Cake Addin #addin nuget:?package=DMISharp&version=2.1.0 // Install DMISharp as a Cake Tool #tool nuget:?package=DMISharp&version=2.1.0
<h1 align="center"> <img src="./dmisharp.png" alt="DMISharp" width="256"/> <br/> DMISharp </h1>
DMISharp is a .NET 8.0 library for easily interacting with the BYOND DMI file format.
Developed with ease-of-use in mind, this library provides a simple means for importing, modifying, and exporting DMI files. Internally, images are handled using ImageSharp, a fantastic open-source library from SixLabors.
Installation
Install the current stable release from Nuget.
Getting Started
Important things to note:
- Always dispose DMIFile / DMIState objects. They use unmanaged memory for their sprites.
Ingesting a DMI file from a path:
using var file = new DMIFile("test.dmi")
// do cool things
Ingesting a DMI file from a stream:
// Getting a memory stream from a database with the DMI file's data in the response
using var dmiData = database.GetFile("test.dmi")
using var file = new DMIFile(dmiData)
// do more cool things
Sorting a DMI file's states alphabetically, and saving the resulting DMI file:
using var file = new DMIFile("unsorted_states.dmi")
file.SortStates();
file.Save("sorted_states.dmi");
Sorting a DMI file's states using a provided comparer, and saving the resulting DMI file to a memory stream:
using var stream = new MemoryStream()
using var file = new DMIFile("unsorted_states.dmi")
file.SortStates(new CoolCustomComparer());
file.Save(stream);
Creating a new DMI file with 32x32 pixel states, and creating 3 states from 3 source images:
using var newDMI = new DMIFile(32, 32)
var sourceData = new List<string>() { "sord", "sordvert", "steve32" };
foreach (var source in sourceData)
{
var img = Image.Load<Rgba32>($@"Data/Input/SourceImages/{source}.png");
var newState = new DMIState(source, DirectionDepth.One, 1, 32, 32);
newState.SetFrame(img, 0);
newDMI.AddState(newState);
}
newDMI.Save(@"Data/Output/minecraft.dmi");
Creating a new DMI file with 32x32 pixel states, creating a state, and then modifying that state's frame and direction depth:
using var newDMI = new DMIFile(32, 32)
// Create state
var img = Image.Load<Rgba32>($@"Data/Input/SourceImages/steve32.png");
var newState = new DMIState("steve32", DirectionDepth.One, 1, 32, 32);
newState.SetFrame(img, 0);
newDMI.AddState(newState);
// Modifying state
newDMI.States.First().SetDirectionDepth(DirectionDepth.Four);
newDMI.States.First().SetFrameCount(10);
// At this point you would add the new frames for each direction, otherwise
// you cannot save the file.
// Saving
newDMI.Save(@"Data/Output/minecraft.dmi");
Questions?
Feel free to contact me on Discord at @bobbahbrown
with any questions or concerns. Additionally, I can be found in the /tg/station discord server.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. 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. net7.0 is compatible. 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 is compatible. 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. |
-
net6.0
- CommunityToolkit.HighPerformance (>= 8.2.2)
- MetadataExtractor (>= 2.8.1)
- SixLabors.ImageSharp (>= 3.1.4)
-
net7.0
- CommunityToolkit.HighPerformance (>= 8.2.2)
- MetadataExtractor (>= 2.8.1)
- SixLabors.ImageSharp (>= 3.1.4)
-
net8.0
- CommunityToolkit.HighPerformance (>= 8.2.2)
- MetadataExtractor (>= 2.8.1)
- SixLabors.ImageSharp (>= 3.1.4)
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 |
---|---|---|
2.1.0 | 130 | 7/22/2024 |
2.0.2 | 292 | 7/8/2023 |
2.0.2-alpha.1 | 83 | 7/7/2023 |
2.0.1 | 161 | 7/7/2023 |
2.0.0 | 178 | 7/7/2023 |
1.7.0 | 78,502 | 3/13/2022 |
1.6.2 | 464 | 3/15/2021 |
1.6.1 | 373 | 3/10/2021 |
1.6.0 | 364 | 3/10/2021 |
1.5.1 | 376 | 1/18/2021 |
1.5.0 | 390 | 11/27/2020 |
1.4.1 | 616 | 11/5/2019 |
1.4.0 | 532 | 10/9/2019 |
1.3.4 | 550 | 10/8/2019 |
1.3.3 | 546 | 10/4/2019 |
1.3.2 | 549 | 10/4/2019 |
1.3.1 | 538 | 10/4/2019 |
1.2.1 | 533 | 10/4/2019 |
1.1.2 | 623 | 6/29/2019 |
1.1.0 | 593 | 6/29/2019 |
1.0.2 | 571 | 6/29/2019 |
See notes for this release on GitHub: https://github.com/bobbahbrown/DMISharp/releases/tag/2.1.0