WindowsIconReader.st
changeset 4003 256b43a46036
parent 3999 2e26f0d49ca9
child 4012 af495a29eafa
--- a/WindowsIconReader.st	Tue Aug 29 23:45:29 2017 +0200
+++ b/WindowsIconReader.st	Thu Aug 31 15:29:24 2017 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 1993 by Claus Gittinger
 	      All Rights Reserved
@@ -599,12 +601,37 @@
     "load bmp-4 bit per pixel imagedata."
 
     compression == 0 ifTrue:[
-	^ self loadUncompressedFrom:aStream into:aByteArray
+        ^ self loadUncompressedFrom:aStream into:aByteArray
     ].
     compression == 2 ifTrue:[
-	^ self loadRLECompressedBMP4From:aStream into:aByteArray
+        [
+            ^ self loadRLECompressedBMP4From:aStream into:aByteArray
+        ] on:Error do:[:ex |
+            self fileFormatError:'Error during RLE decompression: %1' with:ex description.
+            ^ false.
+        ]
     ].
 
+    self fileFormatError:'unsupported compression: %1' with:compression.
+    ^ false
+!
+
+loadBMP8From:aStream into:aByteArray
+    "load bmp-8 bit per pixel imagedata."
+
+    compression == 0 ifTrue:[
+        ^ self loadUncompressedFrom:aStream into:aByteArray.
+    ].
+    compression == 1 ifTrue:[
+        [
+            ^ self loadRLECompressedBMP8From:aStream into:aByteArray.
+        ] on:Error do:[:ex |
+            self fileFormatError:'error during RLE decompression: %1' with:ex description.
+            ^ false.
+        ]
+    ].
+
+    self fileFormatError:'unsupported compression: %1' with:compression.
     ^ false
 !
 
@@ -617,7 +644,7 @@
 
     ((compression == 0) or:[compression == 3]) ifFalse:[
         "/ 'BMPReader: unsupported compression: ' infoPrint. compression infoPrintCR. 
-        self fileFormatError:('unsupported compression:', compression printString).
+        self fileFormatError:'unsupported compression: %1' with:compression.
         ^ false.
     ].
 
@@ -661,15 +688,7 @@
     "helper: load a BMP image"
 
     d == 8 ifTrue:[
-        compression == 0 ifTrue:[
-            ^ self loadUncompressedFrom:aStream into:aByteArray.
-        ].
-        compression == 1 ifTrue:[
-            ^ self loadRLECompressedBMP8From:aStream into:aByteArray.
-        ].
-        "/ self breakPoint:#cg info:'unhandled compression'.
-        self fileFormatError:('unsupported compression:', compression printString).
-        ^ false
+        ^ self loadBMP8From:aStream into:aByteArray
     ].
     d == 4 ifTrue:[
         ^ self loadBMP4From:aStream into:aByteArray
@@ -687,7 +706,8 @@
         ].
         ^ true
     ].
-    self fileFormatError:('unsupported depth:', d printString).
+
+    self fileFormatError:'unsupported depth: %1' with:d.
     ^ false
 
     "Created: / 17-09-1995 / 18:48:11 / claus"