ITT Rule IDL Version 7.0 User Manual Page 250

  • Download
  • Add to my manuals
  • Print
  • Page
    / 430
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 249
250 Chapter 9: Creating a File Reader
Example: TIFF File Reader iTool Developers Guide
Finally, we return the value 1 to indicate successful initialization.
IsA Method
FUNCTION example1_readtiff::Isa, strFilename
RETURN, QUERY_TIFF(strFilename)
END
Discussion
The IsA method for our TIFF file reader is simple: we use the IDL QUERY_TIFF
function to determine whether the specified file is a TIFF file, returning the
function’s return value.
GetData Method
FUNCTION example1_readtiff::GetData, oImageData
filename = self->GetFilename()
IF (QUERY_TIFF(filename, fInfo, IMAGE_INDEX=self._index) EQ 0) $
THEN RETURN, 0
IF (fInfo.has_palette) THEN BEGIN
image = READ_TIFF(filename, palRed, palGreen, palBlue, $
IMAGE_INDEX = self._index)
ENDIF ELSE BEGIN
image = READ_TIFF(filename, IMAGE_INDEX = self._index)
ENDELSE
; Store image data in Image Data object.
oImageData = OBJ_NEW('IDLitDataIDLImage', $
NAME = FILE_BASENAME(fileName))
result = oImageData->SetData(image, 'ImagePixels', /NO_COPY)
IF (result EQ 0) THEN $
RETURN, 0
; Store palette data in Image Data object.
IF (fInfo.has_palette) THEN $
result = oImageData->SetData( TRANSPOSE([[palRed], $
[palGreen], [palBlue]]), 'Palette')
IF fInfo.num_images GT 1 THEN $
self->IDLitIMessaging::StatusMessage, $
'Read channel ' + strtrim(self._index,2)
Page view 249
1 2 ... 245 246 247 248 249 250 251 252 253 254 255 ... 429 430

Comments to this Manuals

No comments