MacOSXIconReader.st
changeset 4349 6767c83f1b0d
parent 4188 f9e164682d74
child 4377 a8225a850449
equal deleted inserted replaced
4348:6113e0a7959c 4349:6767c83f1b0d
   132      Assuming that we store in PNG format, delegate that decision."
   132      Assuming that we store in PNG format, delegate that decision."
   133 
   133 
   134     ^ PNGReader canRepresent:anImage
   134     ^ PNGReader canRepresent:anImage
   135 !
   135 !
   136 
   136 
       
   137 hasValidImageHeader:someHeaderBytes
       
   138     "return true, if someHeaderBytes 
       
   139      (which does not need to be the whole data, but large enough
       
   140       to detect the header) contains a valid TIFF image header"
       
   141 
       
   142     |id|
       
   143 
       
   144     id := (someHeaderBytes copyFrom:1 to:4) asString.
       
   145     ^ (id = 'icns')
       
   146 !
       
   147 
   137 isValidImageFile:aFileName
   148 isValidImageFile:aFileName
   138     "return true, if aFileName is an apple osx icon file"
   149     "return true, if aFileName is an apple osx icon file"
   139 
   150 
   140     |id inStream|
   151     |someBytes inStream|
   141 
   152 
   142     inStream := self streamReadingFile:aFileName.
   153     inStream := self streamReadingFile:aFileName.
   143     inStream isNil ifTrue:[^ false].
   154     inStream isNil ifTrue:[^ false].
   144 
   155     someBytes := inStream nextBytes:4.
   145     inStream text.
       
   146 
       
   147     id := String new:4.
       
   148     inStream nextBytes:4 into:id.
       
   149     inStream close.
   156     inStream close.
   150 
   157     ^ self hasValidImageHeader:someBytes
   151     ^ (id = 'icns')
       
   152 ! !
   158 ! !
   153 
   159 
   154 !MacOSXIconReader methodsFor:'image reading'!
   160 !MacOSXIconReader methodsFor:'image reading'!
   155 
   161 
   156 fromStream:aStream
   162 fromStream:aStream