DataTypes Tutorial

DataTypes is the AmigaOS OO system for transparently loading, displaying, and converting data formats. Built on BOOPSI, it lets your app handle pictures, sounds, text, and animation without knowing the specific file format.

What DataTypes gives you

  • Automatic format detection — determine a file's type from its contents (signature bytes, IFF type), not just the extension.
  • Transparent multi-format support — a paint program can load ILBM, GIF, JPEG, BMP, or any picture format as long as a DataType class library exists for it in DEVS:DataTypes/.
  • Embeddable viewers — embed a picture viewer, text browser, or AmigaGuide document in your window with a few function calls.
  • Format conversion — read an ILBM, write a JPEG (both are PICTURE subclasses).
  • Clipboard support — copy/paste via standard DataType methods.
  • Consistent interface — same API for pictures, text, sound, and animation.

Class hierarchy

DATATYPESCLASS (root)
├── PICTUREDTCLASS  — images (ILBM, JPEG, GIF, BMP, PNG, ...)
├── SOUNDDTCLASS    — audio (8SVX, AIFF, WAV, ...)
├── TEXTDTCLASS     — text (ASCII, formatted text)
├── ANIMATIONDTCLASS — animation (ANIM, SMUS)
└── AMIGAGUIDEDTCLASS — AmigaGuide documents

Each leaf class is a shared library in DEVS:DataTypes/. The system auto-detects format and loads the appropriate class.

Basic usage

/* Load a file as a DataType object */
APTR dtObj = NewDTObjectA("image.ilbm", NULL);
if (!dtObj) { /* IoErr() for error */ }

/* Get info about the data */
struct DTSHeader *header;
GetDTAttrsA(dtObj, DTA_DataType, &header, TAG_DONE);
/* header->dth_Name = "ILBM picture", dth_GroupID = GID_PICTURE, etc. */

/* Embed in a window (it's a BOOPSI gadget) */
AddDTObject(win, NULL, dtObj, -1);

/* Invoke a trigger method (e.g., play sound, rewind animation) */
struct dtTrigger dtt = { NULL, STM_REWIND, NULL };
DoDTMethodA(dtObj, win, NULL, DTM_TRIGGER, &dtt);

/* Print */
PrintDTObjectA(dtObj, win, NULL, NULL);

/* Cleanup */
RemoveDTObject(win, dtObj, -1);
DisposeDTObject(dtObj);

Writing a DataType sub-class

  1. Create a shared library under DEVS:DataTypes/.
  2. Subclass PICTUREDTCLASS, SOUNDDTCLASS, TEXTDTCLASS, etc.
  3. Implement key methods:
  4. OM_NEW — load and parse the file.
  5. DTM_FRAMEBOX — report layout dimensions.
  6. GM_RENDER — draw the data.
  7. DTM_PRINT — printing support.
  8. DTM_WRITE — save/convert (enables format conversion).
  9. Register a DataType descriptor (signature, group ID, etc.) so the system recognizes your format.

Asynchronous operations

Important: time-intensive operations (layout, printing, file I/O) are off-loaded to a sub-process — they're asynchronous. Your main task continues; you receive notification via IDCMP when the operation completes.

See Also


Sources: David N. Junod / Commodore-Amiga, Inc., "DataTypes" tutorial (1992-1993). Raw: raw/tutorials/locale-datatypes-bullet.md Updated: 2026-08-04