DMISharp 1.8.0
Prefix ReservedThis version is erroneous and should not be used as it contains breaking API changes despite being a minor version change.
See the version list below for details.
dotnet add package DMISharp --version 1.8.0
NuGet\Install-Package DMISharp -Version 1.8.0
<PackageReference Include="DMISharp" Version="1.8.0" />
paket add DMISharp --version 1.8.0
#r "nuget: DMISharp, 1.8.0"
// Install DMISharp as a Cake Addin #addin nuget:?package=DMISharp&version=1.8.0 // Install DMISharp as a Cake Tool #tool nuget:?package=DMISharp&version=1.8.0
<h1 align="center"> <img src="./dmisharp.png" alt="DMISharp" width="256"/> <br/> DMISharp </h1>
DMISharp is a .NET 7.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 was computed. 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
- MetadataExtractor (>= 2.8.0)
- Microsoft.Toolkit.HighPerformance (>= 7.1.2)
- SixLabors.ImageSharp (>= 3.0.1)
-
net7.0
- MetadataExtractor (>= 2.8.0)
- Microsoft.Toolkit.HighPerformance (>= 7.1.2)
- SixLabors.ImageSharp (>= 3.0.1)
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 | 122 | 7/22/2024 |
2.0.2 | 289 | 7/8/2023 |
2.0.2-alpha.1 | 80 | 7/7/2023 |
2.0.1 | 156 | 7/7/2023 |
2.0.0 | 173 | 7/7/2023 |
1.7.0 | 74,009 | 3/13/2022 |
1.6.2 | 462 | 3/15/2021 |
1.6.1 | 371 | 3/10/2021 |
1.6.0 | 361 | 3/10/2021 |
1.5.1 | 374 | 1/18/2021 |
1.5.0 | 386 | 11/27/2020 |
1.4.1 | 614 | 11/5/2019 |
1.4.0 | 530 | 10/9/2019 |
1.3.4 | 548 | 10/8/2019 |
1.3.3 | 542 | 10/4/2019 |
1.3.2 | 547 | 10/4/2019 |
1.3.1 | 536 | 10/4/2019 |
1.2.1 | 529 | 10/4/2019 |
1.1.2 | 621 | 6/29/2019 |
1.1.0 | 591 | 6/29/2019 |
1.0.2 | 569 | 6/29/2019 |
- Updated to .NET 7
- Updated ImageSharp to 3