padding info in supportedFormats
authorClaus Gittinger <cg@exept.de>
Wed, 22 Nov 1995 15:07:46 +0100
changeset 235 579f3f804a46
parent 234 71a3b9319c0f
child 236 441ee542da50
padding info in supportedFormats
Depth24Image.st
Depth8Image.st
DevWorkst.st
DeviceWorkstation.st
Image.st
XWorkstat.st
XWorkstation.st
--- a/Depth24Image.st	Tue Nov 21 15:02:20 1995 +0100
+++ b/Depth24Image.st	Wed Nov 22 15:07:46 1995 +0100
@@ -34,7 +34,7 @@
 !
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Depth24Image.st,v 1.16 1995-11-11 15:49:12 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Depth24Image.st,v 1.17 1995-11-22 14:06:29 cg Exp $'
 !
 
 documentation
@@ -928,7 +928,7 @@
     ] ifFalse:[
 	has8BitImage := false.
 	aDevice supportedImageFormats do:[:fmt |
-	    (fmt at:2) == 8 ifTrue:[
+	    (fmt at:#bitsPerPixel) == 8 ifTrue:[
 		has8BitImage := true.
 	    ]
 	]
--- a/Depth8Image.st	Tue Nov 21 15:02:20 1995 +0100
+++ b/Depth8Image.st	Wed Nov 22 15:07:46 1995 +0100
@@ -34,7 +34,7 @@
 !
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Depth8Image.st,v 1.31 1995-11-16 16:35:33 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Depth8Image.st,v 1.32 1995-11-22 14:06:39 cg Exp $'
 !
 
 documentation
@@ -715,7 +715,7 @@
     ] ifFalse:[
 	has8BitImage := false.
 	aDevice supportedImageFormats do:[:fmt |
-	    (fmt at:2) == 8 ifTrue:[
+	    (fmt at:#bitsPerPixel) == 8 ifTrue:[
 		has8BitImage := true.
 	    ]
 	]
@@ -1192,7 +1192,7 @@
     ] ifFalse:[
 	has8BitImage := false.
 	aDevice supportedImageFormats do:[:fmt |
-	    (fmt at:2) == 8 ifTrue:[
+	    (fmt at:#bitsPerPixel) == 8 ifTrue:[
 		has8BitImage := true.
 	    ]
 	]
--- a/DevWorkst.st	Tue Nov 21 15:02:20 1995 +0100
+++ b/DevWorkst.st	Wed Nov 22 15:07:46 1995 +0100
@@ -52,7 +52,7 @@
 !
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Attic/DevWorkst.st,v 1.49 1995-11-11 15:50:04 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Attic/DevWorkst.st,v 1.50 1995-11-22 14:06:53 cg Exp $'
 !
 
 documentation
@@ -1289,7 +1289,13 @@
      Here, we return a single format only; every graphics device must
      support b&w single bit images."
 
-    ^ #( 1 1)   "/ depth=1 bitsPerPixel=1
+    |info|
+
+    info := IdentityDictionary new.
+    info at:#depth put:1.
+    info at:#bitsPerPixel put:1.
+    info at:#padding put:32.
+    ^ Array with:info
 !
 
 isSlow
--- a/DeviceWorkstation.st	Tue Nov 21 15:02:20 1995 +0100
+++ b/DeviceWorkstation.st	Wed Nov 22 15:07:46 1995 +0100
@@ -52,7 +52,7 @@
 !
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.49 1995-11-11 15:50:04 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.50 1995-11-22 14:06:53 cg Exp $'
 !
 
 documentation
@@ -1289,7 +1289,13 @@
      Here, we return a single format only; every graphics device must
      support b&w single bit images."
 
-    ^ #( 1 1)   "/ depth=1 bitsPerPixel=1
+    |info|
+
+    info := IdentityDictionary new.
+    info at:#depth put:1.
+    info at:#bitsPerPixel put:1.
+    info at:#padding put:32.
+    ^ Array with:info
 !
 
 isSlow
--- a/Image.st	Tue Nov 21 15:02:20 1995 +0100
+++ b/Image.st	Wed Nov 22 15:07:46 1995 +0100
@@ -42,7 +42,7 @@
 !
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Image.st,v 1.46 1995-11-16 16:35:48 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Image.st,v 1.47 1995-11-22 14:07:11 cg Exp $'
 !
 
 documentation
@@ -1859,8 +1859,8 @@
      form|
 
     bestFormat := self bestSupportedImageFormatFor:aDevice.
-    usedDeviceDepth := bestFormat at:1.
-    usedDeviceBitsPerPixel := bestFormat at:2.
+    usedDeviceDepth := bestFormat at:#depth.
+    usedDeviceBitsPerPixel := bestFormat at:#bitsPerPixel.
 
     "/
     "/ only the trivial case, where the depths match
@@ -2029,8 +2029,8 @@
     ].
 
     bestFormat := self bestSupportedImageFormatFor:aDevice.
-    usedDeviceDepth := bestFormat at:1.
-    usedDeviceBitsPerPixel := bestFormat at:2.
+    usedDeviceDepth := bestFormat at:#depth.
+    usedDeviceBitsPerPixel := bestFormat at:#bitsPerPixel.
 
     "/ for now, only support some depths
 
@@ -2525,8 +2525,8 @@
     ].
 
     bestFormat := self bestSupportedImageFormatFor:aDevice.
-    usedDeviceDepth := bestFormat at:1.
-    usedDeviceBitsPerPixel := bestFormat at:2.
+    usedDeviceDepth := bestFormat at:#depth.
+    usedDeviceBitsPerPixel := bestFormat at:#bitsPerPixel.
 
     "/ for now, only support some depths
 
@@ -3078,9 +3078,9 @@
     "scan through the image formats as supported by aDevice,
      and return the best to use when the receiver is to be represented
      on it. The best format is the one with the same number or more bits per
-     pixel. Here, the smallest format found is taken."
-
-    |bestDeviceDepth bestDeviceBitsPerPixel myDepth maxDepth maxBitsPerPixel|
+     pixel. Here, the smallest format found which can represent enough pixels is taken."
+
+    |bestDeviceDepth bestDeviceBitsPerPixel bestInfo maxInfo myDepth maxDepth maxBitsPerPixel |
 
     myDepth := self bitsPerPixel.
     maxBitsPerPixel := 0.
@@ -3088,11 +3088,13 @@
     aDevice supportedImageFormats do:[:entry |
 	|deviceImageDepth deviceImageBitsPerPixel|
 
-	deviceImageDepth := entry at:1.
-	deviceImageBitsPerPixel := entry at:2.
+	deviceImageDepth := entry at:#depth.
+	deviceImageBitsPerPixel := entry at:#bitsPerPixel.
+
 	deviceImageBitsPerPixel > maxBitsPerPixel ifTrue:[
-	    maxBitsPerPixel := deviceImageBitsPerPixel.
-	    maxDepth := deviceImageDepth.
+	    maxInfo := entry.
+"/            maxBitsPerPixel := deviceImageBitsPerPixel.
+"/            maxDepth := deviceImageDepth.
 	].
 	deviceImageDepth >= myDepth ifTrue:[
 	    deviceImageDepth == myDepth ifTrue:[
@@ -3100,6 +3102,7 @@
 		(bestDeviceDepth isNil
 		 or:[(bestDeviceBitsPerPixel ~~ bestDeviceDepth)
 		    and:[deviceImageDepth == deviceImageBitsPerPixel]]) ifTrue:[
+		    bestInfo := entry.
 		    bestDeviceDepth := deviceImageDepth.
 		    bestDeviceBitsPerPixel := deviceImageBitsPerPixel.
 		]
@@ -3107,6 +3110,7 @@
 		"/ take the next-larger depth
 		(bestDeviceDepth isNil
 		 or:[deviceImageBitsPerPixel < bestDeviceBitsPerPixel]) ifTrue:[
+		    bestInfo := entry.
 		    bestDeviceDepth := deviceImageDepth.
 		    bestDeviceBitsPerPixel := deviceImageBitsPerPixel.
 		]
@@ -3115,15 +3119,20 @@
     ].
     bestDeviceDepth isNil ifTrue:[
 	maxBitsPerPixel == 0 ifTrue:[
+	    "/
+	    "/ oops - nothing appropriate
+	    "/
 	    bestDeviceDepth := bestDeviceBitsPerPixel := aDevice depth.
+	    bestInfo := IdentityDictionary new.
+	    bestInfo at:#depth put:bestDeviceDepth.
+	    bestInfo at:#bitsPerPixel put:bestDeviceDepth.
+	    bestInfo at:#padding put:32.
 	] ifFalse:[
-	    bestDeviceDepth := maxDepth.
-	    bestDeviceBitsPerPixel := maxBitsPerPixel
+	    bestInfo := maxInfo.
 	]
     ].
-    ^ Array with:bestDeviceDepth with:bestDeviceBitsPerPixel
-
-    "Created: 21.10.1995 / 02:17:48 / cg"
+    ^ bestInfo
+
     "Modified: 21.10.1995 / 03:52:45 / cg"
 ! !
 
--- a/XWorkstat.st	Tue Nov 21 15:02:20 1995 +0100
+++ b/XWorkstat.st	Wed Nov 22 15:07:46 1995 +0100
@@ -49,7 +49,7 @@
 !
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Attic/XWorkstat.st,v 1.76 1995-11-21 09:39:19 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Attic/XWorkstat.st,v 1.77 1995-11-22 14:07:46 cg Exp $'
 !
 
 documentation
@@ -1114,8 +1114,9 @@
 !
 
 supportedImageFormats
-    "return an array with supported image formats; each array entry
-     is another array, consisting of depth and bitsPerPixel values."
+    "return an array with supported image formats; 
+     each array entry is an attribute dictionary, consisting of 
+     depth, bitsPerPixel and padding values."
 
     |nFormats "{ Class: SmallInteger }"
      formatArray|
@@ -1129,7 +1130,7 @@
 %}.
     formatArray := Array new:nFormats.
     1 to:nFormats do:[:index |
-	|bitsPerPixelInfo depthInfo i|
+	|info bitsPerPixelInfo depthInfo paddingInfo i|
 
 	i := index.
 %{
@@ -1138,15 +1139,20 @@
 
 	format = DISPLAYACCESS(dpy)->pixmap_format;
 	format += (_intVal(i)-1);
-	bitsPerPixelInfo = _MKSMALLINT(format->bits_per_pixel);
-	depthInfo = _MKSMALLINT(format->depth);
+	bitsPerPixelInfo = __MKSMALLINT(format->bits_per_pixel);
+	depthInfo = __MKSMALLINT(format->depth);
+	paddingInfo = __MKSMALLINT(format->scanline_pad);
 %}.
-	formatArray at:index put:(Array with:depthInfo with:bitsPerPixelInfo).
+	info := IdentityDictionary new.
+	info at:#depth put:depthInfo.
+	info at:#bitsPerPixel put:bitsPerPixelInfo.
+	info at:#padding put:paddingInfo.
+	formatArray at:index put:info.
     ].
     ^ formatArray
 
     "
-     Display supportedImageFormats
+     Display supportedImageFormats 
     "
 !
 
--- a/XWorkstation.st	Tue Nov 21 15:02:20 1995 +0100
+++ b/XWorkstation.st	Wed Nov 22 15:07:46 1995 +0100
@@ -49,7 +49,7 @@
 !
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.76 1995-11-21 09:39:19 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.77 1995-11-22 14:07:46 cg Exp $'
 !
 
 documentation
@@ -1114,8 +1114,9 @@
 !
 
 supportedImageFormats
-    "return an array with supported image formats; each array entry
-     is another array, consisting of depth and bitsPerPixel values."
+    "return an array with supported image formats; 
+     each array entry is an attribute dictionary, consisting of 
+     depth, bitsPerPixel and padding values."
 
     |nFormats "{ Class: SmallInteger }"
      formatArray|
@@ -1129,7 +1130,7 @@
 %}.
     formatArray := Array new:nFormats.
     1 to:nFormats do:[:index |
-	|bitsPerPixelInfo depthInfo i|
+	|info bitsPerPixelInfo depthInfo paddingInfo i|
 
 	i := index.
 %{
@@ -1138,15 +1139,20 @@
 
 	format = DISPLAYACCESS(dpy)->pixmap_format;
 	format += (_intVal(i)-1);
-	bitsPerPixelInfo = _MKSMALLINT(format->bits_per_pixel);
-	depthInfo = _MKSMALLINT(format->depth);
+	bitsPerPixelInfo = __MKSMALLINT(format->bits_per_pixel);
+	depthInfo = __MKSMALLINT(format->depth);
+	paddingInfo = __MKSMALLINT(format->scanline_pad);
 %}.
-	formatArray at:index put:(Array with:depthInfo with:bitsPerPixelInfo).
+	info := IdentityDictionary new.
+	info at:#depth put:depthInfo.
+	info at:#bitsPerPixel put:bitsPerPixelInfo.
+	info at:#padding put:paddingInfo.
+	formatArray at:index put:info.
     ].
     ^ formatArray
 
     "
-     Display supportedImageFormats
+     Display supportedImageFormats 
     "
 !