MacOSXIconReader.st
changeset 3868 d60663c87c61
parent 3580 2bf7c5d62cf6
child 3908 366f0a76e9e3
equal deleted inserted replaced
3867:9b2f1d48773a 3868:d60663c87c61
   167 !
   167 !
   168 
   168 
   169 readSingleIcon:iconType from:iconBytes
   169 readSingleIcon:iconType from:iconBytes
   170     "read a single image from the inputStream."
   170     "read a single image from the inputStream."
   171 
   171 
   172     |img|
   172     ^ Error handle:[:ex |
   173 
       
   174     Error handle:[:ex |
       
   175         self fileFormatError:'internal error / unhandled icon format: ',iconType.
   173         self fileFormatError:'internal error / unhandled icon format: ',iconType.
       
   174         nil
   176     ] do:[
   175     ] do:[
   177         img := self 
   176         self 
   178             perform:('read_',(iconType copyReplaceAny:#( $# $ ) with:$_),'_from:') asSymbol 
   177             perform:('read_',(iconType copyReplaceAny:#( $# $ ) with:$_),'_from:') asSymbol 
   179             with:iconBytes
   178             with:iconBytes
   180             ifNotUnderstood:[
   179             ifNotUnderstood:[
   181                 self breakPoint:#cg.
   180                 self breakPoint:#cg.
   182                 ('MacOSXIconReader: unsupported icon format: ',iconType) infoPrintCR.
   181                 ('MacOSXIconReader: unsupported icon format: ',iconType) infoPrintCR.
   183                 self fileFormatError:'unsupported icon format: ',iconType.
   182                 self fileFormatError:'unsupported icon format: ',iconType.
   184                 nil
   183                 nil
   185             ].
   184             ].
   186     ].
   185     ].
   187     ^ img.
       
   188 
   186 
   189     "
   187     "
   190      self fromFile:'/Applications/TextEdit.app/Contents/Resources/txt.icns'
   188      self fromFile:'/Applications/TextEdit.app/Contents/Resources/txt.icns'
   191      self fromFile:'test.icns'
   189      self fromFile:'test.icns'
   192     "
   190     "
       
   191 
       
   192     "Modified: / 08-02-2017 / 19:08:05 / stefan"
   193 ! !
   193 ! !
   194 
   194 
   195 !MacOSXIconReader methodsFor:'image writing'!
   195 !MacOSXIconReader methodsFor:'image writing'!
   196 
   196 
   197 save:anImage onStream:aStream
   197 save:anImage onStream:aStream