Saving indexed palette 8Bit images with Datatypes...

Online Status

Hello, some times ago I tried to read an image file from memory with datatypes, now I'm trying to write 8bit images with datatypes. And I can't make it work at all. I have been trying to change params for hours. Either NewDTObject return NULL or DoMethod does nothing. I test on OS3.2.3. I can't find an example for this anywhere (DevCD2.1, NDK3.2). I don't know if it correct to use DTST_FILE if the file doesnt exists, if I need to set PMODE_V42 or PMODE_V43. In the best case, i need to have the choice of the image format (iff, gif, png,...)

  // Create a new Datatype object for output
    dto = NewDTObject(fileToWritename,
	DTA_SourceType,DTST_FILE,
	DTA_GroupID,GID_PICTURE,
	// DTA_SourceType, DTST_FILE,
	// PDTA_SourceMode, PMODE_V42,
	PDTA_DestMode, PMODE_V42,
	PDTA_ColorRegisters,(ULONG)&colors[0],
	PDTA_NumColors,16,
	TAG_DONE);

    if (!dto) {
        ...
        return PETSCII_EXPORT_ENOMEM; // Failed to create Datatype object
    }

    // Prepare the pixel array write operation
    bpa.MethodID = PDTM_WRITEPIXELARRAY;
    bpa.pbpa_PixelData = (APTR)pixels;
    bpa.pbpa_PixelFormat = PBPAFMT_LUT8; // (depth == 32) ? PBPAFMT_RGBA : PBPAFMT_RGB;
    bpa.pbpa_PixelArrayMod =width; //  width * depth / 8;
    bpa.pbpa_Left = 0;
    bpa.pbpa_Top = 0;
    bpa.pbpa_Width = width;
    bpa.pbpa_Height = height;

    // Perform the write operation
    result = DoMethod(dto, (Msg)&bpa);

Online Status

Is saving images with datatype even a thing ? The OS3.2.3 multiview can save, I always imaged it uses datatype for this.