
Chapter 10: Creating a File Writer 275
iTool Developer’s Guide Example: TIFF File Writer
RETURN, 1 ; success
END
Discussion
The SetData method accepts an IDLitData object (oImageData) as its input
parameter. Before processing the input data, the method prompts the user for a file in
which to save the image, using the GetFilename method of the IDLitWriter object.
After securing a filename, the method proceeds to check the input data object. First it
checks to make sure that the input object is valid. Then it attempts to retrieve a data
object of the iTool data type
IDLIMAGEPIXELS from the data object, using the
GetByType method. If this fails, it attempts to retrieve a data object of the iTool data
type
IDLARRAY2D from the data object, again using the GetByType method. If this
second attempt fails, we exit, returning 0.
Next, we use the GetData method to retrieve the image data from the data object. The
method then checks the return value from the GetData method to determine whether
the returned value is valid, and exits if it is not.
The method next attempts to retrieve a object of the data type IDLPALETTE from
the input object. If a palette is retrieved, the palette data is reformed to suit the needs
of the WRITE_TIFF procedure.
Finally, the method uses the WRITE_TIFF procedure to create an image file. The
image data must be processed by the REVERSE function in order to make it appear
in the output file with the correct orientation.