dmi_read 0.1.0

DMI Read #

A Dart library for reading .dmi spritesheet files used by the BYOND platform.

This library does not depend on dart:io, and thus can be used both in browser and the VM.

Current version has been tested against dmis generated by BYOND version 510.1347.

Background #

BYOND is a proprietary game engine and platform, allowing creation of 2D tile-based multiplayer games through its Dream Maker component.

In BYOND game sources, sprites are kept in .dmi files. .dmi files are sprite sheets in a PNG file with a zTXt chunk containing metadata which describes the frames in the sprite sheet. An image viewer or editor will generally be able to open the whole sprite sheet, however, figuring out where the individual sprites are, and how they are grouped requires parsing the attached .dmi metadata.

Example #

Print the names of every state in foo.dmi:

DmiSheet sheet = new DmiSheet.fromBytes(
    await new File('foo.dmi').readAsBytes());
sheet.states.forEach((state) {

For a slightly longer example, see dmi_read_example.dart.

Project #

dmi_read is free software licensed under the ISC license. See the LICENSE file for details.

Bug reports and pull requests can be filed at

Changelog #

0.1.0 #

Initial release.


import 'dart:io';

import 'package:dmi_read/dmi_read.dart';
import 'package:image/image.dart';

main() async {
  var fileBytes = await new File('test/samples/anim.dmi').readAsBytes();

  DmiSheet sheet;

  try {
    sheet = new DmiSheet.fromBytes(fileBytes);
  } on DmiParseError catch (e) {
    // Problems with loading the DMI file will result in `DmiParseError` or its
    // subclasses getting thrown
    print('Something went wrong with loading. ' + e.toString());

  // Print some information about the whole sheet
  print('Icon size: ${sheet.iconWidth} × ${sheet.iconHeight}');

  // Go through all the states in this dmi sheet and print some metadata
  for (var state in sheet.states) {
    // PixmapState and MovieState are the two possible things a state can be
    if (state is PixmapState) {
      print('• ${}, pixmap');
    } else if (state is MovieState) {
          '• ${}, movie, ${state.framesCount} frames in ${state.directionsCount} directions');

  // Save an image from the sheet
  MovieState state =
      sheet.getStateNamed('anim'); // 'anim' is the name of the state set in DM
  DmiIcon icon =
      state.icons[IconDirection.north][0]; // first icon in the north direction

  // We use the `image` library's `encodePng` to save the icon as PNG
  var outFile =
      await new File('first-frame.png').writeAsBytes(encodePng(icon.image));

  // We can also find the icon's hotspot
  print('Wrote icon with hotspot ${icon.hotspot} to $outFile');

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  dmi_read: ^0.1.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:dmi_read/dmi_read.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.0 <2.0.0