ITT Rule IDL Version 7.0 Manual de usuario Pagina 267

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 430
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 266
Chapter 10: Creating a File Writer 267
iTool Developer’s Guide Creating a New File Writer
Example SetData Method
FUNCTION ExampleWriter::SetData, oImageData
; Prompt user for a file in which to save the data
strFilename = self->GetFilename()
IF (strFilename EQ '') THEN $
RETURN, 0 ; failure
; Check validity of the input data object
IF (~ OBJ_VALID(oImageData)) THEN BEGIN
self->ErrorMessage, ['Invalid image data object'], $
TITLE = 'Error', SEVERITY = 2
RETURN, 0 ; failure
ENDIF
; Check the iTool data type of the selected data object.
; If the data is not of a type that can be written to an
; image file, display an error message.
oData = oImageData->GetByType("IDLIMAGE", COUNT = count)
IF (count EQ 0) THEN $ ; no image, image pixels?
oData = oImageData->GetByType("IDLIMAGEPIXELS", $
COUNT = count)
IF (count EQ 0) THEN $ ; no image, array 2d?
oData = oImageData->GetByType("IDLARRAY2D", COUNT = count)
IF (count EQ 0) THEN BEGIN
self->ErrorMessage, $
["Invalid data provided to file writer."], $
TITLE="Error", SEVERITY = 2
RETURN, 0 ; failure
END
; Turn a 1-D object array into a scalar object.
oData = oData[0]
; Determine whether the data is an image.
isImage = OBJ_ISA(oData, "IDLitDataIDLImage")
; If data is an image, get image pixels, otherwise
; turn data into an image.
IF (isImage NE 0) THEN BEGIN
result = oData->GetData(image, 'ImagePixels')
ENDIF ELSE BEGIN
result = oData->GetData(image)
ENDELSE
; Check the result of the GetData method.
IF (result EQ 0) THEN BEGIN
self->ErrorMessage, ['Error retrieving image data'], $
Vista de pagina 266
1 2 ... 262 263 264 265 266 267 268 269 270 271 272 ... 429 430

Comentarios a estos manuales

Sin comentarios