DMI Icon Info

by DarkCampainger
Retrieve extra information about a DMI file--directions, delays, movement, ect--with this handy DLL
ID:794107
 
This library is a wrapper around a DLL that parses the zTXt chunk of DMI files to gain access to additional information not otherwise available (currently).

It can access the following attributes:
  • version
  • width
  • height
  • dirs
  • frames
  • loop
  • rewind
  • movement
  • delay

Usage is simple, and a demo is included. If you find any DMI files that don't work, please let me know.

////////////////////////
// //
// DMI Icon Info //
// VERSION 1.1 //
// BY DARKCAMPAINGER //
// //
// REFERENCE //
// //
////////////////////////
//
// > Process a DMI icon
//
new/dmi_info(filename)
//
// > Arguments:
//
// - filename: name of DMI file to process
//
// > Returns:
//
// New /dmi_info object containing the icon's metadata if the
// operation was successful. If the operation fails, the
// 'version' will be equal to -1.
//
//
// > Access icon metadata
//
dmi_info.version // Text string of DMI file format version
dmi_info.width // Number holding width of each icon_state in pixels
dmi_info.height // Number holding height of each icon_state in pixels

dmi_info.states // Indexed list of /dmi_info/dmi_state objects
dmi_info.stateNames // Associative list in form of ("stateName" = /dmi_info/dmi_state object)
//
// > Access icon_state metadata
//
dmi_info.GetStateDirs(stateId)
dmi_info.GetStateFrames(stateId)
dmi_info.GetStateLoop(stateId)
dmi_info.GetStateRewind(stateId)
dmi_info.GetStateMovement(stateId)
//
// > Arguments:
//
// - stateId: text name, numeric index, or reference of state to access
//
// > Returns:
//
// If state exists, returns associated property in numeric form.
// Returns null if the state cannot be found.
//
// > Access icon_state frame metadata
//
dmi_info.GetStateDelay(stateId, [frame])
//
// > Arguments:
//
// - stateId: text name or numeric index of state to access
// - [frame]: frame number to retrieve delay for (optional)
//
// > Returns:
//
// If no frame is specified, returns a list of all of the delays for the state
// If a frame is specified, returns the numeric delay for that frame
// Returns null if the state cannot be found.
// Returns null if the frame was specified and is out of bounds.
//
//
// > Filter/Search icon_states
//
dmi_info.SearchStates(query)
//
// > Arguments:
//
// - query: parameter string of "attribute=value" pairs
//
// > Returns:
//
// List of /dmi_info/dmi_state objects with attributes that match all
// of the given parameters.
//


Update History:

Version 1.1 (June 3rd, 2012)

Added SearchStates() process to /dmi_info object to find states matching specific attributes

The GetState[x]() accessors now accept a reference to the /dmi_info/dmi_state object itself

Two example DMI files added to the demo

Version 1.0 (June 3rd, 2012)

Initial release
Would you mind releasing the source for the DLL? I'd to take a look at it/make an SO.
In response to Murrawhip
Murrawhip wrote:
Would you mind releasing the source for the DLL? I'd to take a look at it/make an SO.

Once I clean it up and add some actual error handling, I'll think about uploading the source. Even then, it won't be pretty.

Regardless, I guess others might find it useful if they want to write their own DMI processors/writers, but don't know where to start.
In response to DarkCampainger
DarkCampainger wrote:
Regardless, I guess others might find it useful if they want to write their own DMI processors/writers, but don't know where to start.

That's pretty well what I want it for - I managed to get the zTxt chunks, but gave up before deflating it because my code was convoluted to all hell.
I figured it'd be nice to see how someone else managed it.
In response to Murrawhip
I use libpng / zlib to read the files. It's a bit overkill just for reading the zTXt chunk, but I already had most of the code from my lighting generator and I was in a hurry.
I still think it would be nice to have a GIMP plugin that can properly import and export DMI files, so that you could do editing there instead, without having to use Dream Maker as a go-between.
That happens to have approximately zero to do with this particular library, I'm afraid, which is all about programmatic access to DMI information in DM.