All this makes me think about a more general datatypes-related problem.
Let's suppose I write a FLAC Datatype (ie. a subclass of the Sound Datatype) in which I also implement the DTM_WRITE method. As FLAC encoding is a CPU-intensive task, performing the method will naturally take some time (in fact, several minutes on a Sam440). Is the datatypes system ready/designed for this? Will the user be informed about the progress of the task somehow, or will the datatype keep doing work silently, leaving the user puzzled about what's happening?
nothing stops the Flac datatype from putting up an (optional) progress requester.
Considering the fact that things like the actual text rendering (in the case of Text Datatype subclasses) or sound playback (in the case of Sound Datatype subclasses) are done at the superclass level, I'd recommend implementing the progress requester at the superclass level as well - for the sake of user interface consistency. If different datatypes implement each their own way of indicating progress (some will use Gadtools, some ReAction...), we end up in an unpredictable system that will only confuse the user.
You will see from that thread that I have identified quite a number of problems that go beyond merely supporting DTM_WRITE: 1. You can't DTM_WRITE to an in-memory location 2. There is no way of identifying if a DataType supports DTM_WRITE without trying it 3. If you want to convert between formats you have to create a blank DataType object in memory (DTST_RAM) using the destination subclass (a lot of DataTypes don't support this either). 4. The DTA_BaseName tag of NewDTObject doesn't work (this is a datatypes.library bug, unless I'm doing something wrong)
A DataType subclass needs to support creation of a new blank DataType object in memory (DTST_RAM) and DTM_WRITE in order to be able to convert from one format to another. The calling application also needs to know that DTM_WRITE is supported (which there isn't any way of doing AFAIK), otherwise you end up with unexpected IFF data where it has been passed to the superclass.
kas1e wrote: If we assume that we have savers in datatypes, how can i load let's say png file, and save it in bmp file ?
It's in the thread link I posted in my previous post, but basically you have to open the PNG as normal, create a blank BMP DTObject and copy all the data over, then save the BMP. There's no "quick" way of doing it (but normally you'd be poking in-application data in, rather than directly converting from another DTObject, so it's not really a problem)
btw, my WebP DataType has DTM_WRITE support if anybody needs one for testing (it's the only picture datatype I know of that has DTM_WRITE support that actually works).
I don't know if there is still any problems with NewDTObject() and DTA_BaseName but I just made it possible to create empty objects with DTST_RAM using following datatype classes: ilbm.datatype png.datatype bmp.datatype jpeg.datatype
This was not possible before.
The code I used to test uses destdtn = ObtainDataTypeA(DTST_RAM, basename, NULL); and DTA_DataType tag so it's a bit different from your code.
If you send me some code using your method I can test and ensure that it also works correctly.