#FEATURE by cg
authorClaus Gittinger <cg@exept.de>
Tue, 29 Aug 2017 23:16:18 +0200
changeset 17640 06a397102b23
parent 17639 caf3bfd0821a
child 17641 4211d4bb9e73
#FEATURE by cg class: FileApplicationNoteBook::ImageViewApplication changed: #image autoload readers.
FileApplicationNoteBook.st
--- a/FileApplicationNoteBook.st	Tue Aug 29 12:37:53 2017 +0200
+++ b/FileApplicationNoteBook.st	Tue Aug 29 23:16:18 2017 +0200
@@ -4272,16 +4272,41 @@
 !
 
 image
-    |img fn e|
+    |img fn e firstTry|
 
     fn := self fileName.
+    firstTry := true.
     Image badImageFormatQuerySignal handle:[:ex |
+        |reader|
+        
+        firstTry ifTrue:[
+            firstTry := false.
+            
+            "/ autoload image readers and retry
+            (fn suffix = 'pcx') ifTrue:[
+                reader := PCXReader.
+            ].    
+            (#('ppm' 'pgm' 'pbm' ) includes:fn suffix) ifTrue:[
+                reader := PBMReader.
+            ].    
+            (fn suffix = 'tga') ifTrue:[
+                reader := TargaReader.
+            ].    
+            (fn suffix = 'bmp') ifTrue:[
+                reader := WindowsIconReader.
+            ]. 
+            reader notNil ifTrue:[
+                reader autoload. ex restart.
+            ]    
+        ].
+        
         e := ex description.
         Dialog warn:('Error while reading image:\n\n%s' printfWith:e).
         "/ ex mayProceed ifTrue:[ ex proceed ].
     ] do:[
         img := Image fromFile:fn.
     ].
+    
     img isNil ifTrue:[
         e isNil ifTrue:[
             fn exists ifTrue:[
@@ -4298,7 +4323,7 @@
     ].
     ^ img.
 
-    "Modified: / 26-08-2017 / 10:37:21 / cg"
+    "Modified: / 29-08-2017 / 22:42:35 / cg"
 !
 
 showHex