ITT Rule IDL Version 7.0 User Manual Page 268

  • Download
  • Add to my manuals
  • Print
  • Page
    / 430
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 267
268 Chapter 10: Creating a File Writer
Creating a New File Writer iTool Developers Guide
TITLE = 'Error', SEVERITY = 2
RETURN, 0 ; failure
ENDIF
; Get number of dimensions of image array.
ndim = SIZE(image, /N_DIMENSIONS)
; Write to a PPM file. Use REVERSE to make image appear
; with correct orientation.
WRITE_PPM, strFilename, REVERSE(image, ndim)
; Return 1 for success.
RETURN, 1
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 data of
an appropriate iTool data type from the data object; in this example, the method tries
to extract an data of one of the following types using the GetByType method of the
IDLitData class:
•IDLIMAGE
IDLIMAGEPIXELS
IDLARRAY2D
If no data of any of these types is found, the method displays an error message and
exits.
Once the method has obtained an appropriate data object, it checks to determine
whether the data object is an IDLitDataIDLImage object; if so, it attempts to retrieve
the image pixels from the data object; otherwise it simply retrieves the data array.
The data retrieved by the GetData method is stored in the variable
image. The
method then checks the return value from the GetData method to determine whether
the returned value is valid.
Using the valid image data, the method determines the number of dimensions and
then uses the WRITE_PPM 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.
Page view 267
1 2 ... 263 264 265 266 267 268 269 270 271 272 273 ... 429 430

Comments to this Manuals

No comments