Image.st
changeset 1433 f243ebc8d043
parent 1403 4b132381579e
child 1446 3007549e3d5e
--- a/Image.st	Thu Mar 06 15:17:58 1997 +0100
+++ b/Image.st	Thu Mar 06 15:26:08 1997 +0100
@@ -608,6 +608,27 @@
     "Modified: 25.1.1997 / 12:27:35 / cg"
 !
 
+extent:ext depth:d palette:aColormap
+    "create & return a blank image of the given size.
+     ST-80 compatibility"
+
+    |newImage emptyBits|
+
+    newImage := (self implementorForDepth:d) new.
+    newImage width:ext x height:ext y depth:d palette:aColormap.
+    emptyBits := ByteArray new:(newImage bytesPerRow * ext y).
+    newImage bits:emptyBits.
+    ^ newImage
+
+    "
+     Image extent:16@16 depth:8 palette:nil
+     Image extent:16@16 depth:4 palette:nil
+     Image extent:16@16 depth:2 palette:nil
+    "
+
+    "Created: 6.3.1997 / 15:24:01 / cg"
+!
+
 extent:ext depth:d palette:aColormap bits:bits
     "ST-80 compatibility"
 
@@ -1551,6 +1572,14 @@
     "Created: 10.2.1997 / 12:44:46 / cg"
 !
 
+containsPoint:aPoint
+    "in st-80, images are visualComponents ..."
+
+    ^ self bounds containsPoint:aPoint
+
+    "Created: 6.3.1997 / 15:24:12 / cg"
+!
+
 convertToPalette:aColormap renderedBy:anImageRenderer
     "this does not really mimicri the corresponding ST-80 functionality"
 
@@ -1582,6 +1611,16 @@
     "Modified: 1.3.1997 / 17:25:50 / cg"
 !
 
+paintBasis
+    "huh - whats that;
+     I guess, I have to return Color for images without a mask,
+     and CoverageValue for those with a mask; for now, always return Color"
+
+    ^ ColorValue
+
+    "Created: 6.3.1997 / 15:24:19 / cg"
+!
+
 preferredBounds
     ^ self bounds
 
@@ -1629,6 +1668,9 @@
 
     colorMap := aColorMap.
     colorMap notNil ifTrue:[
+        (aColorMap isKindOf:Colormap) ifFalse:[
+            colorMap := Colormap fromColors:aColorMap
+        ].
         photometric := #palette.
     ] ifFalse:[
         (photometric == #palette) ifTrue:[
@@ -1640,7 +1682,7 @@
     ]
 
     "Modified: 31.8.1995 / 03:05:59 / claus"
-    "Modified: 15.6.1996 / 09:32:09 / cg"
+    "Modified: 6.3.1997 / 15:24:48 / cg"
 !
 
 container:aVisualContainer
@@ -1800,6 +1842,14 @@
     ^ self valueAtX:aPoint x y:aPoint y
 !
 
+atPoint:aPoint put:aPixelValue
+    "ST-80 compatibility: set the pixelValue at:aPoint."
+
+    ^ self atX:aPoint x y:aPoint y putValue:aPixelValue
+
+    "Created: 6.3.1997 / 15:24:14 / cg"
+!
+
 atX:x y:y
     "retrieve a pixel at x/y; return a color.
      Pixels start at 0@0 for upper left pixel, end at
@@ -1900,6 +1950,22 @@
     bytes := aByteArray
 !
 
+rowAt:rowIndex putAll:pixelArray
+    "replace a single rows bits from bits in the argument;
+     Notice: row indexing starts at 0.
+     This is a slow fallBack method, which works with any depth;
+     concrete image subclasses should redefine this for more performance."
+
+    |bytesPerRow x|
+
+    0 to:(width-1) do:[:col |
+        self atX:col y:rowIndex putValue:(pixelArray at:(col + 1))
+    ].
+    ^ pixelArray
+
+    "Created: 6.3.1997 / 15:24:09 / cg"
+!
+
 valueAt:aPoint
     "retrieve the pixelValue at aPoint; return an integer number.
      Pixels start at 0@0 for upper left pixel, end at
@@ -2095,6 +2161,25 @@
     "Modified: 23.4.1996 / 11:08:59 / cg"
 !
 
+width:w height:h depth:d palette:aColormap
+    "set the width, height and depth of the image.
+
+     This interface is only to be used when initializing
+     instances or by image readers. Calling for a change of an
+     existing image may confuse later pixel interpretation."
+
+    width := w.
+    height := h.
+    self depth:d.
+    colorMap := aColormap.
+    aColormap notNil ifTrue:[
+        photometric := #palette
+    ]
+
+    "Modified: 23.4.1996 / 11:08:56 / cg"
+    "Created: 6.3.1997 / 15:23:57 / cg"
+!
+
 width:w height:h photometric:p samplesPerPixel:spp bitsPerSample:bps colorMap:cm bits:pixels
     "set all relevant internal state of the image.
 
@@ -8417,6 +8502,17 @@
     ^ true
 !
 
+pixelArraySpecies
+    "return the kind of pixel-value container in rowAt:/rowAt:put: methods"
+
+    depth > 8 ifTrue:[
+        ^ Array
+    ].
+    ^ ByteArray
+
+    "Created: 6.3.1997 / 15:24:05 / cg"
+!
+
 realColorMap
     "return a collection usable as a real colormap of the image.
      For palette images, this is the internal colormap; 
@@ -9064,6 +9160,6 @@
 !Image class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Image.st,v 1.151 1997-03-01 16:27:28 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Image.st,v 1.152 1997-03-06 14:26:08 cg Exp $'
 ! !
 Image initialize!