XPMReader.st
changeset 107 7e7debba3a26
parent 99 a656b0c9dd21
child 114 e577a2f332d0
--- a/XPMReader.st	Mon Oct 23 18:00:19 1995 +0100
+++ b/XPMReader.st	Wed Oct 25 11:16:32 1995 +0100
@@ -37,7 +37,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libview2/XPMReader.st,v 1.9 1995-08-30 17:54:40 claus Exp $
+$Header: /cvs/stx/stx/libview2/XPMReader.st,v 1.10 1995-10-25 10:16:29 cg Exp $
 "
 !
 
@@ -55,6 +55,9 @@
 
 	Does not (currently) handle none-colors (i.e. for image-masks).
 
+	Only understands single-word color names (i.e. names with spaces 
+	are not supported)
+
 	Save not supported
 
     Suggestions: adapt & use the XPM library here.
@@ -130,7 +133,7 @@
     ].
 
     line := aStream nextLine.
-    [line notNil and:[line startsWith:'/*']] whileTrue:[
+    [line notNil and:[(line startsWith:'/*') or:[line isBlank]]] whileTrue:[
 	line := aStream nextLine.
     ].
     (line notNil and:[line startsWith:'static char']) ifFalse:[
@@ -138,8 +141,11 @@
 	^ nil
     ].
     line := aStream nextLine.
-    [line notNil and:[line startsWith:'/*']] whileTrue:[
-	line := aStream nextLine.
+    (line notNil and:[line startsWith:'/*']) ifTrue:[
+	[line notNil 
+	 and:[(line startsWith:'/*') or:[line startsWith:' *']]] whileTrue:[
+	    line := aStream nextLine.
+	].
     ].
     (line notNil and:[line startsWith:'"']) ifFalse:[
 	'XPM: format error (expected "ww hh nn mm)' errorPrintNL.
@@ -157,13 +163,13 @@
     ].
     xlation := Array new:256.
 
-    redMap := Array new:colorMapSize.
-    greenMap := Array new:colorMapSize.
-    blueMap := Array new:colorMapSize.
+    redMap := ByteArray new:colorMapSize.
+    greenMap := ByteArray new:colorMapSize.
+    blueMap := ByteArray new:colorMapSize.
     colorMap := Colormap redVector:redMap greenVector:greenMap blueVector:blueMap.
 
     1 to:colorMapSize do:[:colorIndex |
-	|index line color|
+	|index line color t|
 
 	line := aStream nextLine.
 	[line notNil and:[line startsWith:'/*']] whileTrue:[
@@ -240,9 +246,9 @@
 	] ifFalse:[
 	    color := Color name:colorName.
 	].
-	redMap at:colorIndex put:(color red * 255 // 100).
-	greenMap at:colorIndex put:(color green * 255 // 100).
-	blueMap at:colorIndex put:(color blue * 255 // 100).
+	redMap at:colorIndex put:(color red asFloat * 255.0 // 100).
+	greenMap at:colorIndex put:(color green asFloat * 255.0 // 100).
+	blueMap at:colorIndex put:(color blue asFloat * 255.0 // 100).
     ].
 
     "actually, could make it an image with less depth most of the time ..."
@@ -283,7 +289,10 @@
      XPMReader fromStream:('bitmaps/magtape.xpm' asFilename readStream)
      XPMReader fromStream:('bitmaps/pixmap.xpm' asFilename readStream) 
      XPMReader fromStream:('bitmaps/SBrowser.xbm' asFilename readStream)
-    " 
+    "
+
+    "Created: 24.9.1995 / 06:20:06 / claus"
+    "Modified: 24.9.1995 / 07:07:33 / claus"
 ! !
 
 XPMReader initialize!