Image.st
changeset 8116 a91860abbaa5
parent 8115 6b4a08f7e951
child 8130 3f89522ad9fb
--- a/Image.st	Mon Aug 28 03:36:02 2017 +0200
+++ b/Image.st	Tue Aug 29 15:39:26 2017 +0200
@@ -3128,7 +3128,7 @@
 !Image methodsFor:'accessing-pixels'!
 
 at:aPoint
-    "WARNING: for now, this returns a pixels color
+    "WARNING: for now, this returns a pixel's color
      (backward compatibility with ST/X)
      In the future, this will return a pixel value (ST-80 compatibility)
      Use #colorAt: - for future compatibility.
@@ -3145,12 +3145,13 @@
     self obsoleteFeatureWarning:'Image [warning]: the Image>>at: will change semantics soon; use #colorAt:'.
     ^ self colorAtX:(aPoint x) y:(aPoint y)
 
-    "Modified: / 21.6.1997 / 13:10:17 / cg"
-    "Modified: / 9.1.1998 / 20:33:52 / stefan"
+    "Modified: / 21-06-1997 / 13:10:17 / cg"
+    "Modified: / 09-01-1998 / 20:33:52 / stefan"
+    "Modified (comment): / 29-08-2017 / 14:35:55 / cg"
 !
 
 at:aPoint put:aColor
-    "WARNING: for now, this expects a pixels color
+    "WARNING: for now, this expects a pixel's color
      (backward compatibility with ST/X)
      In the future, this will expect a pixel value (ST-80 compatibility)
      Use #colorAt:put: - for future compatibility.
@@ -3168,8 +3169,9 @@
     self obsoleteFeatureWarning:'Image [warning]: the Image>>at:put: will change semantics soon; use #colorAt:put:'.
     ^ self colorAtX:aPoint x y:aPoint y put:aColor.
 
-    "Modified: / 21.6.1997 / 13:16:02 / cg"
-    "Modified: / 9.1.1998 / 20:34:15 / stefan"
+    "Modified: / 21-06-1997 / 13:16:02 / cg"
+    "Modified: / 09-01-1998 / 20:34:15 / stefan"
+    "Modified (comment): / 29-08-2017 / 14:36:03 / cg"
 !
 
 atImageAndMask:aPoint put:aColorOrPixelOrNil
@@ -3238,7 +3240,7 @@
 
 atX:x y:y
     <resource: #obsolete>
-    "WARNING: for now, this returns a pixels color
+    "WARNING: for now, this returns a pixel's color
      (backward compatibility with ST/X)
      In the future, this will return a pixel value (ST-80 compatibility)
      Use #colorAt: - for future compatibility.
@@ -3253,11 +3255,12 @@
     self obsoleteFeatureWarning:'Image [warning]: the Image>>atX:y: will change semantics soon; use #colorAtX:y:'.
     ^ self colorAtX:x y:y
 
-    "Modified: 21.6.1997 / 13:10:32 / cg"
+    "Modified: / 21-06-1997 / 13:10:32 / cg"
+    "Modified (comment): / 29-08-2017 / 14:36:09 / cg"
 !
 
 atX:x y:y put:aColor
-    "WARNING: for now, this expects a pixels color
+    "WARNING: for now, this expects a pixel's color
      (backward compatibility with ST/X)
      In the future, this will expect a pixel value (ST-80 compatibility)
      Use #colorAt:put: - for future compatibility.
@@ -3276,7 +3279,8 @@
     self obsoleteFeatureWarning:'Image [warning]: the Image>>atX:y:put: will change semantics soon; use #colorAtX:y:put:'.
     ^ self colorAtX:x y:y put:aColor
 
-    "Modified: 21.6.1997 / 13:10:44 / cg"
+    "Modified: / 21-06-1997 / 13:10:44 / cg"
+    "Modified (comment): / 29-08-2017 / 14:36:15 / cg"
 !
 
 atX:x y:y putValue:aPixelValue
@@ -3540,20 +3544,28 @@
 !
 
 rgbValueAt:aPoint
-    "retrieve a pixels rgb value at x/y; return a 24bit rgbValue (rrggbb, red is MSB).
-     Pixels start at 0@0 for upper left pixel, end at (width-1)@(height-1) for lower right pixel."
+    "retrieve a pixel's rgb value at x/y; 
+     return a 24bit rgbValue (rrggbb, red is MSB).
+     Pixels start at 0@0 for the upper left pixel, 
+     and end at (width-1)@(height-1) for the lower right pixel."
 
     ^ self rgbValueAtX:(aPoint x) y:(aPoint y)
+
+    "Modified (comment): / 29-08-2017 / 14:36:33 / cg"
 !
 
 rgbValueAtX:x y:y
-    "retrieve a pixels rgb value at x/y; return a 24bit rgbValue (rrggbb, red is MSB).
-     Pixels start at 0@0 for upper left pixel, end at (width-1)@(height-1) for lower right pixel."
+    "retrieve a pixel's rgb value at x/y; 
+     return a 24bit rgbValue (rrggbb, red is MSB).
+     Pixels start at 0@0 for the upper left pixel, 
+     and end at (width-1)@(height-1) for the lower right pixel."
 
     |pixel|
 
     pixel := self pixelAtX:x y:y.
     ^ self rgbFromValue:pixel
+
+    "Modified (comment): / 29-08-2017 / 14:36:48 / cg"
 !
 
 rgbValueAtX:x y:y put:newRGBValue
@@ -3654,7 +3666,7 @@
 !
 
 valueAt:aPoint
-    "WARNING: for now, this returns a pixels value
+    "WARNING: for now, this returns a pixel's value
      (backward compatibility with ST/X)
      In the future, this will return a color (ST-80 compatibility)
      Use #pixelAt: - for future compatibility.
@@ -3671,11 +3683,12 @@
     'Image [warning]: the Image>>valueAt: will change semantics soon; use #pixelAt:' infoPrintCR.
     ^ self pixelAtX:aPoint x y:aPoint y
 
-    "Modified: 21.6.1997 / 13:11:19 / cg"
+    "Modified: / 21-06-1997 / 13:11:19 / cg"
+    "Modified (comment): / 29-08-2017 / 14:36:52 / cg"
 !
 
 valueAtX:x y:y
-    "WARNING: for now, this returns a pixels value
+    "WARNING: for now, this returns a pixel's value
      (backward compatibility with ST/X)
      In the future, this will return a color (ST-80 compatibility)
      Use #pixelAt: - for future compatibility.
@@ -3692,7 +3705,8 @@
     'Image [warning]: the Image>>valueAtX:y: will change semantics soon; use #pixelAtX:y' infoPrintCR.
     ^ self pixelAtX:x y:y
 
-    "Modified: 21.6.1997 / 13:11:29 / cg"
+    "Modified: / 21-06-1997 / 13:11:29 / cg"
+    "Modified (comment): / 29-08-2017 / 14:36:57 / cg"
 ! !
 
 !Image methodsFor:'accessing-private'!
@@ -10556,6 +10570,61 @@
     "Modified: 11.7.1996 / 19:50:47 / cg"
 !
 
+rgbValuesAtY:y from:x1 to:x2 do:aBlock
+    "perform aBlock for each rgbValue from x1 to x2 in row y.
+     rgbValues are of the form rrggbb (i.e. red is in the high byte).
+     
+     Notice the difference between rgbValue and pixelValue: rgbValues are always
+     the rgb bytes; pixelvalues depend on the photometric interpretation, and may be
+     indices into a colormap or be non-byte-sized rgb values.
+
+     Notice that x and y coordinates start at 0@0 for the upper left corner.
+     The block is passed the x coordinate and the pixelValue at each pixel.
+     (see also Image>>atY:from:to:do:).
+     The code here provides a generic and slow implementation, and
+     should be redefined in concrete subclasses, to avoid some processing
+     when going from pixel to pixel (i.e. the byte-index and mask computations)."
+
+    |xStart "{Class: SmallInteger }"
+     xEnd   "{Class: SmallInteger }"|
+
+    xStart := x1.
+    xEnd := x2.
+    xStart to:xEnd do:[:xRun |
+        aBlock value:xRun value:(self rgbValueAtX:xRun y:y)
+    ]
+
+    "Created: / 29-08-2017 / 14:40:48 / cg"
+!
+
+rgbValuesFromX:xStart y:yStart toX:xEnd y:yEnd do:aBlock
+    "perform aBlock for each rgbValue in a rectangular area of the image.
+     rgbValues are of the form rrggbb (i.e. the redByte is in the high byte).
+
+     Notice the difference between rgbValue and pixelValue: rgbValues are always
+     the rgb bytes; pixelvalues depend on the photometric interpretation, and may be
+     indices into a colormap or be non-byte-sized rgb values.
+     
+     Notice that x and y coordinates start at 0@0 for the upper left corner.
+     The block is passed the x and y coordinates and pixelValue at each pixel.
+     The code here provides a generic and slow implementation, and
+     should be redefined in concrete subclasses, to avoid some processing
+     when going from pixel to pixel (i.e. the byte-index and mask computations)."
+
+    |yS "{Class: SmallInteger }"
+     yE "{Class: SmallInteger }"|
+
+    yS := yStart.
+    yE := yEnd.
+    yS to:yE do:[:yRun |
+        self rgbValuesAtY:yRun from:xStart to:xEnd do:[:xRun :rgb |
+            aBlock value:xRun value:yRun value:rgb
+        ]
+    ]
+
+    "Created: / 29-08-2017 / 14:39:34 / cg"
+!
+
 valueAtY:y from:x1 to:x2 do:aBlock
     "perform aBlock for each pixelValue from x1 to x2 in row y.
      Obsolete - remains for backward compatibility."
@@ -10569,12 +10638,15 @@
 !
 
 valuesAtY:y from:x1 to:x2 do:aBlock
-    "WARNING: for now, this enumerates pixel values
-     (backward compatibility with ST/X)
-     In the future, this will enumerate colors
-     Use #pixelAtT:from:to:do: - for future compatibility.
-
-     perform aBlock for each pixelValue from x1 to x2 in row y.
+    "WARNING: this enumerates pixel values which need photometric interpretation
+     Do not confuse with #rgbValuesAtY:from:to:do:
+
+     Perform aBlock for each pixelValue from x1 to x2 in row y.
+
+     Notice the difference between rgbValue and pixelValue: rgbValues are always
+     the rgb bytes; pixelvalues depend on the photometric interpretation, and may be
+     indices into a colormap or be non-byte-sized rgb values.
+
      Notice that x and y coordinates start at 0@0 for the upper left corner.
      The block is passed the x coordinate and the pixelValue at each pixel.
      (see also Image>>atY:from:to:do:).
@@ -10591,12 +10663,21 @@
         aBlock value:xRun value:(self pixelAtX:xRun y:y)
     ]
 
-    "Created: 7.6.1996 / 19:09:51 / cg"
-    "Modified: 24.4.1997 / 16:55:38 / cg"
+    "Created: / 07-06-1996 / 19:09:51 / cg"
+    "Modified: / 24-04-1997 / 16:55:38 / cg"
+    "Modified (comment): / 29-08-2017 / 14:44:50 / cg"
 !
 
 valuesFromX:xStart y:yStart toX:xEnd y:yEnd do:aBlock
-    "perform aBlock for each pixelValue in a rectangular area of the image.
+    "WARNING: this enumerates pixel values which need photometric interpretation
+     Do not confuse with #rgbValuesAtY:from:to:do:
+
+     Perform aBlock for each pixelValue in a rectangular area of the image.
+
+     Notice the difference between rgbValue and pixelValue: rgbValues are always
+     the rgb bytes; pixelvalues depend on the photometric interpretation, and may be
+     indices into a colormap or be non-byte-sized rgb values.
+
      Notice that x and y coordinates start at 0@0 for the upper left corner.
      The block is passed the x and y coordinates and pixelValue at each pixel.
      The code here provides a generic and slow implementation, and
@@ -10616,6 +10697,7 @@
 
     "Modified: / 07-06-1996 / 19:09:29 / cg"
     "Modified: / 31-01-2017 / 14:46:26 / stefan"
+    "Modified (comment): / 29-08-2017 / 14:45:06 / cg"
 ! !
 
 !Image methodsFor:'finalization'!