When the first Amiga came out in 1985 there were very few file formats available and very few standard formats (GIF didn't appear until 1987 and JPEG until 1992). So Commodore and Electronics Arts developed the IFF (Interchangable File Format) which covered pictures (ILBM), sound (8SVX) and text (FTXT) and others. When the AGA Amigas appeared around 1992 then more file formats appeared for all sorts of files, it was advantageous for the Amiga to be able to read and write such formats, so a new shared library appeared in AmigaOS 3.0 for programs to read and write different file formats without having to re-write the wheel each time when new file formats appear, this is the Datatype library which can decode file formats easily using different classes which can be installed as they are needed.
To use datatypes, you need to open the datatypes library along with the other libraries in your program:
DataTypesBase = OpenLibrary ("datatypes.library", 39)
To create a Datatype Object, use the NewDTObject function as below:
Function:
Object o = NewDTObject(APTR name, Tag1[, tag2, tag3, ... ] )
Object o = NewDTObjectA(APTR name, struct TagItem *attrs)
void DisposeDTObject(Object *o)
Example:
gd->gd_DisplayObject = NewDTObject ((APTR)gd->gd_Unit,
DTA_SourceType, DTST_CLIPBOARD,
GA_Immediate, TRUE,
GA_RelVerify, TRUE,
DTA_TextAttr, (ULONG) & gd->gd_TextAttr,
TAG_DONE))
The parameters of this functions uses Tags as defined in datatypes/datatypesclasses.h
and intuition/gadgetclass.h
gf->gd_Unit = the Clipboard unit number
DTST_Clipboard = the Clipboard is the data source
GA_Immediate = Should the object be active when displayed
GA_RelVerify = Verify that the pointer is over the object when it is selected
gd_->gd_TextAttr = Pointer to text font attributes
Once a datatype object is no longer required, it is disposed of and memory
released:
e.g.
DisposeDTObject (gd->gd_DisplayObject);
To get attributes from a datatype object, you can use the the GetDTAttrs
function
e.g.
GetDTAttrs (gd->gd_DisplayObject, DTA_DataType, (ULONG)&dtn, TAG_DONE);
and examing the results from the dtn structure you can retreive:
dtn->dtn_Header->dth_Name = Descriptive name of the datatype
dtn->dtn_Header->dth_GroupID = The group the datatype belongs to
The function GetDTString returns a localised Datatypes string of the
id given. This string could be syst, text, docu,
soun, inst, musi, pict, anim or movi (see datatypes.h).
e.g.
GetDTString (dtn->dtn_Header->dth_GroupID)